From e919f0f20e61d6eb0abbd514bf2dd5b35428a2e7 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 10 Mar 2023 13:13:08 -0500 Subject: [PATCH 1/4] the fix (fixed build by adding missing import.) --- compiler/rustc_target/src/spec/wasm_base.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index 625d3b37c4f26..341763aadbaf1 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -1,3 +1,4 @@ +use super::crt_objects::LinkSelfContainedDefault; use super::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; pub fn options() -> TargetOptions { @@ -94,6 +95,13 @@ pub fn options() -> TargetOptions { pre_link_args, + // FIXME: Figure out cases in which WASM needs to link with a native toolchain. + // + // rust-lang/rust#104137: cannot blindly remove this without putting in + // some other way to compensate for lack of `-nostartfiles` in linker + // invocation. + link_self_contained: LinkSelfContainedDefault::True, + // This has no effect in LLVM 8 or prior, but in LLVM 9 and later when // PIC code is implemented this has quite a drastic effect if it stays // at the default, `pic`. In an effort to keep wasm binaries as minimal From 568b7221402b348fe65fd87ade2e1174b356bd74 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 10 Mar 2023 13:13:45 -0500 Subject: [PATCH 2/4] Test using pattern established in run-make/wasm-stringify-ints-small. Replicates problem on my machine. To exercise the test, I had to use a config.toml that has: ``` [build] target = ["x86_64-unknown-linux-gnu","wasm32-unknown-unknown"] nodejs = "node" [rust] lld = true ``` --- tests/run-make/wasm-override-linker/Makefile | 11 +++++++++++ tests/run-make/wasm-override-linker/foo.rs | 1 + 2 files changed, 12 insertions(+) create mode 100644 tests/run-make/wasm-override-linker/Makefile create mode 100644 tests/run-make/wasm-override-linker/foo.rs diff --git a/tests/run-make/wasm-override-linker/Makefile b/tests/run-make/wasm-override-linker/Makefile new file mode 100644 index 0000000000000..d6163b1e04f1b --- /dev/null +++ b/tests/run-make/wasm-override-linker/Makefile @@ -0,0 +1,11 @@ +include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=clang +else ifeq ($(TARGET),wasm64-unknown-unknown) +all: + $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=clang +else +all: +endif diff --git a/tests/run-make/wasm-override-linker/foo.rs b/tests/run-make/wasm-override-linker/foo.rs new file mode 100644 index 0000000000000..4bd8276f34927 --- /dev/null +++ b/tests/run-make/wasm-override-linker/foo.rs @@ -0,0 +1 @@ +// empty file From cda130fd0319bf1e1bd88825e87763e3186970ff Mon Sep 17 00:00:00 2001 From: Felix S Klock II Date: Wed, 29 Mar 2023 11:29:05 -0400 Subject: [PATCH 3/4] Delete Makefile removing regression test --- tests/run-make/wasm-override-linker/Makefile | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 tests/run-make/wasm-override-linker/Makefile diff --git a/tests/run-make/wasm-override-linker/Makefile b/tests/run-make/wasm-override-linker/Makefile deleted file mode 100644 index d6163b1e04f1b..0000000000000 --- a/tests/run-make/wasm-override-linker/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -include ../../run-make-fulldeps/tools.mk - -ifeq ($(TARGET),wasm32-unknown-unknown) -all: - $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=clang -else ifeq ($(TARGET),wasm64-unknown-unknown) -all: - $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=clang -else -all: -endif From 167623a36ae0b09381d4297886c29dc869c350f6 Mon Sep 17 00:00:00 2001 From: Felix S Klock II Date: Wed, 29 Mar 2023 11:29:21 -0400 Subject: [PATCH 4/4] Delete foo.rs removing regression test --- tests/run-make/wasm-override-linker/foo.rs | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/run-make/wasm-override-linker/foo.rs diff --git a/tests/run-make/wasm-override-linker/foo.rs b/tests/run-make/wasm-override-linker/foo.rs deleted file mode 100644 index 4bd8276f34927..0000000000000 --- a/tests/run-make/wasm-override-linker/foo.rs +++ /dev/null @@ -1 +0,0 @@ -// empty file