Skip to content

Commit

Permalink
[lld] Support RUN_LLD_MAIN_TWICE for the ELF port
Browse files Browse the repository at this point in the history
This enables the LLD_IN_TEST=2 testing mode for
```
path/to/llvm-lit -sv --param RUN_LLD_MAIN_TWICE=1 lld/test/ELF
```

When `Fatal` is called, `RunSafely` will return false.
For the first invocation in LLD_IN_TEST=2 mode, `inTestOutputDisabled`
is true and lld will not write to stdout/stderr, making many tests fail.
(This essentially discourages `Fatal` calls in the source code.)

Add XFAIL: main-run-twice to these tests similar to
https://reviews.llvm.org/D112898 for Mach-O

```
xargs </tmp/0 sed -Ei '1s/(;|#|\/\/) REQUIRES: .*/\0\n\1 XFAIL: main-run-twice/;t;1s/^/# XFAIL: main-run-twice\n/'
```
  • Loading branch information
MaskRay committed Jan 26, 2025
1 parent c1f10ef commit 0c83491
Show file tree
Hide file tree
Showing 23 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions lld/test/ELF/archive-thin-missing-member.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice

# RUN: rm -f %t-no-syms.a
# RUN: rm -f %t-syms.a
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/arm-thumb-thunk-v6m-xo.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: arm
// XFAIL: main-run-twice
// RUN: rm -rf %t && split-file %s %t
// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6m-none-eabi %t/a.s -o %t/a.o
// RUN: ld.lld --no-rosegment --script %t/a.t %t/a.o -o %t/a
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/arm-thunk-section-too-large.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: arm
// XFAIL: main-run-twice
// RUN: llvm-mc %s -triple=armv7a-linux-gnueabihf -arm-add-build-attributes -filetype=obj -o %t.o
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/arm-thunk-toolargesection.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: arm
// XFAIL: main-run-twice
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: not ld.lld %t -o /dev/null 2>&1 | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/arm-v5-reloc-error.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: arm
// XFAIL: main-run-twice
// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: . = SIZEOF_HEADERS; \
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/bad-archive.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: x86
// XFAIL: main-run-twice

// Check bad archive error reporting with --whole-archive
// and without it.
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/fatlto/fatlto.invalid.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: not ld.lld %t -o /dev/null --fat-lto-objects 2>&1 | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid-cie-reference.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: x86
// XFAIL: main-run-twice

// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: not ld.lld %t -o /dev/null 2>&1 | FileCheck %s
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/comdat-broken.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice

# RUN: yaml2obj %s -o %t.o
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/common-symbol-alignment.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# XFAIL: main-run-twice
## If an object contains a common symbol with zero alignment,
## check we report it.
# RUN: yaml2obj --docnum=1 %s -o %t1.o
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/data-encoding.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice

# The object in the archive has invalid data encoding.
# Check we report this.
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/dynamic-section-broken.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# XFAIL: main-run-twice
## .dynamic section has invalid sh_entsize, check we report it.
# RUN: yaml2obj --docnum=1 %s -o %t.so
# RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/invalid-elf.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# XFAIL: main-run-twice
# RUN: rm -rf %t && mkdir -p %t
# RUN: echo > %t/empty.o
# RUN: llvm-ar --format=gnu cr %t/not-elf.a %t/empty.o
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/invalid-file-class.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice
# RUN: rm -rf %t && mkdir -p %t

## In this test, we check that able to report objects with
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/invalid-soname.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice
# RUN: yaml2obj %s -o %t.so
# RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/sht-group-wrong-section.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice
# RUN: yaml2obj %s -o %t.o
# RUN: not ld.lld %t.o %t.o -o /dev/null 2>&1 | FileCheck %s
# CHECK: error: {{.*}}.o: invalid section index in group: 12345
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/sht-group.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# REQUIRES: x86
# XFAIL: main-run-twice
# RUN: yaml2obj %s -o %t.o
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
# CHECK: invalid symbol index
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/symtab-sh-info.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# XFAIL: main-run-twice
## .symtab's sh_info contains zero value. First entry in a .symtab is a
## zero entry that must exist in a valid object, so sh_info can't be null.
## Check we report a proper error for that case.
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/invalid/verneed-shared.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## REQUIRES: x86
# XFAIL: main-run-twice
## Test that we can parse SHT_GNU_verneed in a shared object and report certain errors.

# RUN: echo '.globl _start; _start:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/lto/bitcode-nodatalayout.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; REQUIRES: x86
; XFAIL: main-run-twice
; RUN: llvm-as %s -o %t.o
; RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/lto/bitcode-wrapper.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; REQUIRES: x86
; XFAIL: main-run-twice

;; The LLVM bitcode format allows for an optional wrapper header. This test
;; shows that LLD can handle bitcode wrapped in this way, and also that an
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/unsupported-emachine.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# XFAIL: main-run-twice
# RUN: yaml2obj %s -o %t.o
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s

Expand Down
2 changes: 0 additions & 2 deletions lld/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@
config.environment["LLD_IN_TEST"] = "1"
else:
config.environment["LLD_IN_TEST"] = "2"
# Many ELF tests fail in this mode.
config.excludes.append("ELF")
# Some old Mach-O backend tests fail, and it's due for removal anyway.
config.excludes.append("mach-o")
# Some new Mach-O backend tests fail; give them a way to mark themselves
Expand Down

0 comments on commit 0c83491

Please sign in to comment.