fix: ios hotpatching due to missing isysroot flag

This commit is contained in:
Jonathan Kelley committed 2025-10-14 19:59:25 -07:00
1 parent 7102bc3b6a
commit 056b47fcd0
1 file changed
+30 -2
+30 -2
View File
@@ -868,6 +868,26 @@ impl BuildRequest {
]);
}
// Make sure we set the sysroot for ios builds in the event the user doesn't have it set
if matches!(bundle, BundleFormat::Ios) {
let xcode_path = Workspace::get_xcode_path()
.await
.unwrap_or_else(|| "/Applications/Xcode.app".to_string().into());
let sysroot_location = match triple.environment {
target_lexicon::Environment::Sim => xcode_path
.join("Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"),
_ => xcode_path.join("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"),
};
if sysroot_location.exists() && !rustflags.flags.iter().any(|f| f == "-isysroot") {
rustflags.flags.extend([
"-Clink-arg=-isysroot".to_string(),
format!("-Clink-arg={}", sysroot_location.display()),
]);
}
}
// automatically set the getrandom backend for web builds if the user requested it
if matches!(bundle, BundleFormat::Web) && args.wasm_js_cfg {
rustflags.flags.extend(
@@ -1842,12 +1862,20 @@ impl BuildRequest {
// -lxyz
// There might be more, but some flags might break our setup.
for (idx, arg) in original_args.iter().enumerate() {
if *arg == "-framework" || *arg == "-arch" || *arg == "-L" {
if *arg == "-framework"
|| *arg == "-arch"
|| *arg == "-L"
|| *arg == "-target"
|| *arg == "-isysroot"
{
out_args.push(arg.to_string());
out_args.push(original_args[idx + 1].to_string());
}
if arg.starts_with("-l") || arg.starts_with("-m") {
if arg.starts_with("-l")
|| arg.starts_with("-m")
|| arg.starts_with("-nodefaultlibs")
{
out_args.push(arg.to_string());
}
}