Skip to content

Commit 754b946

Browse files
authored
[lld] Support RUN_LLD_MAIN_TWICE for the ELF port (llvm#124441)
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 ``` comment="This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice." xargs </tmp/0 sed -Ei "1s/(;|#|\/\/) REQUIRES: .*/\0\n\1 "$comment"\n\1 XFAIL: main-run-twice/;t;1s/^/# "$comment"\n# XFAIL: main-run-twice\n/" ```
1 parent 1782168 commit 754b946

21 files changed

+42
-4
lines changed

lld/test/ELF/archive-thin-missing-member.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24

35
# RUN: rm -f %t-no-syms.a
46
# RUN: rm -f %t-syms.a

lld/test/ELF/arm-thumb-thunk-v6m-xo.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// REQUIRES: arm
2+
// This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
// XFAIL: main-run-twice
24
// RUN: rm -rf %t && split-file %s %t
35
// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6m-none-eabi %t/a.s -o %t/a.o
46
// RUN: ld.lld --no-rosegment --script %t/a.t %t/a.o -o %t/a

lld/test/ELF/arm-thunk-section-too-large.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// REQUIRES: arm
2+
// This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
// XFAIL: main-run-twice
24
// RUN: llvm-mc %s -triple=armv7a-linux-gnueabihf -arm-add-build-attributes -filetype=obj -o %t.o
35
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
46

lld/test/ELF/arm-thunk-toolargesection.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// REQUIRES: arm
2+
// This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
// XFAIL: main-run-twice
24
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
35
// RUN: not ld.lld %t -o /dev/null 2>&1 | FileCheck %s
46

lld/test/ELF/arm-v5-reloc-error.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// REQUIRES: arm
2+
// This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
// XFAIL: main-run-twice
24
// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabi %s -o %t
35
// RUN: echo "SECTIONS { \
46
// RUN: . = SIZEOF_HEADERS; \

lld/test/ELF/bad-archive.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// REQUIRES: x86
2+
// This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
// XFAIL: main-run-twice
24

35
// Check bad archive error reporting with --whole-archive
46
// and without it.

lld/test/ELF/fatlto/fatlto.invalid.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
35
# RUN: not ld.lld %t -o /dev/null --fat-lto-objects 2>&1 | FileCheck %s
46

lld/test/ELF/invalid-cie-reference.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// REQUIRES: x86
2+
// This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
// XFAIL: main-run-twice
24

35
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
46
// RUN: not ld.lld %t -o /dev/null 2>&1 | FileCheck %s

lld/test/ELF/invalid/comdat-broken.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24

35
# RUN: yaml2obj %s -o %t.o
46
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s

lld/test/ELF/invalid/data-encoding.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24

35
# The object in the archive has invalid data encoding.
46
# Check we report this.

lld/test/ELF/invalid/dynamic-section-broken.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
2+
# XFAIL: main-run-twice
13
## .dynamic section has invalid sh_entsize, check we report it.
24
# RUN: yaml2obj --docnum=1 %s -o %t.so
35
# RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1

lld/test/ELF/invalid/invalid-elf.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
2+
# XFAIL: main-run-twice
13
# RUN: rm -rf %t && mkdir -p %t
24
# RUN: echo > %t/empty.o
35
# RUN: llvm-ar --format=gnu cr %t/not-elf.a %t/empty.o

lld/test/ELF/invalid/invalid-file-class.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24
# RUN: rm -rf %t && mkdir -p %t
35

46
## In this test, we check that able to report objects with

lld/test/ELF/invalid/sht-group-wrong-section.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24
# RUN: yaml2obj %s -o %t.o
35
# RUN: not ld.lld %t.o %t.o -o /dev/null 2>&1 | FileCheck %s
46
# CHECK: error: {{.*}}.o: invalid section index in group: 12345

lld/test/ELF/invalid/sht-group.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24
# RUN: yaml2obj %s -o %t.o
35
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
46
# CHECK: invalid symbol index

lld/test/ELF/invalid/symtab-sh-info.s

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
2+
# XFAIL: main-run-twice
13
## .symtab's sh_info contains zero value. First entry in a .symtab is a
24
## zero entry that must exist in a valid object, so sh_info can't be null.
35
## Check we report a proper error for that case.

lld/test/ELF/invalid/verneed-shared.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## REQUIRES: x86
2+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
# XFAIL: main-run-twice
24
## Test that we can parse SHT_GNU_verneed in a shared object and report certain errors.
35

46
# RUN: echo '.globl _start; _start:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o

lld/test/ELF/lto/bitcode-nodatalayout.ll

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
; REQUIRES: x86
2+
; This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
; XFAIL: main-run-twice
24
; RUN: llvm-as %s -o %t.o
35
; RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
46

lld/test/ELF/lto/bitcode-wrapper.ll

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
; REQUIRES: x86
2+
; This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3+
; XFAIL: main-run-twice
24

35
;; The LLVM bitcode format allows for an optional wrapper header. This test
46
;; shows that LLD can handle bitcode wrapped in this way, and also that an

lld/test/ELF/unsupported-emachine.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
2+
# XFAIL: main-run-twice
13
# RUN: yaml2obj %s -o %t.o
24
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
35

lld/test/lit.cfg.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@
104104
config.environment["LLD_IN_TEST"] = "1"
105105
else:
106106
config.environment["LLD_IN_TEST"] = "2"
107-
# Many ELF tests fail in this mode.
108-
config.excludes.append("ELF")
109-
# Some old Mach-O backend tests fail, and it's due for removal anyway.
110-
config.excludes.append("mach-o")
107+
# Many wasm tests fail.
108+
config.excludes.append("wasm")
111109
# Some new Mach-O backend tests fail; give them a way to mark themselves
112110
# unsupported in this mode.
113111
config.available_features.add("main-run-twice")

0 commit comments

Comments
 (0)