Auto merge of #75956 - jonas-schievink:lto-opt-sz, r=tmiasko

Fix -Clinker-plugin-lto with opt-levels s and z

Pass s and z as `-plugin-opt=O2` to the linker. This is what `-Os` and `-Oz` correspond to, apparently.

Fixes https://github.com/rust-lang/rust/issues/75940
This commit is contained in:
bors 2020-10-12 06:10:50 +00:00
commit 62cbe81b8a
3 changed files with 15 additions and 3 deletions

View File

@ -221,10 +221,8 @@ impl<'a> GccLinker<'a> {
let opt_level = match self.sess.opts.optimize {
config::OptLevel::No => "O0",
config::OptLevel::Less => "O1",
config::OptLevel::Default => "O2",
config::OptLevel::Default | config::OptLevel::Size | config::OptLevel::SizeMin => "O2",
config::OptLevel::Aggressive => "O3",
config::OptLevel::Size => "Os",
config::OptLevel::SizeMin => "Oz",
};
self.linker_arg(&format!("-plugin-opt={}", opt_level));

View File

@ -0,0 +1,7 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=s
// build-pass
// no-prefer-dynamic
#![crate_type = "rlib"]
pub fn foo() {}

View File

@ -0,0 +1,7 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=z
// build-pass
// no-prefer-dynamic
#![crate_type = "rlib"]
pub fn foo() {}