about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2022-04-18 02:58:33 +0100
committerGary Guo <gary@garyguo.net>2022-04-18 20:50:56 +0100
commite2fdb84df7c967e840a576fab86affab1e63d9fd (patch)
tree3bbe18bf89985d60fdd6c65c2648791e61a3fd5e /compiler/rustc_codegen_ssa/src
parentc475117ffb526a7c45c3b59710bd9dcdc38982af (diff)
downloadrust-e2fdb84df7c967e840a576fab86affab1e63d9fd.tar.gz
rust-e2fdb84df7c967e840a576fab86affab1e63d9fd.zip
Conditionally export msan symbols only if they are defined
* `__msan_keep_going` is defined when `-Zsanitizer-recover=memory`.
* `__msan_track_origins` is defined when `-Zsanitizer-memory-track-origins`.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/symbol_export.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index 56159cc2e08..2fa6778cca4 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -241,10 +241,18 @@ fn exported_symbols_provider_local<'tcx>(
     }
 
     if tcx.sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::MEMORY) {
+        let mut msan_weak_symbols = Vec::new();
+
         // Similar to profiling, preserve weak msan symbol during LTO.
-        const MSAN_WEAK_SYMBOLS: [&str; 2] = ["__msan_track_origins", "__msan_keep_going"];
+        if tcx.sess.opts.debugging_opts.sanitizer_recover.contains(SanitizerSet::MEMORY) {
+            msan_weak_symbols.push("__msan_keep_going");
+        }
+
+        if tcx.sess.opts.debugging_opts.sanitizer_memory_track_origins != 0 {
+            msan_weak_symbols.push("__msan_track_origins");
+        }
 
-        symbols.extend(MSAN_WEAK_SYMBOLS.iter().map(|sym| {
+        symbols.extend(msan_weak_symbols.into_iter().map(|sym| {
             let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, sym));
             (
                 exported_symbol,