Skip to content

Commit ceeea91

Browse files
committed
[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.
1 parent de18ff3 commit ceeea91

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lld/MachO/InputFiles.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,9 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
19121912
normalSymbols.push_back(symbol);
19131913
}
19141914
}
1915+
// interface.symbols() order is non-deterministic.
1916+
llvm::sort(normalSymbols,
1917+
[](auto *l, auto *r) { return l->getName() < r->getName(); });
19151918

19161919
// TODO(compnerd) filter out symbols based on the target platform
19171920
for (const auto *symbol : normalSymbols) {

lld/test/MachO/dead-strip.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@
266266
# UNWIND-NEXT: g F __TEXT,__text _main
267267
# UNWIND-NEXT: g F __TEXT,__text __mh_execute_header
268268
# UNWIND-NEXT: *UND* dyld_stub_binder
269+
# UNWIND-NEXT: *UND* __ZTIi
269270
# UNWIND-NEXT: *UND* ___cxa_allocate_exception
271+
# UNWIND-NEXT: *UND* ___cxa_begin_catch
270272
# UNWIND-NEXT: *UND* ___cxa_end_catch
271-
# UNWIND-NEXT: *UND* __ZTIi
272273
# UNWIND-NEXT: *UND* ___cxa_throw
273274
# UNWIND-NEXT: *UND* ___gxx_personality_v0
274-
# UNWIND-NEXT: *UND* ___cxa_begin_catch
275275
# UNWIND-NOT: GCC_except_table0
276276

277277
## If a dead stripped function has a strong ref to a dylib symbol but

0 commit comments

Comments
 (0)