deal with xcode version and ld_classic

This commit is contained in:
Brendan Hansknecht 2024-07-13 09:44:29 -07:00
parent 0533578562
commit b1eb1e2971
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -1105,6 +1105,10 @@ fn link_macos(
.args(input_paths)
.args(extra_link_flags());
if get_xcode_version() >= 15.0 {
ld_command.arg("-ld_classic");
}
let sdk_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib";
if Path::new(sdk_path).exists() {
ld_command.arg(format!("-L{sdk_path}"));
@ -1187,6 +1191,25 @@ fn get_macos_version() -> String {
.join(".")
}
fn get_xcode_version() -> f32 {
let mut cmd = Command::new("xcodebuild");
cmd.arg("-version");
debug_print_command(&cmd);
cmd.output()
.map_err(|_| ())
.and_then(|out| String::from_utf8(out.stdout).map_err(|_| ()))
.and_then(|str| {
str.split_whitespace()
.skip(1)
.next()
.map(|s| s.to_string())
.ok_or(())
})
.and_then(|version| version.parse::<f32>().map_err(|_| ()))
.unwrap_or(0.0)
}
fn link_wasm32(
_target: Target,
output_path: PathBuf,