From 5292adda3a0596ba3413fdf59e3e5a4fcb694bfe Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 17 Aug 2025 22:26:33 +0300 Subject: [PATCH 1/3] fix(compiler/rustc_target): set correct linker flags for `wasm32v1-none` --- compiler/rustc_target/src/spec/targets/wasm32v1_none.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs index e554e2ac07680..77b04e5a5d562 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs @@ -29,6 +29,11 @@ pub(crate) fn target() -> Target { // For now this target just never has an entry symbol no matter the output // type, so unconditionally pass this. "--no-entry", + // It is also necessary to explicitly set the features since some changes + // were made to WebAssembly starting with LLVM 20.1.0: + // https://releases.llvm.org/20.1.0/docs/ReleaseNotes.html#changes-to-the-webassembly-backend + "--features=+mutable-globals", + "--no-check-features", ], ); options.add_pre_link_args( @@ -37,7 +42,7 @@ pub(crate) fn target() -> Target { // Make sure clang uses LLD as its linker and is configured appropriately // otherwise "--target=wasm32-unknown-unknown", - "-Wl,--no-entry", + "-Wl,--no-entry,--features=+mutable-globals,--no-check-features", ], ); From 35f2feb939de975e17efe5d4401b96e3a58b47dd Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 17 Aug 2025 23:58:37 +0300 Subject: [PATCH 2/3] use `--mllvm=-mcpu=mvp` --- compiler/rustc_target/src/spec/targets/wasm32v1_none.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs index 77b04e5a5d562..141c3de5b2135 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs @@ -29,11 +29,10 @@ pub(crate) fn target() -> Target { // For now this target just never has an entry symbol no matter the output // type, so unconditionally pass this. "--no-entry", - // It is also necessary to explicitly set the features since some changes + // It is also necessary to explicitly set CPU since some changes // were made to WebAssembly starting with LLVM 20.1.0: // https://releases.llvm.org/20.1.0/docs/ReleaseNotes.html#changes-to-the-webassembly-backend - "--features=+mutable-globals", - "--no-check-features", + "--mllvm=-mcpu=mvp", ], ); options.add_pre_link_args( @@ -42,7 +41,7 @@ pub(crate) fn target() -> Target { // Make sure clang uses LLD as its linker and is configured appropriately // otherwise "--target=wasm32-unknown-unknown", - "-Wl,--no-entry,--features=+mutable-globals,--no-check-features", + "-Wl,--no-entry,--mllvm=-mcpu=mvp", ], ); From 8f0ff598287f25a0e34ee2ddf65d7d96cf88a34b Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Mon, 18 Aug 2025 10:30:27 +0300 Subject: [PATCH 3/3] add `--mllvm=-mattr=+mutable-globals` --- compiler/rustc_target/src/spec/targets/wasm32v1_none.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs index 141c3de5b2135..63a785a35b66c 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs @@ -29,10 +29,11 @@ pub(crate) fn target() -> Target { // For now this target just never has an entry symbol no matter the output // type, so unconditionally pass this. "--no-entry", - // It is also necessary to explicitly set CPU since some changes + // It is also necessary to explicitly set CPU and features since some changes // were made to WebAssembly starting with LLVM 20.1.0: // https://releases.llvm.org/20.1.0/docs/ReleaseNotes.html#changes-to-the-webassembly-backend "--mllvm=-mcpu=mvp", + "--mllvm=-mattr=+mutable-globals", ], ); options.add_pre_link_args( @@ -41,7 +42,7 @@ pub(crate) fn target() -> Target { // Make sure clang uses LLD as its linker and is configured appropriately // otherwise "--target=wasm32-unknown-unknown", - "-Wl,--no-entry,--mllvm=-mcpu=mvp", + "-Wl,--no-entry,--mllvm=-mcpu=mvp,--mllvm=-mattr=+mutable-globals", ], );