[lld] Make tests calling llvm-ar more robust

Some lit tests that call llvm-ar use the 'r' flag. If the target archive
already exists and is in a corrupt state, this can cause the test to fail. We
have added 'rm -f' calls before the llvm-ar calls to increase the
robustness of the tests.

Differential revision: https://reviews.llvm.org/D49184

llvm-svn: 338705
This commit is contained in:
Chris Jackson 2018-08-02 11:33:54 +00:00
parent a318e2c603
commit 1a721eb3a2
19 changed files with 20 additions and 1 deletions

View File

@ -63,6 +63,7 @@ __imp__unexported:
# RUN: mkdir -p %T/libs
# RUN: echo -e ".global mingwfunc\n.text\nmingwfunc:\nret\n" > %T/libs/mingwfunc.s
# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/mingwfunc.s -filetype=obj -o %T/libs/mingwfunc.o
# RUN: rm -f %T/libs/libmingwex.a
# RUN: llvm-ar rcs %T/libs/libmingwex.a %T/libs/mingwfunc.o
# RUN: echo -e ".global crtfunc\n.text\ncrtfunc:\nret\n" > %T/libs/crtfunc.s
# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/crtfunc.s -filetype=obj -o %T/libs/crt2.o

View File

@ -2,6 +2,7 @@
; RUN: llvm-as -o %t.obj %s
; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %T/lto-chkstk-foo.obj %S/Inputs/lto-chkstk-foo.s
; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %T/lto-chkstk-chkstk.obj %S/Inputs/lto-chkstk-chkstk.s
; RUN: rm -f %t.lib
; RUN: llvm-ar cru %t.lib %T/lto-chkstk-chkstk.obj
; RUN: lld-link /out:%t.exe /entry:main /subsystem:console %t.obj %T/lto-chkstk-foo.obj %t.lib

View File

@ -1,6 +1,7 @@
# REQUIRES: x86
# RUN: yaml2obj < %p/Inputs/export.yaml > %t.archive.obj
# RUN: rm -f %t.archive.lib
# RUN: llvm-ar rcs %t.archive.lib %t.archive.obj
# RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.main.obj

View File

@ -26,6 +26,7 @@
# RUN: FileCheck -check-prefix=DEMANGLE %s
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/conflict.s -o %t2.o
# RUN: rm -f %t3.a
# RUN: llvm-ar rcs %t3.a %t2.o
# RUN: not ld.lld %t1.o %t3.a -u baz -o %t2 2>&1 | FileCheck -check-prefix=ARCHIVE %s

View File

@ -13,7 +13,7 @@
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %t2.s -o %t2-ppc64le.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %t2.s -o %t2-ppc64.o
# RUN: rm -f %t2-i386.a %t2-x86_64.a %t2-ppc64.a
# RUN: rm -f %t2-i386.a %t2-x86_64.a %t2-ppc64.a %t2-ppc64le.a
# RUN: llvm-ar rc %t2-i386.a %t2-i386.o
# RUN: llvm-ar rc %t2-x86_64.a %t2-x86_64.o
# RUN: llvm-ar rc %t2-ppc64le.a %t2-ppc64le.o

View File

@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/archive.s -o %ta.o
// RUN: rm -f %t.a
// RUN: llvm-ar rc %t.a %ta.o
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %tb.o
// RUN: not ld.lld %t.a %tb.o -o /dev/null 2>&1 | FileCheck %s

View File

@ -48,6 +48,7 @@
// We used to fail to identify this incompatibility and crash trying to
// read a 64 bit file as a 32 bit one.
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/archive2.s -o %ta.o
// RUN: rm -f %t.a
// RUN: llvm-ar rc %t.a %ta.o
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %tb.o
// RUN: not ld.lld %t.a %tb.o 2>&1 -o %t | FileCheck --check-prefix=ARCHIVE %s

View File

@ -43,6 +43,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
# RUN: %p/Inputs/filename-spec.s -o %t.testdir2/filename-spec2.o
# RUN: rm -f %t.testdir1/lib1.a %t.testdir2/lib2.a
# RUN: llvm-ar rsc %t.testdir1/lib1.a %t.testdir1/filename-spec1.o
# RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o

View File

@ -1,5 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/lazy-symbols.s -o %t1
# RUN: rm -f %tar
# RUN: llvm-ar rcs %tar %t1
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t2
# RUN: ld.lld %t2 %tar --script %s -o %tout

View File

@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: rm -f %t.a
// RUN: llvm-ar rcs %t.a %t.o
// RUN: not ld.lld -o /dev/null -u _start %t.a 2>&1 | FileCheck %s

View File

@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-in-archive.s -o %t1.o
// RUN: rm -f %t.a
// RUN: llvm-ar cru %t.a %t1.o
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o
// RUN: ld.lld %t2.o %t.a -o /dev/null

View File

@ -4,6 +4,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
// RUN: %p/Inputs/tls-in-archive.s -o %t1.o
// RUN: rm -f %t.a
// RUN: llvm-ar cru %t.a %t1.o
// RUN: ld.lld %t.o %t.a -o %t

View File

@ -2,6 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.foo.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/trace-ar1.s -o %t.obj1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/trace-ar2.s -o %t.obj2.o
# RUN: rm -f %t.boo.a
# RUN: llvm-ar rcs %t.boo.a %t.obj1.o %t.obj2.o
## Check how -t works with achieves

View File

@ -8,7 +8,9 @@
# RUN: %p/Inputs/trace-symbols-foo-strong.s -o %t2
# RUN: ld.lld -shared %t1 -o %t1.so
# RUN: ld.lld -shared %t2 -o %t2.so
# RUN: rm -f %t1.a
# RUN: llvm-ar rcs %t1.a %t1
# RUN: rm -f %t2.a
# RUN: llvm-ar rcs %t2.a %t2
# RUN: ld.lld -y foo -trace-symbol common -trace-symbol=hsymbol \

View File

@ -3,6 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef.s -o %t2.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef-debug.s -o %t3.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef-bad-debug.s -o %t4.o
# RUN: rm -f %t2.a
# RUN: llvm-ar rc %t2.a %t2.o
# RUN: not ld.lld %t.o %t2.a %t3.o %t4.o -o %t.exe 2>&1 | FileCheck %s
# RUN: not ld.lld -pie %t.o %t2.a %t3.o %t4.o -o %t.exe 2>&1 | FileCheck %s

View File

@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc %p/Inputs/versiondef.s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: rm -f %t.a
// RUN: llvm-ar -r %t.a %t.o
// RUN: llvm-mc %s -o %t2.o -filetype=obj -triple=x86_64-pc-linux
// RUN: ld.lld %t2.o %t.a --shared --exclude-libs ALL -o %t.so

View File

@ -3,6 +3,7 @@
; RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o
; RUN: llc -filetype=obj %S/Inputs/archive3.ll -o %t.a3.o
; RUN: llc -filetype=obj %S/Inputs/hello.ll -o %t.hello.o
; RUN: rm -f %t.a
; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o %t.hello.o
; RUN: rm -f %t.imports
; RUN: not wasm-ld %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED %s

View File

@ -4,6 +4,7 @@
; RUN: llc -filetype=obj %S/Inputs/ret64.ll -o %t.o
; RUN: llc -filetype=obj %S/Inputs/ret32.ll -o %t2.o
; RUN: llc -filetype=obj %S/Inputs/start.ll -o %t.start.o
; RUN: rm -f %t2.a
; RUN: llvm-ar rcs %t2.a %t2.o
; RUN: wasm-ld %t.start.o --no-gc-sections %t2.a %t.o -o %t.wasm -u ret32 --undefined ret64
; RUN: obj2yaml %t.wasm | FileCheck %s

View File

@ -1,5 +1,6 @@
; RUN: llc -filetype=obj -o %t.o %s
; RUN: llc -filetype=obj %S/Inputs/hidden.ll -o %t2.o
; RUN: rm -f %t2.a
; RUN: llvm-ar rcs %t2.a %t2.o
; RUN: wasm-ld %t.o %t2.a -o %t.wasm
; RUN: obj2yaml %t.wasm | FileCheck %s