Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lld/elf: Deduplicate undefined symbol diagnostics
Before: ``` ld.lld: error: undefined symbol: f() >>> referenced by test.cc:3 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-9c0808.o:(g()) ld.lld: error: undefined symbol: f() >>> referenced by test.cc:4 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-9c0808.o:(h()) ld.lld: error: undefined symbol: f() >>> referenced by test.cc:5 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-9c0808.o:(j()) ld.lld: error: undefined symbol: k() >>> referenced by test.cc:5 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-9c0808.o:(j()) ld.lld: error: undefined symbol: f() >>> referenced by test2.cc:2 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test2-07b391.o:(asdf()) clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` Now: ``` ld.lld: error: undefined symbol: f() >>> referenced by test.cc:3 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-0e07ba.o:(g()) >>> referenced by test.cc:4 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-0e07ba.o:(h()) >>> referenced by test.cc:5 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-0e07ba.o:(j()) >>> referenced by test2.cc:2 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test2-6bdb24.o:(asdf()) ld.lld: error: undefined symbol: k() >>> referenced by test.cc:5 >>> /var/folders/c5/8d7sdn1x2mg92mj0rndghhdr0000gn/T/test-0e07ba.o:(j()) clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` If there are more than 10 references to an undefined symbol, only the first 10 are printed. Fixes PR42260. Differential Revision: https://reviews.llvm.org/D63344 llvm-svn: 363962
- Loading branch information
Showing
5 changed files
with
164 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef.s -o %t2.o | ||
# RUN: not ld.lld %t.o %t2.o -o /dev/null 2>&1 | FileCheck %s | ||
|
||
# CHECK: error: undefined symbol: zed2 | ||
# CHECK-NEXT: >>> referenced by undef-multi.s | ||
# CHECK-NEXT: >>> {{.*}}:(.text+0x1) | ||
# CHECK-NEXT: >>> referenced by undef-multi.s | ||
# CHECK-NEXT: >>> {{.*}}:(.text+0x6) | ||
# CHECK-NEXT: >>> referenced by undef-multi.s | ||
# CHECK-NEXT: >>> {{.*}}:(.text+0xB) | ||
# CHECK-NEXT: >>> referenced by undef-multi.s | ||
# CHECK-NEXT: >>> {{.*}}:(.text+0x10) | ||
# CHECK-NEXT: >>> referenced by {{.*}}tmp2.o:(.text+0x0) | ||
|
||
# All references to a single undefined symbol count as a single error -- but | ||
# at most 10 references are printed. | ||
# RUN: echo ".globl _bar" > %t.moreref.s | ||
# RUN: echo "_bar:" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: echo " call zed2" >> %t.moreref.s | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.moreref.s -o %t3.o | ||
# RUN: not ld.lld %t.o %t2.o %t3.o -o /dev/null -error-limit=2 2>&1 | \ | ||
# RUN: FileCheck --check-prefix=LIMIT %s | ||
|
||
# LIMIT: error: undefined symbol: zed2 | ||
# LIMIT-NEXT: >>> referenced by undef-multi.s | ||
# LIMIT-NEXT: >>> {{.*}}:(.text+0x1) | ||
# LIMIT-NEXT: >>> referenced by undef-multi.s | ||
# LIMIT-NEXT: >>> {{.*}}:(.text+0x6) | ||
# LIMIT-NEXT: >>> referenced by undef-multi.s | ||
# LIMIT-NEXT: >>> {{.*}}:(.text+0xB) | ||
# LIMIT-NEXT: >>> referenced by undef-multi.s | ||
# LIMIT-NEXT: >>> {{.*}}:(.text+0x10) | ||
# LIMIT-NEXT: >>> referenced by {{.*}}tmp2.o:(.text+0x0) | ||
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x1) | ||
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x6) | ||
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0xB) | ||
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x10) | ||
# LIMIT-NEXT: >>> referenced by {{.*}}tmp3.o:(.text+0x15) | ||
# LIMIT-NEXT: >>> referenced 2 more times | ||
|
||
.file "undef-multi.s" | ||
|
||
.globl _start | ||
_start: | ||
call zed2 | ||
|
||
.globl _f | ||
_f: | ||
call zed2 | ||
|
||
.globl _g | ||
_g: | ||
call zed2 | ||
|
||
.globl _h | ||
_h: | ||
call zed2 |