Skip to content

Commit 20eb719

Browse files
committed
lld: Reduce number of references to undefined printed from 10 to 3.
As of a while ago, lld groups all undefined references to a single symbol in a single diagnostic. Back then, I made it so that we print up to 10 references to each undefined symbol. Having used this for a while, I never wished there were more references, but I sometimes found that this can print a lot of output. lld prints up to 10 diagnostics by default, and if each has 10 references (which I've seen in practice), and each undefined symbol produces 2 (possibly very long) lines of output, that's over 200 lines of error output. Let's try it with just 3 references for a while and see how that feels in practice. Differential Revision: https://reviews.llvm.org/D77017
1 parent 3ea0774 commit 20eb719

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

lld/COFF/SymbolTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void reportUndefinedSymbol(const UndefinedDiag &undefDiag) {
204204
llvm::raw_string_ostream os(out);
205205
os << "undefined symbol: " << toString(*undefDiag.sym);
206206

207-
const size_t maxUndefReferences = 10;
207+
const size_t maxUndefReferences = 3;
208208
size_t i = 0, numRefs = 0;
209209
for (const UndefinedDiag::File &ref : undefDiag.files) {
210210
std::vector<std::string> symbolLocations =

lld/ELF/Relocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef,
870870
if (msg.empty())
871871
msg = "undefined " + visibility() + "symbol: " + toString(sym);
872872

873-
const size_t maxUndefReferences = 10;
873+
const size_t maxUndefReferences = 3;
874874
size_t i = 0;
875875
for (UndefinedDiag::Loc l : undef.locs) {
876876
if (i >= maxUndefReferences)

lld/test/COFF/undefined-symbol-multi.s

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@
2222
# CHECK-NEXT: >>> referenced by {{.*}}tmp.obj:(main)
2323
# CHECK-NEXT: >>> referenced by {{.*}}tmp.obj:(main)
2424
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
25-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
26-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
27-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
28-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
29-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
30-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
31-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.obj:(bar)
32-
# CHECK-NEXT: >>> referenced 2 more times
25+
# CHECK-NEXT: >>> referenced 9 more times
3326
# CHECK-EMPTY:
3427
# CHECK-NEXT: error: undefined symbol: int __cdecl bar(void)
3528
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(main)

lld/test/ELF/undef-multi.s

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
# CHECK-NEXT: >>> {{.*}}:(.text+0x6)
1111
# CHECK-NEXT: >>> referenced by undef-multi.s
1212
# CHECK-NEXT: >>> {{.*}}:(.text+0xB)
13-
# CHECK-NEXT: >>> referenced by undef-multi.s
14-
# CHECK-NEXT: >>> {{.*}}:(.text+0x10)
15-
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.o:(.text+0x0)
13+
# CHECK-NEXT: >>> referenced 2 more times
1614

1715
# All references to a single undefined symbol count as a single error -- but
1816
# at most 10 references are printed.
@@ -36,15 +34,7 @@
3634
# LIMIT-NEXT: >>> {{.*}}:(.text+0x6)
3735
# LIMIT-NEXT: >>> referenced by undef-multi.s
3836
# LIMIT-NEXT: >>> {{.*}}:(.text+0xB)
39-
# LIMIT-NEXT: >>> referenced by undef-multi.s
40-
# LIMIT-NEXT: >>> {{.*}}:(.text+0x10)
41-
# LIMIT-NEXT: >>> referenced by {{.*}}tmp2.o:(.text+0x0)
42-
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x1)
43-
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x6)
44-
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0xB)
45-
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x10)
46-
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x15)
47-
# LIMIT-NEXT: >>> referenced 2 more times
37+
# LIMIT-NEXT: >>> referenced 9 more times
4838

4939
.file "undef-multi.s"
5040

0 commit comments

Comments
 (0)