Skip to content

Commit d694297

Browse files
committed
[lld-macho]Define a macro to allow specifying the slop size at build time.
We're seeing thunk size overrun in our large builds and it would be helpful to be able to increase the slop size. However, this should probably not be changed between different runs of LLD, hence making it a build option so that it's fixed per lld binary.
1 parent ad582e3 commit d694297

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lld/MachO/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
option(LLD_MACHO_SLOP_FACTOR
3+
"Specify the slop factor. For very large build, the default of 256 might be too small, which can cause thunk-range overrun. Recommend increasing this value to 1024 or higher as needed.", 256)
4+
add_definitions("-DLLD_MACHO_SLOP_FACTOR=${LLD_MACHO_SLOP_FACTOR}")
5+
16
set(LLVM_TARGET_DEFINITIONS Options.td)
27
tablegen(LLVM Options.inc -gen-opt-parser-defs)
38
add_public_tablegen_target(MachOOptionsTableGen)

lld/MachO/ConcatOutputSection.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,12 @@ void TextOutputSection::finalize() {
306306
// contains several branch instructions in succession, then the distance
307307
// from the current position to the position where the thunks are inserted
308308
// grows. So leave room for a bunch of thunks.
309-
unsigned slop = 256 * thunkSize;
309+
#ifdef LLD_MACHO_SLOP_FACTOR
310+
const unsigned kSlopFact = LLD_MACHO_SLOP_FACTOR;
311+
#else
312+
const unsigned kSlopFact = 256;
313+
#endif
314+
unsigned slop = kSlopFact * thunkSize;
310315
while (finalIdx < endIdx) {
311316
uint64_t expectedNewSize =
312317
alignToPowerOf2(addr + size, inputs[finalIdx]->align) +

0 commit comments

Comments
 (0)