Skip to content

Commit

Permalink
Fix -Clinker-plugin-lto with opt-levels s and z
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Oct 11, 2020
1 parent c71248b commit 4f53941
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
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
6 changes: 6 additions & 0 deletions src/test/ui/lto-opt-level-s.rs
@@ -0,0 +1,6 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=s
// build-pass

#![crate_type = "rlib"]

pub fn foo() {}
6 changes: 6 additions & 0 deletions src/test/ui/lto-opt-level-z.rs
@@ -0,0 +1,6 @@
// compile-flags: -Clinker-plugin-lto -Copt-level=z
// build-pass

#![crate_type = "rlib"]

pub fn foo() {}

0 comments on commit 4f53941

Please sign in to comment.