Skip to content

Commit ccb5d0a

Browse files
committed
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.
1 parent 4b65a86 commit ccb5d0a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/librustc_target/spec/apple_ios_base.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::env;
12
use std::io;
23
use std::process::Command;
34
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
@@ -27,6 +28,12 @@ impl Arch {
2728
}
2829

2930
pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
31+
if let Some(sdkroot) = env::var("SDKROOT").ok() {
32+
let sdkroot_path = Path::new(sdkroot);
33+
if sdkroot_path.is_absolute() && sdkroot_path != Path::new("/") && sdkroot_path.exists() {
34+
return Ok(sdkroot);
35+
}
36+
}
3037
let res = Command::new("xcrun")
3138
.arg("--show-sdk-path")
3239
.arg("-sdk")

0 commit comments

Comments
 (0)