clang-cl: use /arch:SSE2 for x86 target arch by jieyouxu · Pull Request #1425 · rust-lang/cc-rs (original) (raw)

…15245)

What does this PR try to resolve?

GitHub Runner Images 20250224.5.0+ ship Windows 11 SDK 10.0.26100+ compared to the previous Windows 11 SDK 10.0.22621, which bumped the UCRT headers. The new UCRT headers use SSE2 types. However, cc versions <= 1.2.15 emit /arch:IA32 for x86 Windows targets for clang-cl, which causes compilation errors since clang-cl can't find SSE2 types without /arch:SSE2 specified (or defaulted). (Note that MSVC at the time of writing silently accepts and emits instruments for code using SSE2 types, as opposed to clang-cl hard error-ing).

cc 1.2.16 contains a fix for this problem, rust-lang/cc-rs#1425, to correctly emit /arch:SSE2 instead of /arch:IA32 to enable clang-cl to find the SSE2 types. However, cargo's cc currently is still on 1.2.13.

To fix this for rust-lang/rust CI, we need to bump anything that transitively relies on cc and tries to use clang-cl on x86 Windows targets to compile any C/C++ code that transitively use functions or types that require SSE2 types, such as <wchar.h>.

How should we test and review this PR?

The fix was initially intended for rustc_{codegen_ssa,llvm} cc, and based on testing in rust-lang/rust#137724, I was able to successfully build rustc_{codegen_ssa,llvm} with a forked cc based on 1.2.15 which contains the fix from rust-lang/cc-rs#1425. Note that in the same PR, while the compiler build succeeded, the build of cargo itself failed since it transitively used a cc without the fix to build curl-sys[^dep-chain], which failed as one might expect (curl-sys tries to build C code that uses <wchar.h> which runs into the same problem). Hence, this PR is opened to bump cargo's cc to a cc version containing the fix.

Additional information

This x86 Windows CI problem is:

cc changelog between 1.2.13 and 1.2.16

`cc` changes since 1.2.13 up to and including 1.2.16

1.2.16

Fixed
Other

1.2.15

Other

1.2.14

Other

[^dep-chain]: I think the dep chain is something like git2 -> libgit2-sys -> curl -> curl-sys?