Skip to content

Commit

Permalink
Auto merge of #75956 - jonas-schievink:lto-opt-sz, r=tmiasko
Browse files Browse the repository at this point in the history
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 #75940
  • Loading branch information
bors committed Oct 12, 2020
2 parents 63962f0 + 32cf035 commit 62cbe81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/lto-opt-level-s.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=s
// build-pass
// no-prefer-dynamic

#![crate_type = "rlib"]

pub fn foo() {}
7 changes: 7 additions & 0 deletions src/test/ui/lto-opt-level-z.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=z
// build-pass
// no-prefer-dynamic

#![crate_type = "rlib"]

pub fn foo() {}

0 comments on commit 62cbe81

Please sign in to comment.