Fix clang-cl target when cross-compiling#1670
Conversation
Otherwise it forces the Arch of the host upon the compilation, producing for example `coff arm64` on Darwin aarch64 host for target `x86_64-pc-windows-msvc`
madsmtm
left a comment
There was a problem hiding this comment.
Hmm, are you sure? target here should be the target we're compiling for, this seems more like it'd regress cross-compilation? E.g. compiling from x86_64-pc-windows-msvc to i686-pc-windows-msvc, we'd no longer be passing -m32?
|
Yes I'm sure that that code was producing a How is the original code supposed to understand it will compile for Windows when ran on a Darwin host? It does not set the
We'd be passing |
|
Right, I didn't read the Frankly, I'm leaning towards maybe just removing the branching here, and instead always pass |
I was about to ask you the same thing. What do you think, should I go that way? EDIT: probably we should maintain the if clang_cl {
cmd.push_cc_arg(
format!(
"--target={}",
target.llvm_target(&self.get_raw_target()?, None)
)
.into(),
);
if target.arch == "x86" {
// See
// <https://learn.microsoft.com/en-us/cpp/build/reference/arch-x86?view=msvc-170>.
//
// NOTE: Rust officially supported Windows targets all require SSE2 as part
// of baseline target features.
//
// NOTE: The same applies for STL. See: -
// <https://github.com/microsoft/STL/issues/3922>, and -
// <https://github.com/microsoft/STL/pull/4741>.
cmd.push_cc_arg("-arch:SSE2".into());
}
} |
|
I'd be in favor of that, especially if you can test that it works on a Windows machine (if not, I can do it, but it'll take me a little while to get it set up on a VM). |
|
Ok, I'll go that way then, cool thanks for the quick answers, really appreciate it! |
Some issues observed: - macOS ARM host, compiling for `x86_64-pc-windows-msvc` target, producing unexpectidly `coff arm64`.
|
I tested that new approach in the JetBrains monorepo (Fleet/Air is using Rust extensively under the hood with some non-trivial crates) and it worked fine there. I also tested it on ArchangelX360/toolchains_llvm_testbench too, just so that you can have a look at a usual setup I would be testing against, it's important to read that section to understand what is out of the ordinary in my setups. It won't work if you try to run it yourself, because it requires an MSVC sysroot archive, which I cannot provide you for legal reasons (thanks Microsoft Please re-review when you have time, and we could move to a merge if you feel like it 😄 |
|
(CI is gonna make a release on Friday IIRC) |
Otherwise it forces the Arch of the host upon the compilation, producing for example
coff arm64on Darwin aarch64 host for targetx86_64-pc-windows-msvc