linker: Use --as-needed by default when linker supports it

This commit is contained in:
Vadim Petrochenkov 2021-03-28 00:02:23 +03:00
parent afaf33dcaf
commit 6615ee89be
21 changed files with 30 additions and 94 deletions

View file

@ -130,6 +130,7 @@ pub trait Linker {
fn group_end(&mut self);
fn linker_plugin_lto(&mut self);
fn add_eh_frame_header(&mut self) {}
fn add_as_needed(&mut self) {}
fn finalize(&mut self);
}
@ -641,6 +642,12 @@ impl<'a> Linker for GccLinker<'a> {
fn add_eh_frame_header(&mut self) {
self.linker_arg("--eh-frame-hdr");
}
fn add_as_needed(&mut self) {
if self.sess.target.linker_is_gnu {
self.linker_arg("--as-needed");
}
}
}
pub struct MsvcLinker<'a> {