diff --git a/src/librustc_target/spec/apple_ios_base.rs b/src/librustc_target/spec/apple_ios_base.rs index d400bc62bfd07..f46ad06ba436a 100644 --- a/src/librustc_target/spec/apple_ios_base.rs +++ b/src/librustc_target/spec/apple_ios_base.rs @@ -29,6 +29,12 @@ impl Arch { } pub fn get_sdk_root(sdk_name: &str) -> Result { + // Following what clang does + // (https://github.com/llvm/llvm-project/blob/ + // 296a80102a9b72c3eda80558fb78a3ed8849b341/clang/lib/Driver/ToolChains/Darwin.cpp#L1661-L1678) + // to allow the SDK path to be set. (For clang, xcrun sets + // SDKROOT; for rustc, the user or build system can set it, or we + // can fall back to checking for xcrun on PATH.) if let Some(sdkroot) = env::var("SDKROOT").ok() { let sdkroot_path = Path::new(&sdkroot); if sdkroot_path.is_absolute() && sdkroot_path != Path::new("/") && sdkroot_path.exists() {