Skip to content

Commit 4bc0562

Browse files
committed
Driver tests: set --sysroot="" to support clang with DEFAULT_SYSROOT
When testing clang that has been compiled with `-DDEFAULT_SYSROOT` set to some path, some tests would fail. Override sysroot to be empty string for the tests to succeed when clang is configured with `DEFAULT_SYSROOT`. Differential Revision: https://reviews.llvm.org/D66834 Patch by Sergej Jaskiewicz <[email protected]>. llvm-svn: 373147
1 parent b1cd918 commit 4bc0562

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

clang/test/Driver/darwin-sdkroot.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// RUN: rm -rf %t.tmpdir
44
// RUN: mkdir -p %t.tmpdir
5-
// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 \
5+
// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 --sysroot="" \
66
// RUN: -c %s -### 2> %t.log
77
// RUN: FileCheck --check-prefix=CHECK-BASIC < %t.log %s
88
//
@@ -13,7 +13,7 @@
1313
// Check that we don't use SDKROOT as the default if it is not a valid path.
1414
//
1515
// RUN: rm -rf %t.nonpath
16-
// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 \
16+
// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 --sysroot="" \
1717
// RUN: -c %s -### 2> %t.log
1818
// RUN: FileCheck --check-prefix=CHECK-NONPATH < %t.log %s
1919
//
@@ -23,7 +23,7 @@
2323

2424
// Check that we don't use SDKROOT as the default if it is just "/"
2525
//
26-
// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 \
26+
// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 --sysroot="" \
2727
// RUN: -c %s -### 2> %t.log
2828
// RUN: FileCheck --check-prefix=CHECK-NONROOT < %t.log %s
2929
//
@@ -43,7 +43,7 @@
4343
//
4444
// RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
4545
// RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
46-
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin %s -### 2>&1 \
46+
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin --sysroot="" %s -### 2>&1 \
4747
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
4848
//
4949
// CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
5555
//
5656
// RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
5757
// RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
58-
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
58+
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin --sysroot="" %s -### 2>&1 \
5959
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
6060
//
6161
// CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
6666
//
6767
// RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
6868
// RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
69-
// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
69+
// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin --sysroot="" %s -### 2>&1 \
7070
// RUN: | FileCheck --check-prefix=CHECK-MACOSX %s
7171
//
7272
// CHECK-MACOSX: clang

clang/test/Driver/gcc-toolchain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
44
// RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
55
// RUN: --gcc-toolchain=%S/Inputs/ubuntu_11.04_multiarch_tree/usr \
6+
// RUN: --sysroot="" \
67
// RUN: | FileCheck %s
78
//
89
// Additionally check that the legacy spelling of the flag works.
910
// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
1011
// RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
1112
// RUN: -gcc-toolchain %S/Inputs/ubuntu_11.04_multiarch_tree/usr \
13+
// RUN: --sysroot="" \
1214
// RUN: | FileCheck %s
1315
//
1416
// Test for header search toolchain detection.

clang/test/Driver/mips-mti.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
55
// RUN: --target=mips-mti-linux-gnu \
66
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
7+
// RUN: --sysroot="" \
78
// RUN: -stdlib=libstdc++ \
89
// RUN: -EB -mhard-float -mabi=32 \
910
// RUN: | FileCheck --check-prefix=EB-HARD-O32 %s
@@ -32,6 +33,7 @@
3233
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
3334
// RUN: --target=mips-mti-linux-gnu \
3435
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
36+
// RUN: --sysroot="" \
3537
// RUN: -stdlib=libstdc++ \
3638
// RUN: -EB -mhard-float -mabi=n32 \
3739
// RUN: | FileCheck --check-prefix=EB-HARD-N32 %s
@@ -60,6 +62,7 @@
6062
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
6163
// RUN: --target=mips64-mti-linux-gnu \
6264
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
65+
// RUN: --sysroot="" \
6366
// RUN: -stdlib=libstdc++ \
6467
// RUN: -EB -mhard-float -mabi=64 \
6568
// RUN: | FileCheck --check-prefix=EB-HARD-N64 %s
@@ -88,6 +91,7 @@
8891
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
8992
// RUN: --target=mips-mti-linux-gnu \
9093
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
94+
// RUN: --sysroot="" \
9195
// RUN: -stdlib=libstdc++ \
9296
// RUN: -EL -mhard-float -mabi=32 \
9397
// RUN: | FileCheck --check-prefix=EL-HARD-O32 %s
@@ -116,6 +120,7 @@
116120
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
117121
// RUN: --target=mips-mti-linux-gnu \
118122
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
123+
// RUN: --sysroot="" \
119124
// RUN: -stdlib=libstdc++ \
120125
// RUN: -EL -mhard-float -mabi=n32 \
121126
// RUN: | FileCheck --check-prefix=EL-HARD-N32 %s
@@ -144,6 +149,7 @@
144149
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
145150
// RUN: --target=mips64-mti-linux-gnu \
146151
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
152+
// RUN: --sysroot="" \
147153
// RUN: -stdlib=libstdc++ \
148154
// RUN: -EL -mhard-float -mabi=64 \
149155
// RUN: | FileCheck --check-prefix=EL-HARD-N64 %s
@@ -172,6 +178,7 @@
172178
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
173179
// RUN: --target=mips-mti-linux-gnu \
174180
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
181+
// RUN: --sysroot="" \
175182
// RUN: -stdlib=libstdc++ \
176183
// RUN: -EB -msoft-float \
177184
// RUN: | FileCheck --check-prefix=EB-SOFT %s
@@ -200,6 +207,7 @@
200207
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
201208
// RUN: --target=mips-mti-linux-gnu \
202209
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
210+
// RUN: --sysroot="" \
203211
// RUN: -stdlib=libstdc++ \
204212
// RUN: -EL -msoft-float \
205213
// RUN: | FileCheck --check-prefix=EL-SOFT %s
@@ -228,6 +236,7 @@
228236
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
229237
// RUN: --target=mips-mti-linux-gnu \
230238
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
239+
// RUN: --sysroot="" \
231240
// RUN: -stdlib=libstdc++ \
232241
// RUN: -EB -mhard-float -muclibc \
233242
// RUN: | FileCheck --check-prefix=EB-HARD-UCLIBC %s
@@ -256,6 +265,7 @@
256265
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
257266
// RUN: --target=mips-mti-linux-gnu \
258267
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
268+
// RUN: --sysroot="" \
259269
// RUN: -stdlib=libstdc++ \
260270
// RUN: -EL -mhard-float -muclibc \
261271
// RUN: | FileCheck --check-prefix=EL-HARD-UCLIBC %s
@@ -284,6 +294,7 @@
284294
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
285295
// RUN: --target=mips-mti-linux-gnu \
286296
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
297+
// RUN: --sysroot="" \
287298
// RUN: -stdlib=libstdc++ \
288299
// RUN: -EB -mhard-float -mnan=2008 \
289300
// RUN: | FileCheck --check-prefix=EB-HARD-NAN2008 %s
@@ -312,6 +323,7 @@
312323
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
313324
// RUN: --target=mips-mti-linux-gnu \
314325
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
326+
// RUN: --sysroot="" \
315327
// RUN: -stdlib=libstdc++ \
316328
// RUN: -EL -mhard-float -mnan=2008 \
317329
// RUN: | FileCheck --check-prefix=EL-HARD-NAN2008 %s
@@ -340,6 +352,7 @@
340352
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
341353
// RUN: --target=mips-mti-linux-gnu \
342354
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
355+
// RUN: --sysroot="" \
343356
// RUN: -stdlib=libstdc++ \
344357
// RUN: -EB -mhard-float -muclibc -mnan=2008 \
345358
// RUN: | FileCheck --check-prefix=EB-HARD-UCLIBC-NAN2008 %s
@@ -368,6 +381,7 @@
368381
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
369382
// RUN: --target=mips-mti-linux-gnu \
370383
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
384+
// RUN: --sysroot="" \
371385
// RUN: -stdlib=libstdc++ \
372386
// RUN: -EL -mhard-float -muclibc -mnan=2008 \
373387
// RUN: | FileCheck --check-prefix=EL-HARD-UCLIBC-NAN2008 %s
@@ -396,6 +410,7 @@
396410
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
397411
// RUN: --target=mips-mti-linux-gnu \
398412
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
413+
// RUN: --sysroot="" \
399414
// RUN: -stdlib=libstdc++ \
400415
// RUN: -EL -msoft-float -mmicromips \
401416
// RUN: | FileCheck --check-prefix=EL-SOFT-MICRO %s
@@ -424,6 +439,7 @@
424439
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
425440
// RUN: --target=mips-mti-linux-gnu \
426441
// RUN: --gcc-toolchain=%S/Inputs/mips_mti_tree \
442+
// RUN: --sysroot="" \
427443
// RUN: -stdlib=libstdc++ \
428444
// RUN: -EL -mhard-float -mmicromips -mnan=2008 \
429445
// RUN: | FileCheck --check-prefix=EL-SOFT-MICRO-NAN2008 %s

clang/test/Driver/msp430-toolchain.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// A basic clang -cc1 command-line, and simple environment check.
22

3-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 2>&1 \
3+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" 2>&1 \
44
// RUN: | FileCheck -check-prefix=CC1 %s
55
// CC1: clang{{.*}} "-cc1" "-triple" "msp430"
66

77
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
8-
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
8+
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \
99
// RUN: | FileCheck -check-prefix=MSP430 %s
1010

1111
// MSP430: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld"
@@ -18,7 +18,7 @@
1818
// MSP430: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crtn.o"
1919

2020
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
21-
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
21+
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \
2222
// RUN: | FileCheck -check-prefix=MSP430-NO-DFT-LIB %s
2323

2424
// MSP430-NO-DFT-LIB: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld"
@@ -31,7 +31,7 @@
3131
// MSP430-NO-DFT-LIB: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crtn.o"
3232

3333
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
34-
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
34+
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \
3535
// RUN: | FileCheck -check-prefix=MSP430-NO-START %s
3636

3737
// MSP430-NO-START: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld"
@@ -40,39 +40,39 @@
4040
// MSP430-NO-START: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" "-lnosys" "--end-group"
4141

4242
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostdlib \
43-
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
43+
// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \
4444
// RUN: | FileCheck -check-prefix=MSP430-NO-STD-LIB %s
4545

4646
// MSP430-NO-STD-LIB: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld"
4747
// MSP430-NO-STD-LIB: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
4848
// MSP430-NO-STD-LIB: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430"
4949
// MSP430-NO-STD-LIB: "--start-group" "-lmul_none" "-lgcc" "--end-group"
5050

51-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f147 2>&1 \
51+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f147 --sysroot="" 2>&1 \
5252
// RUN: | FileCheck -check-prefix=MSP430-HWMult-16BIT %s
53-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f147 -mhwmult=auto 2>&1 \
53+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f147 -mhwmult=auto --sysroot="" 2>&1 \
5454
// RUN: | FileCheck -check-prefix=MSP430-HWMult-16BIT %s
55-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=16bit 2>&1 \
55+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=16bit --sysroot="" 2>&1 \
5656
// RUN: | FileCheck -check-prefix=MSP430-HWMult-16BIT %s
5757

5858
// MSP430-HWMult-16BIT: "--start-group" "-lmul_16"
5959

60-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f4783 2>&1 \
60+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f4783 --sysroot="" 2>&1 \
6161
// RUN: | FileCheck -check-prefix=MSP430-HWMult-32BIT %s
62-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f4783 -mhwmult=auto 2>&1 \
62+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f4783 -mhwmult=auto --sysroot="" 2>&1 \
6363
// RUN: | FileCheck -check-prefix=MSP430-HWMult-32BIT %s
64-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=32bit 2>&1 \
64+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=32bit --sysroot="" 2>&1 \
6565
// RUN: | FileCheck -check-prefix=MSP430-HWMult-32BIT %s
6666

6767
// MSP430-HWMult-32BIT: "--start-group" "-lmul_32"
6868

69-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series 2>&1 \
69+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
7070
// RUN: | FileCheck -check-prefix=MSP430-HWMult-F5 %s
7171
// MSP430-HWMult-F5: "--start-group" "-lmul_f5"
7272

73-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none 2>&1 \
73+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none --sysroot="" 2>&1 \
7474
// RUN: | FileCheck -check-prefix=MSP430-HWMult-NONE %s
75-
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 2>&1 \
75+
// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
7676
// RUN: | FileCheck -check-prefix=MSP430-HWMult-NONE %s
7777

7878
// MSP430-HWMult-NONE: "--start-group" "-lmul_none"

clang/unittests/Driver/ToolChainTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TEST(ToolChainTest, VFSGCCInstallation) {
6060
llvm::MemoryBuffer::getMemBuffer("\n"));
6161

6262
std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
63-
{"-fsyntax-only", "--gcc-toolchain=", "foo.cpp"}));
63+
{"-fsyntax-only", "--gcc-toolchain=", "--sysroot=", "foo.cpp"}));
6464
EXPECT_TRUE(C);
6565

6666
std::string S;

0 commit comments

Comments
 (0)