Skip to content

Official binaries for wasm32-unknown-unknown (and potentially other WASM platforms?) contain code for the wrong architecture #132802

Open
@emilazy

Description

@emilazy

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 the cc crate will end up silently compiling code for the wrong architecture entirely. This means that, for example, the compiler-builtins shipping for wasm32-unknown-unknown via Rustup contains object files like the following:

45c91108d938afe8-cmpti2.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped

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

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 9, 2024
added
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
O-wasmTarget: WASM (WebAssembly), http://webassembly.org/
on Nov 9, 2024
removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 10, 2024
jyn514

jyn514 commented on Feb 10, 2025

@jyn514
Member

@emilazy are you interested in fixing this? i think there are three main steps:

  1. give a hard error in bootstrap when using gcc to compile for wasm
  2. change our CI to use clang instead of gcc
  3. add a test that compiling a sample program for wasm32-unknown doesn't give any linker warnings

optionally, you could also change bootstrap to default to clang instead of cc for wasm32-unknown.

i'm happy to mentor this.

@rustbot label E-mentor

added
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on Feb 10, 2025
JayAndJef

JayAndJef commented on Feb 18, 2025

@JayAndJef

Hi @jyn514! If @emilazy doesn't want to take on this issue, I would be glad to. I'm not sure if this is beyond the scope of mine or yours, however, as i'm looking for a good first issue in rustc to resolve - would you be willing to mentor?

jyn514

jyn514 commented on Feb 18, 2025

@jyn514
Member

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 src/bootstrap, at the dev guide for bootstrap, and at the wasm32-unknown platform docs. This check should probably (?) live in sanity.rs, which has flaws, but it's what we have right now.

JayAndJef

JayAndJef commented on Feb 19, 2025

@JayAndJef

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?

jyn514

jyn514 commented on Feb 19, 2025

@jyn514
Member

both those, yeah - i think @rustbot claim is the current syntax?

i'm on zulip as "jyn".

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @trevyn@saethlin@tgross35@bjorn3@emilazy

      Issue actions

        Official binaries for `wasm32-unknown-unknown` (and potentially other WASM platforms?) contain code for the wrong architecture · Issue #132802 · rust-lang/rust