Skip to content

Commit 4486916

Browse files
authored
Rollup merge of rust-lang#150164 - fix-wasm-export-executable-symbols, r=jdonszelmann
rustc: Fix `-Zexport-executable-symbols` on wasm This commit reorders some cases in `export_symbols` in the linker implementation for wasm to ensure that the `is_like_wasm` case is handled before the catch-all `CrateType::Executable` case.
2 parents 1b60a50 + 5610d84 commit 4486916

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,11 @@ impl<'a> Linker for GccLinker<'a> {
839839
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
840840
}
841841
self.link_arg(path);
842+
} else if self.sess.target.is_like_wasm {
843+
self.link_arg("--no-export-dynamic");
844+
for (sym, _) in symbols {
845+
self.link_arg("--export").link_arg(sym);
846+
}
842847
} else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris {
843848
let res: io::Result<()> = try {
844849
let mut f = File::create_buffered(&path)?;
@@ -853,11 +858,6 @@ impl<'a> Linker for GccLinker<'a> {
853858
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
854859
}
855860
self.link_arg("--dynamic-list").link_arg(path);
856-
} else if self.sess.target.is_like_wasm {
857-
self.link_arg("--no-export-dynamic");
858-
for (sym, _) in symbols {
859-
self.link_arg("--export").link_arg(sym);
860-
}
861861
} else {
862862
// Write an LD version script
863863
let res: io::Result<()> = try {

0 commit comments

Comments
 (0)