-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm32-unknown-unknown
build as part of rustc
contains object files for the wrong architecture when using GCC
#732
Comments
GCC doesn't support wasm at all, so building a fully optimized version of compiler-builtins for wasm requires using clang. It should be possible to configure clang as C compiler just for wasm32-unknown-unknown in the config.toml file that contains all build configuration for building rustc while still using GCC for the rest. There is also an option there to disable optimized compiler builtins (which skips building C entirely for compiler-builtins), but this can only be disabled globally and thus would make the compiler itself a bit slower too. |
Right. But it at least seems like a flaw in the build script that it will currently happily guess that it should use GCC (for, most likely, the platform that FWIW it seems like this problem was exposed by #566 and the motivation there was compatibility with C code, which would make sense with my experience that I couldn’t find any way to get Rust to try and call the broken code. |
The cc crate (which most crates use to build C code) by default attempts to use gcc or clang as C compiler even when cross-compiling. If you need another C compiler in general or for a specific target, you have to tell it using an env var. Rust's build systems sets this env var when you specify a C compiler for your target in config.toml. |
Fair enough, although using unprefixed |
I missed the part of your message that this also effects the official toolchain builds. This probably will have to be fixed in the build system of rust, so https://github.com/rust-lang/rust/issues would be the best place to report this. |
Thanks; I’ve opened rust-lang/rust#132802. The fallback compiler behaviour still seems somewhat broken to me in a cross‐compilation context – hence both Nixpkgs and the Rust project itself ending up with silently broken builds – but I suppose that’s more of a bug in the |
Hi there, I’m not sure if I should report this here or in rust-lang/rust, so please let me know if I need to move this report elsewhere.
When investigating issues with the Nixpkgs
rustc
build, we discovered that when enabling thewasm32-unknown-unknown
target on Linux, thelibcompiler_builtins-*.rlib
built for that platform contained object files for the architecture the compiler is being built for, rather than WASM ones. These correspond to the C‐based compiler-rt intrinsics.I spent hours assuming this was purely a bug with our build environment until I looked at what
rustup
is shipping forwasm32-unknown-unknown
:I can’t seem to induce Rust to try and link with these – whenever I do something that ought to use one of the intrinsics it just open‐codes it into the output WASM – but this seems kind of bad? When this crate is built with a Clang‐based environment, it passes
--target
and they’re built for the right platform, but it will also happily use a single‐target GCC and build for the entirely wrong platform. (It’s also not entirely clear to me how the Clang‐based build is meant to work, as the compiler-rt C files depend onlibc
headers despite the platform being freestanding; it seems to at least work by coincidence on our Clang‐based Darwin build, but fail in exciting ways if we try to use Clang on Linux.)If these C‐based intrinsics are never used on
wasm32-unknown-unknown
, then they should probably not get compiled in the first place, but if they matter then it seems like they’re currently broken on GCC‐based environments.The text was updated successfully, but these errors were encountered: