Skip to content
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

Compiling tests for wasm64-unknown-unknown on latest Nightly results in linking error #121460

Closed
newpavlov opened this issue Feb 22, 2024 · 2 comments · Fixed by #121464
Closed
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@newpavlov
Copy link
Contributor

Compiling any crate with cargo test --no-run -Z build-std=std,panic_abort --target=wasm64-unknown-unknown results in the following error: rust-lld: error: /home/dir/.cargo/target/wasm64-unknown-unknown/debug/deps/libtest-ed35d2d81ad088d3.rlib(lib.rmeta): wasm32 object file can't be linked in wasm64 mode. This is a regression introduced in one of the recent NIghtly versions.

Toolchain version: cargo 1.78.0-nightly (194a60b29 2024-02-21)

@newpavlov newpavlov added the C-bug Category: This is a bug. label Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@matthiaskrgr
Copy link
Member

Probably related to #120588 cc @alexcrichton

@alexcrichton
Copy link
Member

Yep definitely looks like my fault, I'll work on a fix!

alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 22, 2024
It looks like LLD will detect object files being either 32 or 64-bit
depending on any memory present. LLD will additionally reject 32-bit
objects during a 64-bit link. Previously metadata objects did not have
any memories in them which led LLD to conclude they were 32-bit objects
which broke 64-bit targets for wasm.

This commit fixes this by ensuring that for 64-bit targets there's a
memory object present to get LLD to detect it's a 64-bit target.
Additionally this commit moves away from a hand-crafted wasm encoder to
the `wasm-encoder` crate on crates.io as the complexity grows for the
generated object file.

Closes rust-lang#121460
@jieyouxu jieyouxu added A-linkage Area: linking into static, shared libraries and binaries O-wasm Target: WASM (WebAssembly), http://webassembly.org/ -Zbuild-std Unstable Cargo option: Compile the standard library yourself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 22, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 29, 2024
…iser

rustc: Fix wasm64 metadata object files

It looks like LLD will detect object files being either 32 or 64-bit depending on any memory present. LLD will additionally reject 32-bit objects during a 64-bit link. Previously metadata objects did not have any memories in them which led LLD to conclude they were 32-bit objects which broke 64-bit targets for wasm.

This commit fixes this by ensuring that for 64-bit targets there's a memory object present to get LLD to detect it's a 64-bit target. Additionally this commit moves away from a hand-crafted wasm encoder to the `wasm-encoder` crate on crates.io as the complexity grows for the generated object file.

Closes rust-lang#121460
@bors bors closed this as completed in 646e8e7 Mar 1, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 1, 2024
Rollup merge of rust-lang#121464 - alexcrichton:fix-wasm64, r=wesleywiser

rustc: Fix wasm64 metadata object files

It looks like LLD will detect object files being either 32 or 64-bit depending on any memory present. LLD will additionally reject 32-bit objects during a 64-bit link. Previously metadata objects did not have any memories in them which led LLD to conclude they were 32-bit objects which broke 64-bit targets for wasm.

This commit fixes this by ensuring that for 64-bit targets there's a memory object present to get LLD to detect it's a 64-bit target. Additionally this commit moves away from a hand-crafted wasm encoder to the `wasm-encoder` crate on crates.io as the complexity grows for the generated object file.

Closes rust-lang#121460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants