From e9509d78bd1c790b49000bc469e8ad812ea88457 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 30 Jul 2018 19:55:08 -0500 Subject: [PATCH] Disable debug sections when optimization flags is set for LLD. --- src/librustc_codegen_llvm/back/linker.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/librustc_codegen_llvm/back/linker.rs b/src/librustc_codegen_llvm/back/linker.rs index 5f2f3733ec7f0..7253b5346b9ab 100644 --- a/src/librustc_codegen_llvm/back/linker.rs +++ b/src/librustc_codegen_llvm/back/linker.rs @@ -1006,6 +1006,18 @@ impl<'a> Linker for WasmLd<'a> { OptLevel::Size => "-O2", OptLevel::SizeMin => "-O2" }); + match self.sess.opts.optimize { + OptLevel::No => (), + OptLevel::Less | + OptLevel::Default | + OptLevel::Aggressive | + OptLevel::Size | + OptLevel::SizeMin => { + // LLD generates incorrect debugging information when + // optimization is applied: strip debug sections. + self.cmd.arg("--strip-debug"); + } + } } fn pgo_gen(&mut self) {