1 // Test that gcc-toolchain option is working correctly
2 //
3 /// Without --rtlib=libgcc the driver may pick clang_rt.crtbegin.o if
4 /// -DCLANG_DEFAULT_RTLIB=compiler-rt.
5 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t --target=x86_64-linux-gnu \
6 // RUN:   --gcc-toolchain=%S/Inputs/ubuntu_14.04_multiarch_tree/usr -stdlib=libstdc++ --rtlib=libgcc 2>&1 | \
7 // RUN:   FileCheck %s
8 //
9 // Additionally check that the legacy spelling of the flag works.
10 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t --target=x86_64-linux-gnu \
11 // RUN:   -gcc-toolchain %S/Inputs/ubuntu_14.04_multiarch_tree/usr -stdlib=libstdc++ --rtlib=libgcc 2>&1 | \
12 // RUN:   FileCheck %s
13 //
14 // Test for header search toolchain detection.
15 // CHECK: "-internal-isystem"
16 // CHECK: "[[TOOLCHAIN:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"
17 // CHECK: "-internal-isystem"
18 // CHECK: "[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
19 // CHECK: "-internal-isystem"
20 // CHECK: "[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
21 // CHECK: "-internal-isystem" "/usr/local/include"
22 //
23 // Test for linker toolchain detection. Note that only the '-L' flags will use
24 // the same precise formatting of the path as the '-internal-system' flags
25 // above, so we just blanket wildcard match the 'crtbegin.o'.
26 // CHECK: "{{[^"]*}}ld{{(.exe)?}}"
27 // CHECK-SAME: "{{[^"]*}}/usr/lib/gcc/x86_64-linux-gnu/4.8{{/|\\\\}}crtbegin.o"
28 // CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8"
29 /// On x86_64, there is an extra usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu but we should not test it.
30 // CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.."
31 
32 /// Test we don't detect GCC installation under -B.
33 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
34 // RUN:   --target=aarch64-suse-linux --gcc-toolchain=%S/Inputs/opensuse_42.2_aarch64_tree/usr | \
35 // RUN:   FileCheck %s --check-prefix=AARCH64
36 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
37 // RUN:   --target=aarch64-suse-linux -B%S/Inputs/opensuse_42.2_aarch64_tree/usr | \
38 // RUN:   FileCheck %s --check-prefix=NO_AARCH64
39 
40 // AARCH64:        Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crt1.o"
41 // NO_AARCH64-NOT: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crt1.o"
42