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
This commit is contained in:
bors 2023-09-06 20:04:03 +00:00
commit e3abbd4994
2 changed files with 50 additions and 0 deletions

View file

@ -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;