Don't link with --export-dynamic on wasm32-wasi
Remove --export-dynamic from the link arguments on the wasm32-wasi target, as it emits spurious exports and increases code size. Leave it in place for wasm32-unknown-unknown and wasm32-unknown-emscripten. Even though it isn't a great solution there, users are likely depending on its behavior there.
This commit is contained in:
parent
65767e5653
commit
9abcfa55c3
3 changed files with 24 additions and 15 deletions
|
@ -55,15 +55,6 @@ pub fn options() -> TargetOptions {
|
||||||
// to do so.
|
// to do so.
|
||||||
arg("--no-demangle");
|
arg("--no-demangle");
|
||||||
|
|
||||||
// The symbol visibility story is a bit in flux right now with LLD.
|
|
||||||
// It's... not entirely clear to me what's going on, but this looks to
|
|
||||||
// make everything work when `export_symbols` isn't otherwise called for
|
|
||||||
// things like executables.
|
|
||||||
//
|
|
||||||
// This is really only here to get things working. If it can be removed and
|
|
||||||
// basic tests still work, then sounds like it should be removed!
|
|
||||||
arg("--export-dynamic");
|
|
||||||
|
|
||||||
let mut pre_link_args = BTreeMap::new();
|
let mut pre_link_args = BTreeMap::new();
|
||||||
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Wasm), lld_args);
|
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Wasm), lld_args);
|
||||||
pre_link_args.insert(LinkerFlavor::Gcc, clang_args);
|
pre_link_args.insert(LinkerFlavor::Gcc, clang_args);
|
||||||
|
|
|
@ -2,6 +2,17 @@ use super::wasm32_base;
|
||||||
use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions};
|
use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions};
|
||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
|
let mut options = wasm32_base::options();
|
||||||
|
|
||||||
|
let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
|
||||||
|
|
||||||
|
// Rust really needs a way for users to specify exports and imports in
|
||||||
|
// the source code. --export-dynamic isn't the right tool for this job,
|
||||||
|
// however it does have the side effect of automatically exporting a lot
|
||||||
|
// of symbols, which approximates what people want when compiling for
|
||||||
|
// wasm32-unknown-unknown expect, so use it for now.
|
||||||
|
clang_args.push("--export-dynamic".to_string());
|
||||||
|
|
||||||
let mut post_link_args = LinkArgs::new();
|
let mut post_link_args = LinkArgs::new();
|
||||||
post_link_args.insert(
|
post_link_args.insert(
|
||||||
LinkerFlavor::Em,
|
LinkerFlavor::Em,
|
||||||
|
@ -28,7 +39,7 @@ pub fn target() -> Target {
|
||||||
panic_strategy: PanicStrategy::Unwind,
|
panic_strategy: PanicStrategy::Unwind,
|
||||||
post_link_args,
|
post_link_args,
|
||||||
os_family: Some("unix".to_string()),
|
os_family: Some("unix".to_string()),
|
||||||
..wasm32_base::options()
|
..options
|
||||||
};
|
};
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "wasm32-unknown-emscripten".to_string(),
|
llvm_target: "wasm32-unknown-emscripten".to_string(),
|
||||||
|
|
|
@ -26,11 +26,18 @@ pub fn target() -> Target {
|
||||||
// For now this target just never has an entry symbol no matter the output
|
// For now this target just never has an entry symbol no matter the output
|
||||||
// type, so unconditionally pass this.
|
// type, so unconditionally pass this.
|
||||||
clang_args.push("-Wl,--no-entry".to_string());
|
clang_args.push("-Wl,--no-entry".to_string());
|
||||||
options
|
|
||||||
.pre_link_args
|
// Rust really needs a way for users to specify exports and imports in
|
||||||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm))
|
// the source code. --export-dynamic isn't the right tool for this job,
|
||||||
.unwrap()
|
// however it does have the side effect of automatically exporting a lot
|
||||||
.push("--no-entry".to_string());
|
// of symbols, which approximates what people want when compiling for
|
||||||
|
// wasm32-unknown-unknown expect, so use it for now.
|
||||||
|
clang_args.push("-Wl,--export-dynamic".to_string());
|
||||||
|
|
||||||
|
// Add the flags to wasm-ld's args too.
|
||||||
|
let lld_args = options.pre_link_args.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm)).unwrap();
|
||||||
|
lld_args.push("--no-entry".to_string());
|
||||||
|
lld_args.push("--export-dynamic".to_string());
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "wasm32-unknown-unknown".to_string(),
|
llvm_target: "wasm32-unknown-unknown".to_string(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue