[lld-macho][nfc] Centralize usages of ld64.lld in tests
authorVincent Lee <leevince@fb.com>
Thu, 10 Feb 2022 01:05:18 +0000 (17:05 -0800)
committerVincent Lee <leevince@fb.com>
Fri, 11 Feb 2022 01:27:07 +0000 (17:27 -0800)
We have a mix of substituted lld (`%lld`) and hard-coded lld (`ld64.lld`) commands.
When testing with different versions of LLD, this would require going into every place
where lld is hard-coded and changing that. If we centralize it, this'll only  require us
to modify it in only one place and will make it easy to run the same test suite. Plus,
this will make it be consistent with how we write other tests.

Reviewed By: #lld-macho, int3, oontvoo

Differential Revision: https://reviews.llvm.org/D119394

lld/test/MachO/adhoc-codesign.s
lld/test/MachO/invalid/stub-link.s
lld/test/MachO/lit.local.cfg
lld/test/MachO/reproduce.s
lld/test/MachO/reroot-path.s
lld/test/MachO/search-paths-darwin.test
lld/test/MachO/skip-platform-checks.s
lld/test/MachO/syslibroot.test

index 1795035..9c063c7 100644 (file)
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
 
 
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
 # RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib   -o %t/out %t/foo-arm64-sim.o
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib   -o %t/out %t/foo-arm64-sim.o
 # RUN: llvm-objdump --macho --all-headers  %t/out| FileCheck --check-prefix=NO-ADHOC %s
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle  -o %t/out %t/foo-arm64-sim.o
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle  -o %t/out %t/foo-arm64-sim.o
 # RUN: llvm-objdump --macho --all-headers  %t/out| FileCheck --check-prefix=NO-ADHOC %s
 
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib   -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib   -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle  -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle  -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
 
-# RUN: ld64.lld -lSystem -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk
+# RUN: %no-arg-lld -lSystem -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib   -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib   -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
-# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle  -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
+# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle  -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
 
 # ADHOC:          cmd LC_CODE_SIGNATURE
index ed38b5e..effdca7 100644 (file)
@@ -6,7 +6,7 @@
 # RUN: mkdir -p %t
 #
 # RUN: llvm-mc -filetype obj -triple x86_64-apple-ios %s -o %t/test.o
-# RUN: not ld64.lld -arch x86_64 -platform_version ios 14.0 15.0 -o %t/test \
+# RUN: not %no-arg-lld -arch x86_64 -platform_version ios 14.0 15.0 -o %t/test \
 # RUN:   -syslibroot %S/../Inputs/iPhoneSimulator.sdk -lSystem %t/test.o 2>&1 | FileCheck %s
 
 # CHECK-DAG: error: undefined symbol: __cache_handle_memory_pressure_event
index 984c5e5..c020223 100644 (file)
@@ -15,6 +15,8 @@ lld_watchos = ('ld64.lld -arch arm64_32 -platform_version watchos 7.0 8.0 -sysli
 config.substitutions.append(('%lld-watchos', lld_watchos + ' -fatal_warnings'))
 config.substitutions.append(('%no_fatal_warnings_lld-watchos', lld_watchos))
 
+config.substitutions.append(('%no-arg-lld', 'ld64.lld'))
+
 # Since most of our tests are written around x86_64, we give this platform the
 # shortest substitution of "%lld".
 lld = ('ld64.lld -arch x86_64 -platform_version macos 10.15 11.0 -syslibroot ' +
index 2a63dee..df438b4 100644 (file)
@@ -38,7 +38,7 @@
 # RUN: FileCheck %s --check-prefix=VERSION < repro1/version.txt
 # VERSION: LLD
 
-# RUN: cd repro1; ld64.lld @response.txt
+# RUN: cd repro1; %no-arg-lld @response.txt
 
 # RUN: mkdir -p %t.dir/build2/a/b/c
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/build2/foo.o
@@ -51,7 +51,7 @@
 # RSP2-NOT:  {{^}}repro2{{[/\\]}}
 # RSP2:      {{[/\\]}}foo.o
 
-# RUN: cd repro2; ld64.lld @response.txt
+# RUN: cd repro2; %no-arg-lld @response.txt
 
 .globl _main
 _main:
index ab3a018..b99d991 100644 (file)
 ## Test our various file-loading flags to make sure all bases are covered.
 # RUN: %lld --reproduce %t/repro1.tar -lSystem -syslibroot %t %t/foo.a %t/bar.a %t/test.o -o /dev/null -t | FileCheck %s -DDIR="%t/%:t"
 # RUN: tar xf %t/repro1.tar -C %t
-# RUN: cd %t/repro1; ld64.lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
+# RUN: cd %t/repro1; %no-arg-lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
 
 # RUN: %lld --reproduce %t/repro2.tar -lSystem -syslibroot %t -force_load %t/foo.a -force_load %t/bar.a %t/test.o -o /dev/null -t | FileCheck %s -DDIR="%t/%:t"
 # RUN: tar xf %t/repro2.tar -C %t
-# RUN: cd %t/repro2; ld64.lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
+# RUN: cd %t/repro2; %no-arg-lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
 
 # RUN: %lld --reproduce %t/repro3.tar -lSystem -syslibroot %t %t/libfoo.dylib %t/libbar.dylib %t/test.o -o /dev/null -t | FileCheck %s -DDIR="%t/%:t"
 # RUN: tar xf %t/repro3.tar -C %t
-# RUN: cd %t/repro3; ld64.lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
+# RUN: cd %t/repro3; %no-arg-lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
 
 # RUN: %lld --reproduce %t/repro4.tar -lSystem -syslibroot %t -weak_library %t/libfoo.dylib -weak_library %t/libbar.dylib %t/test.o -o /dev/null -t | FileCheck %s -DDIR="%t/%:t"
 # RUN: tar xf %t/repro4.tar -C %t
-# RUN: cd %t/repro4; ld64.lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
+# RUN: cd %t/repro4; %no-arg-lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
 
 # RUN: echo "%t/libfoo.dylib" > %t/filelist
 # RUN: echo "%t/libbar.dylib" >> %t/filelist
 # RUN: %lld --reproduce %t/repro5.tar -lSystem -syslibroot %t -filelist %t/filelist %t/test.o -o /dev/null -t | FileCheck %s -DDIR="%t/%:t"
 # RUN: tar xf %t/repro5.tar -C %t
-# RUN: cd %t/repro5; ld64.lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
+# RUN: cd %t/repro5; %no-arg-lld @response.txt | FileCheck %s -DDIR="%:t/%:t"
 
 ## The {{^}} ensures that we only match relative paths if DIR is relative.
 # CHECK: {{^}}[[DIR]]/{{(lib)?}}bar
@@ -63,7 +63,7 @@
 # RUN: FileCheck %s --check-prefix=UNDEF < %t/error
 
 # RUN: tar xf %t/repro6.tar -C %t
-# RUN: cd %t/repro6; not ld64.lld @response.txt 2> %t/error | FileCheck %s -DDIR="%:t/%:t" --check-prefix=FOO
+# RUN: cd %t/repro6; not %no-arg-lld @response.txt 2> %t/error | FileCheck %s -DDIR="%:t/%:t" --check-prefix=FOO
 # RUN: FileCheck %s --check-prefix=UNDEF < %t/error
 
 # FOO: [[DIR]]/libfoo.dylib
index 42767a3..5fa3d08 100644 (file)
@@ -3,7 +3,7 @@ REQUIRES: system-darwin
 
 RUN: mkdir -p %t1 %t2
 
-RUN: not ld64.lld -arch x86_64 -platform_version macos 10.5 11.0 -v -L%t1 -F%t2 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 %s
+RUN: not %no-arg-lld -arch x86_64 -platform_version macos 10.5 11.0 -v -L%t1 -F%t2 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 %s
 CHECK:      Library search paths:
 CHECK-NEXT: [[LDIR]]
 CHECK-NEXT: /usr/lib
@@ -12,7 +12,7 @@ CHECK-NEXT: [[FDIR]]
 CHECK-NEXT: /Library/Frameworks
 CHECK-NEXT: /System/Library/Frameworks
 
-RUN: not ld64.lld -arch x86_64 -platform_version macos 10.5 11.0 -v -L%t1 -F%t2 -Z 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 --check-prefix=CHECK_Z %s
+RUN: not %no-arg-lld -arch x86_64 -platform_version macos 10.5 11.0 -v -L%t1 -F%t2 -Z 2>&1 | FileCheck -DLDIR=%t1 -DFDIR=%t2 --check-prefix=CHECK_Z %s
 CHECK_Z:      Library search paths:
 CHECK_Z-NEXT: [[LDIR]]
 CHECK_Z-NEXT: Framework search paths:
index ce44a97..bcd82d5 100644 (file)
@@ -1,7 +1,7 @@
 # REQUIRES: x86, aarch64
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-iossimulator %s -o %t.o
 ## This should succeed even though libsystem_kernel.dylib has a mismatched platform.
-# RUN: ld64.lld -lSystem -arch x86_64 -platform_version ios-simulator 14.0 15.0 \
+# RUN: %no-arg-lld -lSystem -arch x86_64 -platform_version ios-simulator 14.0 15.0 \
 # RUN:   -syslibroot %S/Inputs/iPhoneSimulator.sdk %t.o -o %t
 # RUN: llvm-objdump --macho --bind %t | FileCheck %s
 # CHECK: __DATA_CONST __got  0x100001000 pointer  0 libSystem  dyld_stub_binder
index 55c0810..268607c 100644 (file)
@@ -1,7 +1,7 @@
 # Ensure that a nonexistent path is ignored with a syslibroot
 # Don't use %lld to not pick up the default syslibroot flag.
 
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot /var/empty 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-NONEXISTENT-SYSLIBROOT
 
@@ -9,7 +9,7 @@ CHECK-NONEXISTENT-SYSLIBROOT: Library search paths:
 CHECK-NONEXISTENT-SYSLIBROOT-NEXT: Framework search paths:
 
 RUN: mkdir -p %t/usr/lib
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-SYSLIBROOT -DROOT=%t
 
@@ -18,7 +18,7 @@ CHECK-SYSLIBROOT: Library search paths:
 CHECK-SYSLIBROOT-NEXT: [[ROOT]]/usr/lib
 
 RUN: mkdir -p %t/Library/libxml2-development
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t -L /Library/libxml2-development 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-ABSOLUTE-PATH-REROOTED -DROOT=%t
 
@@ -26,14 +26,14 @@ CHECK-ABSOLUTE-PATH-REROOTED: Library search paths:
 CHECK-ABSOLUTE-PATH-REROOTED: [[ROOT]]/Library/libxml2-development
 CHECK-ABSOLUTE-PATH-REROOTED: [[ROOT]]/usr/lib
 
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t -L %t/Library/libxml2-development 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-PATH-WITHOUT-REROOT -DPATH=%t/Library/libxml2-development
 CHECK-PATH-WITHOUT-REROOT:      Library search paths:
 CHECK-PATH-WITHOUT-REROOT-NEXT: [[PATH]]
 
 RUN: mkdir -p %t.2/usr/lib
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t -syslibroot %t.2 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-SYSLIBROOT-MATRIX -DROOT=%t
 
@@ -41,7 +41,7 @@ CHECK-SYSLIBROOT-MATRIX: Library search paths:
 CHECK-SYSLIBROOT-MATRIX: [[ROOT]]/usr/lib
 CHECK-SYSLIBROOT-MATRIX: [[ROOT]].2/usr/lib
 
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t -syslibroot %t.2 -syslibroot / 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-SYSLIBROOT-IGNORED -DROOT=%t
 
@@ -50,7 +50,7 @@ CHECK-SYSLIBROOT-IGNORED-NOT: [[ROOT]]/usr/lib
 CHECK-SYSLIBROOT-IGNORED-NOT: [[ROOT]].2/usr/lib
 
 RUN: mkdir -p %t/System/Library/Frameworks
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-SYSLIBROOT-FRAMEWORK -DROOT=%t
 
@@ -59,7 +59,7 @@ CHECK-SYSLIBROOT-FRAMEWORK: [[ROOT]]/System/Library/Frameworks
 
 RUN: mkdir -p %t/Library/Frameworks
 RUN: mkdir -p %t.2/Library/Frameworks
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null  -syslibroot %t -syslibroot %t.2 \
 RUN:     -F /Library/Frameworks 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-SYSLIBROOT-FRAMEWORK-MATRIX -DROOT=%t
@@ -68,7 +68,7 @@ CHECK-SYSLIBROOT-FRAMEWORK-MATRIX: Framework search paths:
 CHECK-SYSLIBROOT-FRAMEWORK-MATRIX: [[ROOT]]/Library/Frameworks
 CHECK-SYSLIBROOT-FRAMEWORK-MATRIX: [[ROOT]].2/Library/Frameworks
 
-RUN: ld64.lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
+RUN: %no-arg-lld -arch x86_64 -platform_version macos 10 11 -v -dylib \
 RUN:     -o /dev/null -syslibroot %t -syslibroot %t.2 -syslibroot / \
 RUN:     -F /Library/Frameworks 2>&1 \
 RUN:     | FileCheck %s -check-prefix CHECK-SYSLIBROOT-FRAMEWORK-IGNORED -DROOT=%t