Skip to content

Commit 4d5a2f3

Browse files
authored
Rollup merge of rust-lang#105405 - sunfishcode:sunfishcode/export-dynamic, r=TaKO8Ki
Stop passing -export-dynamic to wasm-ld. -export-dynamic was a temporary hack added in the early days of the Rust wasm32 target when Rust didn't have a way to specify wasm exports in the source code. This flag causes all global symbols, and some compiler-internal symbols, to be exported, which is often more than needed. Rust now does have a way to specify exports in the source code: `#[export_name = "..."]`. So as the original comment suggests, -export-dynamic can now be removed, allowing users to have smaller binaries and better encapsulation in their wasm32-unknown-unknown modules. It's possible that this change will require existing wasm32-unknown-unknown users will to add explicit `#[export_name = "..."]` directives to exporrt the symbols that their programs depend on having exported.
2 parents f1f7560 + 3a07aa9 commit 4d5a2f3

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs

-7
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ pub fn target() -> Target {
3333
// For now this target just never has an entry symbol no matter the output
3434
// type, so unconditionally pass this.
3535
"--no-entry",
36-
// Rust really needs a way for users to specify exports and imports in
37-
// the source code. --export-dynamic isn't the right tool for this job,
38-
// however it does have the side effect of automatically exporting a lot
39-
// of symbols, which approximates what people want when compiling for
40-
// wasm32-unknown-unknown expect, so use it for now.
41-
"--export-dynamic",
4236
],
4337
);
4438
options.add_pre_link_args(
@@ -48,7 +42,6 @@ pub fn target() -> Target {
4842
// otherwise
4943
"--target=wasm32-unknown-unknown",
5044
"-Wl,--no-entry",
51-
"-Wl,--export-dynamic",
5245
],
5346
);
5447

0 commit comments

Comments
 (0)