cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

aarch64-apple-ios-sim: unrecognized command line option ‘-arch arm64’

Open smaryus opened this issue 3 years ago • 5 comments

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.

smaryus avatar Aug 02 '22 11:08 smaryus

I have the same error. I'm surprised that this issue remained open for about a year.

paxbun avatar Jun 11 '23 13:06 paxbun

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".

paxbun avatar Jun 11 '23 13:06 paxbun

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.

paxbun avatar Jun 11 '23 14:06 paxbun

Changing the version of cc in Cargo.lock to "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 avatar Feb 13 '24 11:02 CodingMarkus

@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?~~

image

I rechecked the release changelog, and it is in 1.0.79, was the issue reopened when working on 1.0.83?

paxbun avatar Feb 13 '24 23:02 paxbun