1- use std:: env;
21use std:: ffi:: OsString ;
3- use std:: str:: FromStr ;
42use std:: path:: PathBuf ;
53use std:: process:: Command ;
64
@@ -11,7 +9,7 @@ use rustc_target::spec::Target;
119pub ( super ) use rustc_target:: spec:: apple:: OSVersion ;
1210use tracing:: debug;
1311
14- use crate :: errors:: { AppleDeploymentTarget , XcrunError , XcrunSdkPathWarning } ;
12+ use crate :: errors:: { XcrunError , XcrunSdkPathWarning } ;
1513use crate :: fluent_generated as fluent;
1614
1715#[ cfg( test) ]
@@ -134,54 +132,6 @@ pub(super) fn add_data_and_relocation(
134132 Ok ( ( ) )
135133}
136134
137- /// Name of the environment variable used to fetch the deployment target on the given OS.
138- pub fn deployment_target_env_var ( os : & str ) -> & ' static str {
139- match os {
140- "macos" => "MACOSX_DEPLOYMENT_TARGET" ,
141- "ios" => "IPHONEOS_DEPLOYMENT_TARGET" ,
142- "watchos" => "WATCHOS_DEPLOYMENT_TARGET" ,
143- "tvos" => "TVOS_DEPLOYMENT_TARGET" ,
144- "visionos" => "XROS_DEPLOYMENT_TARGET" ,
145- _ => unreachable ! ( "tried to get deployment target env var for non-Apple platform" ) ,
146- }
147- }
148-
149- /// Get the deployment target based on the standard environment variables, or fall back to the
150- /// minimum version supported by `rustc`.
151- pub fn deployment_target ( sess : & Session ) -> OSVersion {
152- let min = OSVersion :: minimum_deployment_target ( & sess. target ) ;
153- let env_var = deployment_target_env_var ( & sess. target . os ) ;
154-
155- if let Ok ( deployment_target) = env:: var ( env_var) {
156- match OSVersion :: from_str ( & deployment_target) {
157- Ok ( version) => {
158- let os_min = OSVersion :: os_minimum_deployment_target ( & sess. target . os ) ;
159- // It is common that the deployment target is set a bit too low, for example on
160- // macOS Aarch64 to also target older x86_64. So we only want to warn when variable
161- // is lower than the minimum OS supported by rustc, not when the variable is lower
162- // than the minimum for a specific target.
163- if version < os_min {
164- sess. dcx ( ) . emit_warn ( AppleDeploymentTarget :: TooLow {
165- env_var,
166- version : version. fmt_pretty ( ) . to_string ( ) ,
167- os_min : os_min. fmt_pretty ( ) . to_string ( ) ,
168- } ) ;
169- }
170-
171- // Raise the deployment target to the minimum supported.
172- version. max ( min)
173- }
174- Err ( error) => {
175- sess. dcx ( ) . emit_err ( AppleDeploymentTarget :: Invalid { env_var, error } ) ;
176- min
177- }
178- }
179- } else {
180- // If no deployment target variable is set, default to the minimum found above.
181- min
182- }
183- }
184-
185135pub ( super ) fn add_version_to_llvm_target (
186136 llvm_target : & str ,
187137 deployment_target : OSVersion ,
0 commit comments