Tweak wasm_base target spec to indicate linker is not GNU and update linker inferring logic for wasm-ld.
This commit is contained in:
parent
625d5a693e
commit
f667aca127
3 changed files with 8 additions and 3 deletions
|
@ -1005,6 +1005,8 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||||
|| stem.ends_with("-clang")
|
|| stem.ends_with("-clang")
|
||||||
{
|
{
|
||||||
LinkerFlavor::Gcc
|
LinkerFlavor::Gcc
|
||||||
|
} else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") {
|
||||||
|
LinkerFlavor::Lld(LldFlavor::Wasm)
|
||||||
} else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") {
|
} else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") {
|
||||||
LinkerFlavor::Ld
|
LinkerFlavor::Ld
|
||||||
} else if stem == "link" || stem == "lld-link" {
|
} else if stem == "link" || stem == "lld-link" {
|
||||||
|
|
|
@ -472,7 +472,9 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
// eliminate the metadata. If we're building an executable, however,
|
// eliminate the metadata. If we're building an executable, however,
|
||||||
// --gc-sections drops the size of hello world from 1.8MB to 597K, a 67%
|
// --gc-sections drops the size of hello world from 1.8MB to 597K, a 67%
|
||||||
// reduction.
|
// reduction.
|
||||||
} else if self.sess.target.linker_is_gnu && !keep_metadata {
|
} else if (self.sess.target.linker_is_gnu || self.sess.target.is_like_wasm)
|
||||||
|
&& !keep_metadata
|
||||||
|
{
|
||||||
self.linker_arg("--gc-sections");
|
self.linker_arg("--gc-sections");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -480,13 +482,13 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
fn no_gc_sections(&mut self) {
|
fn no_gc_sections(&mut self) {
|
||||||
if self.sess.target.is_like_osx {
|
if self.sess.target.is_like_osx {
|
||||||
self.linker_arg("-no_dead_strip");
|
self.linker_arg("-no_dead_strip");
|
||||||
} else if self.sess.target.linker_is_gnu {
|
} else if self.sess.target.linker_is_gnu || self.sess.target.is_like_wasm {
|
||||||
self.linker_arg("--no-gc-sections");
|
self.linker_arg("--no-gc-sections");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn optimize(&mut self) {
|
fn optimize(&mut self) {
|
||||||
if !self.sess.target.linker_is_gnu {
|
if !self.sess.target.linker_is_gnu && !self.sess.target.is_like_wasm {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ pub fn options() -> TargetOptions {
|
||||||
// we use the LLD shipped with the Rust toolchain by default
|
// we use the LLD shipped with the Rust toolchain by default
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
lld_flavor: LldFlavor::Wasm,
|
lld_flavor: LldFlavor::Wasm,
|
||||||
|
linker_is_gnu: false,
|
||||||
|
|
||||||
// No need for indirection here, simd types can always be passed by
|
// No need for indirection here, simd types can always be passed by
|
||||||
// value as the whole module either has simd or not, which is different
|
// value as the whole module either has simd or not, which is different
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue