1
- use std:: env;
2
- use std:: str:: FromStr ;
3
-
4
- use rustc_session:: Session ;
5
1
use rustc_target:: spec:: Target ;
6
2
pub ( super ) use rustc_target:: spec:: apple:: OSVersion ;
7
3
8
- use crate :: errors:: AppleDeploymentTarget ;
9
-
10
4
#[ cfg( test) ]
11
5
mod tests;
12
6
@@ -26,54 +20,6 @@ pub(super) fn macho_platform(target: &Target) -> u32 {
26
20
}
27
21
}
28
22
29
- /// Name of the environment variable used to fetch the deployment target on the given OS.
30
- pub fn deployment_target_env_var ( os : & str ) -> & ' static str {
31
- match os {
32
- "macos" => "MACOSX_DEPLOYMENT_TARGET" ,
33
- "ios" => "IPHONEOS_DEPLOYMENT_TARGET" ,
34
- "watchos" => "WATCHOS_DEPLOYMENT_TARGET" ,
35
- "tvos" => "TVOS_DEPLOYMENT_TARGET" ,
36
- "visionos" => "XROS_DEPLOYMENT_TARGET" ,
37
- _ => unreachable ! ( "tried to get deployment target env var for non-Apple platform" ) ,
38
- }
39
- }
40
-
41
- /// Get the deployment target based on the standard environment variables, or fall back to the
42
- /// minimum version supported by `rustc`.
43
- pub fn deployment_target ( sess : & Session ) -> OSVersion {
44
- let min = OSVersion :: minimum_deployment_target ( & sess. target ) ;
45
- let env_var = deployment_target_env_var ( & sess. target . os ) ;
46
-
47
- if let Ok ( deployment_target) = env:: var ( env_var) {
48
- match OSVersion :: from_str ( & deployment_target) {
49
- Ok ( version) => {
50
- let os_min = OSVersion :: os_minimum_deployment_target ( & sess. target . os ) ;
51
- // It is common that the deployment target is set a bit too low, for example on
52
- // macOS Aarch64 to also target older x86_64. So we only want to warn when variable
53
- // is lower than the minimum OS supported by rustc, not when the variable is lower
54
- // than the minimum for a specific target.
55
- if version < os_min {
56
- sess. dcx ( ) . emit_warn ( AppleDeploymentTarget :: TooLow {
57
- env_var,
58
- version : version. fmt_pretty ( ) . to_string ( ) ,
59
- os_min : os_min. fmt_pretty ( ) . to_string ( ) ,
60
- } ) ;
61
- }
62
-
63
- // Raise the deployment target to the minimum supported.
64
- version. max ( min)
65
- }
66
- Err ( error) => {
67
- sess. dcx ( ) . emit_err ( AppleDeploymentTarget :: Invalid { env_var, error } ) ;
68
- min
69
- }
70
- }
71
- } else {
72
- // If no deployment target variable is set, default to the minimum found above.
73
- min
74
- }
75
- }
76
-
77
23
pub ( super ) fn add_version_to_llvm_target (
78
24
llvm_target : & str ,
79
25
deployment_target : OSVersion ,
0 commit comments