about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-06 20:04:03 +0000
committerbors <bors@rust-lang.org>2023-09-06 20:04:03 +0000
commite3abbd4994f72888f9e5e44dc89a4102e48c2a54 (patch)
tree993ccaff342e46ce333fde085df5087edca6abca /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parent4e2116296cf48022e8be4caac71a7796015aa3d7 (diff)
parente6dddbda35399c08c7940477c363002ab1d276da (diff)
downloadrust-e3abbd4994f72888f9e5e44dc89a4102e48c2a54.tar.gz
rust-e3abbd4994f72888f9e5e44dc89a4102e48c2a54.zip
Auto merge of #114946 - anforowicz:generic-fix-for-asan-lto, r=tmiasko
Preserve ASAN-related symbols during LTO.

Fixes https://github.com/rust-lang/rust/issues/113404
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index 8f8f1d8c04f..4ac739326d2 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -1058,6 +1058,13 @@ extern "C" void LLVMRustPrintPasses() {
 extern "C" void LLVMRustRunRestrictionPass(LLVMModuleRef M, char **Symbols,
                                            size_t Len) {
   auto PreserveFunctions = [=](const GlobalValue &GV) {
+    // Preserve LLVM-injected, ASAN-related symbols.
+    // See also https://github.com/rust-lang/rust/issues/113404.
+    if (GV.getName() == "___asan_globals_registered") {
+      return true;
+    }
+
+    // Preserve symbols exported from Rust modules.
     for (size_t I = 0; I < Len; I++) {
       if (GV.getName() == Symbols[I]) {
         return true;