aarch64-apple-ios-sim: unrecognized command line option ‘-arch arm64’
When I try to compile on M1 for iOS Simulator:
build()
.file(&path)
.flag("-Werror")
.compile("name");
it finishes with the following error:
running: "clang" "-O3" "-fPIC" "--target=arm64-apple-ios7.0-simulator" "-arch arm64" "-mios-simulator-version-min=7.0" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk" "-fembed-bitcode" "-Wall" "-Wextra" "-Werror" "-o" "output_file.o" "-c" "some_c_file.c"
cargo:warning=clang: error: argument unused during compilation: '-arch arm64' [-Werror,-Wunused-command-line-argument]
exit status: 1
The problem might be related to this (lib.rs):
} else if is_sim {
match arch {
"arm64" | "aarch64" => ArchSpec::Simulator("-arch arm64"),
_ => {
return Err(Error::new(
ErrorKind::ArchitectureInvalid,
"Unknown architecture for iOS simulator target.",
));
}
}
}
that arm64 is always added.
I have the same error. I'm surprised that this issue remained open for about a year.
Seems like this is because clang recognizes "-arch arm64" as one argument without any value, clang-16 works well with "-arch" "arm64", but not with "-arch arm64".
Oh, this is already fixed: https://github.com/rust-lang/cc-rs/pull/759
Changing the version of cc in Cargo.lock to "1.0.79" resolved the issue.
Changing the version of
ccinCargo.lockto "1.0.79" resolved the issue.
I cannot confirm that. The current stable release (1.76) is pinned to 1.0.79 and I still have that issue. I even tried building with 1.78.0-nightly and it also has this issue.
According to the issue you've liked, it has been fixed in cc 1.0.83.
@CodingMarkus ~~You're right, I also don't get why I thought it was already fixed, but I upgraded cc from 1.0.77 to 1.0.79 and it worked. Maybe my problem was fixed thanks to the changes between those versions?~~
I rechecked the release changelog, and it is in 1.0.79, was the issue reopened when working on 1.0.83?