From e6dddbda35399c08c7940477c363002ab1d276da Mon Sep 17 00:00:00 2001 From: Lukasz Anforowicz Date: Tue, 8 Aug 2023 19:47:36 +0000 Subject: Preserve `___asan_globals_registered` symbol during LTO. Fixes https://github.com/rust-lang/rust/issues/113404 --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp') diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 6af5c24c458..308c935edf9 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; -- cgit 1.4.1-3-g733a5