[lld] ceeea91 - [lld-macho] Stabilize symbol order from InterfaceFile
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 16:36:34 PDT 2024
Author: Fangrui Song
Date: 2024-06-28T16:36:29-07:00
New Revision: ceeea9193726ff3ceeee48e0e121ac25ac12cef0
URL: https://github.com/llvm/llvm-project/commit/ceeea9193726ff3ceeee48e0e121ac25ac12cef0
DIFF: https://github.com/llvm/llvm-project/commit/ceeea9193726ff3ceeee48e0e121ac25ac12cef0.diff
LOG: [lld-macho] Stabilize symbol order from InterfaceFile
llvm/include/llvm/TextAPI/InterfaceFile.h SymbolsSet uses a
llvm::DenseMap<SymbolsMapKey, Symbol *>, which has a non-deterministic
order. For now, stabilize the order in lld since it is much simpler
than refactoring InterfaceFile.h.
Added:
Modified:
lld/MachO/InputFiles.cpp
lld/test/MachO/dead-strip.s
Removed:
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 8d66b37534f47..0cee1a84d0b55 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -1912,6 +1912,9 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
normalSymbols.push_back(symbol);
}
}
+ // interface.symbols() order is non-deterministic.
+ llvm::sort(normalSymbols,
+ [](auto *l, auto *r) { return l->getName() < r->getName(); });
// TODO(compnerd) filter out symbols based on the target platform
for (const auto *symbol : normalSymbols) {
diff --git a/lld/test/MachO/dead-strip.s b/lld/test/MachO/dead-strip.s
index d4350154695ff..f593b69843ba6 100644
--- a/lld/test/MachO/dead-strip.s
+++ b/lld/test/MachO/dead-strip.s
@@ -266,12 +266,12 @@
# UNWIND-NEXT: g F __TEXT,__text _main
# UNWIND-NEXT: g F __TEXT,__text __mh_execute_header
# UNWIND-NEXT: *UND* dyld_stub_binder
+# UNWIND-NEXT: *UND* __ZTIi
# UNWIND-NEXT: *UND* ___cxa_allocate_exception
+# UNWIND-NEXT: *UND* ___cxa_begin_catch
# UNWIND-NEXT: *UND* ___cxa_end_catch
-# UNWIND-NEXT: *UND* __ZTIi
# UNWIND-NEXT: *UND* ___cxa_throw
# UNWIND-NEXT: *UND* ___gxx_personality_v0
-# UNWIND-NEXT: *UND* ___cxa_begin_catch
# UNWIND-NOT: GCC_except_table0
## If a dead stripped function has a strong ref to a dylib symbol but
More information about the llvm-commits
mailing list