Skip to content

Commit 62cbe81

Browse files
committed
Auto merge of rust-lang#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 rust-lang#75940
2 parents 63962f0 + 32cf035 commit 62cbe81

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,8 @@ impl<'a> GccLinker<'a> {
221221
let opt_level = match self.sess.opts.optimize {
222222
config::OptLevel::No => "O0",
223223
config::OptLevel::Less => "O1",
224-
config::OptLevel::Default => "O2",
224+
config::OptLevel::Default | config::OptLevel::Size | config::OptLevel::SizeMin => "O2",
225225
config::OptLevel::Aggressive => "O3",
226-
config::OptLevel::Size => "Os",
227-
config::OptLevel::SizeMin => "Oz",
228226
};
229227

230228
self.linker_arg(&format!("-plugin-opt={}", opt_level));

src/test/ui/lto-opt-level-s.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// compile-flags: -Clinker-plugin-lto -Copt-level=s
2+
// build-pass
3+
// no-prefer-dynamic
4+
5+
#![crate_type = "rlib"]
6+
7+
pub fn foo() {}

src/test/ui/lto-opt-level-z.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// compile-flags: -Clinker-plugin-lto -Copt-level=z
2+
// build-pass
3+
// no-prefer-dynamic
4+
5+
#![crate_type = "rlib"]
6+
7+
pub fn foo() {}

0 commit comments

Comments
 (0)