diff options
| author | Scott Wolchok <swolchok@fb.com> | 2019-07-16 13:29:40 -0700 |
|---|---|---|
| committer | Scott Wolchok <swolchok@fb.com> | 2019-07-16 13:29:40 -0700 |
| commit | ccb5d0a7c170434bb2ced860ec7139f4c6f964ce (patch) | |
| tree | ecea740a970a62cafd7ee7cd2b7c85f30e0ffbf5 /src | |
| parent | 4b65a86ebace8600c8e269e8bfe3365cdc460e68 (diff) | |
Support SDKROOT env var on iOS
Following what clang does (https://github.com/llvm/llvm-project/blob/296a80102a9b72c3eda80558fb78a3ed8849b341/clang/lib/Driver/ToolChains/Darwin.cpp#L1661-L1678), allow allow SDKROOT to tell us where the Apple SDK lives so we don't have to invoke xcrun.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_target/spec/apple_ios_base.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc_target/spec/apple_ios_base.rs b/src/librustc_target/spec/apple_ios_base.rs index 3068ed8d206..40cc7f42010 100644 --- a/src/librustc_target/spec/apple_ios_base.rs +++ b/src/librustc_target/spec/apple_ios_base.rs @@ -1,3 +1,4 @@ +use std::env; use std::io; use std::process::Command; use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; @@ -27,6 +28,12 @@ impl Arch { } pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> { + 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() { + return Ok(sdkroot); + } + } let res = Command::new("xcrun") .arg("--show-sdk-path") .arg("-sdk") |
