]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #75956 - jonas-schievink:lto-opt-sz, r=tmiasko
authorbors <bors@rust-lang.org>
Mon, 12 Oct 2020 06:10:50 +0000 (06:10 +0000)
committerbors <bors@rust-lang.org>
Mon, 12 Oct 2020 06:10:50 +0000 (06:10 +0000)
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

compiler/rustc_codegen_ssa/src/back/linker.rs
src/test/ui/lto-opt-level-s.rs [new file with mode: 0644]
src/test/ui/lto-opt-level-z.rs [new file with mode: 0644]

index 0ddf8bd316fcd4255a6d676b74f6ff0bdac5331e..09dc51c57c22b251ff949164476112f75a2fcc46 100644 (file)
@@ -221,10 +221,8 @@ fn push_linker_plugin_lto_args(&mut self, plugin_path: Option<&OsStr>) {
         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));
diff --git a/src/test/ui/lto-opt-level-s.rs b/src/test/ui/lto-opt-level-s.rs
new file mode 100644 (file)
index 0000000..a7d9d50
--- /dev/null
@@ -0,0 +1,7 @@
+// compile-flags: -Clinker-plugin-lto -Copt-level=s
+// build-pass
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+pub fn foo() {}
diff --git a/src/test/ui/lto-opt-level-z.rs b/src/test/ui/lto-opt-level-z.rs
new file mode 100644 (file)
index 0000000..bf1f5e2
--- /dev/null
@@ -0,0 +1,7 @@
+// compile-flags: -Clinker-plugin-lto -Copt-level=z
+// build-pass
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+pub fn foo() {}