-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Official binaries for wasm32-unknown-unknown
(and potentially other WASM platforms?) contain code for the wrong architecture
#132802
Comments
@emilazy are you interested in fixing this? i think there are three main steps:
optionally, you could also change bootstrap to default to i'm happy to mentor this. @rustbot label E-mentor |
I'm still willing to mentor. I think this would be a challenging first issue but you could do it if you're motivated. There are lots of small things to change, but you will (mostly) have short feedback loops, and finding which parts of the code are relevant will not be too hard I think. Take a look at |
I think I'll take this issue on. Are there any steps I need to take besides forking the repository, such as claiming this issue or moving to a different platform to communicate with you? |
both those, yeah - i think i'm on zulip as "jyn". |
Great, I'll scope out the bootstrap module @rustbot claim |
That seems like the sort of thing that would have gotten noticed almost immediately, compiler-builtins is always provided at linktime. How is this working currently - are builtins never actually needed or is it somehow possible to link wasm and x86 objects together? |
bootstrap supports disabling you can see in #136096 that LLD unconditionally warns when compiling to wasm32-unknown, but it is silenced by rustc so you can't see the warning. I suspect what has happened is:
@tgross35 i think doing that in compiler-builtins would be a good step, yeah. but it still requires work downstream in rust-lang/rust - all the steps in #132802 (comment) are still required; maybe we could get away with delaying step 1 until bootstrap actually builds compiler-builtins, but it would ideally be nice to catch it early. |
cc #105065 |
I think this is a result of rust-lang/compiler-builtins#566 Basically, this doesn’t affect any builtins that are called by Rust, so if you’re only building Rust code for wasm, you’ll never run into this. |
i am confused - i thought the builtins have the same mangled names at runtime, regardless of whether you use the C builtins or the rust builtins, the only difference is that the rust builtins are weak symbols and the c builtins are strong. looking at rust-lang/compiler-builtins#566, it seems it doesn't make any changes other than to compile the C builtins? so it makes sense to me it's falling back to the rust ones. but i don't understand what "only called by rust" has to do with anything. |
Sorry, I added a spurious “only” there and fixed it in edit. My understanding is that the only builtins that are miscompiled are ones that Rust never calls. But if you use clang to compile some C to wasm (to ultimately link with your Rust), it may use these extra builtins. So it might be useful to make these builtins available. Which it sounds like you have a plan to make possible. :) |
The
compiler-builtins
crate compiles C code for WASM platforms since rust-lang/compiler-builtins#566. This works if the C compiler is Clang, as it passes the appropriate-target
. However, in a GCC build environment this means that thecc
crate will end up silently compiling code for the wrong architecture entirely. This means that, for example, thecompiler-builtins
shipping forwasm32-unknown-unknown
via Rustup contains object files like the following:I suppose that the build for these needs to arrange for Clang to be present, or perhaps even specified explicitly in the
target.*.{cc,cxx,linker}
settings.(Was redirected here from rust-lang/compiler-builtins#732.)
The text was updated successfully, but these errors were encountered: