Work around Xcode 15 breaking older macOS versions

This commit is contained in:
Damien Elmes 2023-11-02 19:54:44 +10:00
parent 51a10f0969
commit 373a63f610

View file

@ -3,7 +3,9 @@
use std::process::Command;
use anki_process::CommandExt;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use super::artifacts::macos_deployment_target;
use crate::run::run_command;
@ -37,5 +39,14 @@ pub fn build_bundle_binary() {
)
.env("MACOSX_DEPLOYMENT_TARGET", macos_deployment_target())
.env("CARGO_BUILD_TARGET", env!("TARGET"));
if env!("TARGET") == "x86_64-apple-darwin" {
let xcode_path = Command::run_with_output(["xcode-select", "-p"]).unwrap();
let ld_classic = Utf8PathBuf::from(xcode_path.stdout.trim())
.join("Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic");
if ld_classic.exists() {
// work around XCode 15's default linker not supporting macOS 10.15-12.
command.env("RUSTFLAGS", &format!("-Clink-arg=-fuse-ld={ld_classic}"));
}
}
run_command(&mut command);
}