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

This commit is contained in:
Jonas Schievink 2020-08-26 22:11:53 +02:00
parent c71248b708
commit 4f5394199b
3 changed files with 13 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,6 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=s
// build-pass
#![crate_type = "rlib"]
pub fn foo() {}

View File

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