blob: b2f510544f7d571cd7e3967cffd00cb1bc821e46 [file] [log] [blame]
Chandler Carruthfde8d142011-10-03 06:41:08 +00001// General tests that ld invocations on Linux targets sane. Note that we use
2// sysroot to make these tests independent of the host system.
Chandler Carruthc4cc4032011-10-01 00:37:39 +00003//
Chandler Carruthfde8d142011-10-03 06:41:08 +00004// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Chandler Carruth663abc92011-10-03 08:02:58 +00005// RUN: -ccc-host-triple i386-unknown-linux \
Chandler Carruthfde8d142011-10-03 06:41:08 +00006// RUN: --sysroot=%S/Inputs/basic_linux_tree \
Chandler Carruthc4cc4032011-10-01 00:37:39 +00007// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
Chandler Carruthfde8d142011-10-03 06:41:08 +00008// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
Chandler Carruthb6fdf8f2011-10-03 08:16:09 +00009// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o"
Chandler Carruth663abc92011-10-03 08:02:58 +000010// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
Chandler Carruth621e6a62011-10-03 08:09:02 +000011// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
Chandler Carruth663abc92011-10-03 08:02:58 +000012// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
13// CHECK-LD-32: "-L[[SYSROOT]]/lib"
14// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib"
Chandler Carruthc4cc4032011-10-01 00:37:39 +000015//
Chandler Carruthfde8d142011-10-03 06:41:08 +000016// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
17// RUN: -ccc-host-triple x86_64-unknown-linux \
18// RUN: --sysroot=%S/Inputs/basic_linux_tree \
Chandler Carruthc4cc4032011-10-01 00:37:39 +000019// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
Chandler Carruthfde8d142011-10-03 06:41:08 +000020// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
Chandler Carruthb6fdf8f2011-10-03 08:16:09 +000021// CHECK-LD-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
Chandler Carruth663abc92011-10-03 08:02:58 +000022// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
Chandler Carruth621e6a62011-10-03 08:09:02 +000023// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
Chandler Carruth663abc92011-10-03 08:02:58 +000024// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
25// CHECK-LD-64: "-L[[SYSROOT]]/lib"
26// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib"
Chandler Carruth38ec5462011-10-03 09:00:50 +000027//
28// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
29// RUN: -ccc-host-triple i386-unknown-linux -m32 \
30// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
31// RUN: | FileCheck --check-prefix=CHECK-32-TO-32 %s
32// CHECK-32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
33// CHECK-32-TO-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o"
34// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
35// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib32"
36// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib32"
37// CHECK-32-TO-32: "-L[[SYSROOT]]/lib/../lib32"
38// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32"
39// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
40// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
41// CHECK-32-TO-32: "-L[[SYSROOT]]/lib"
42// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib"
43//
44// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
45// RUN: -ccc-host-triple i386-unknown-linux -m64 \
46// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
47// RUN: | FileCheck --check-prefix=CHECK-32-TO-64 %s
48// CHECK-32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
49// CHECK-32-TO-64: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o"
50// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/64"
51// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib64"
52// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib64"
53// CHECK-32-TO-64: "-L[[SYSROOT]]/lib/../lib64"
54// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64"
55// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
56// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
57// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
58// CHECK-32-TO-64: "-L[[SYSROOT]]/lib"
59// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib"
Chandler Carruthc5306b02011-10-03 09:08:26 +000060//
61// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
62// RUN: -ccc-host-triple x86_64-unknown-linux -m64 \
63// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
64// RUN: | FileCheck --check-prefix=CHECK-64-TO-64 %s
65// CHECK-64-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
66// CHECK-64-TO-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
67// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
68// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib64"
69// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib64"
70// CHECK-64-TO-64: "-L[[SYSROOT]]/lib/../lib64"
71// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64"
72// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
73// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
74// CHECK-64-TO-64: "-L[[SYSROOT]]/lib"
75// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib"
76//
77// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
78// RUN: -ccc-host-triple x86_64-unknown-linux -m32 \
79// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
80// RUN: | FileCheck --check-prefix=CHECK-64-TO-32 %s
81// CHECK-64-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
82// CHECK-64-TO-32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o"
83// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32"
84// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib32"
85// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib32"
86// CHECK-64-TO-32: "-L[[SYSROOT]]/lib/../lib32"
87// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32"
88// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
89// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
90// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
91// CHECK-64-TO-32: "-L[[SYSROOT]]/lib"
92// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib"
Chandler Carruth5058e3a2011-10-05 01:01:57 +000093//
94// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
95// RUN: -ccc-host-triple i386-unknown-linux -m32 \
Chandler Carruth12036002011-10-05 06:38:03 +000096// RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \
Chandler Carruth5058e3a2011-10-05 01:01:57 +000097// RUN: --sysroot=%S/Inputs/basic_linux_tree \
98// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s
99// CHECK-INSTALL-DIR-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
Chandler Carruth12036002011-10-05 06:38:03 +0000100// CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o"
101// CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0"
Chandler Carruth5058e3a2011-10-05 01:01:57 +0000102//
103// Check that with 64-bit builds, we don't actually use the install directory
104// as its version of GCC is lower than our sysrooted version.
105// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
106// RUN: -ccc-host-triple x86_64-unknown-linux -m64 \
Chandler Carruth12036002011-10-05 06:38:03 +0000107// RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \
Chandler Carruth5058e3a2011-10-05 01:01:57 +0000108// RUN: --sysroot=%S/Inputs/basic_linux_tree \
109// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s
110// CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
111// CHECK-INSTALL-DIR-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
112// CHECK-INSTALL-DIR-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
Chandler Carruthdbc21442011-10-05 03:09:51 +0000113//
114// Check that we support unusual patch version formats, including missing that
115// component.
116// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
117// RUN: -ccc-host-triple i386-unknown-linux -m32 \
Chandler Carruth12036002011-10-05 06:38:03 +0000118// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing1/bin \
Chandler Carruthdbc21442011-10-05 03:09:51 +0000119// RUN: --sysroot=%S/Inputs/basic_linux_tree \
120// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s
121// CHECK-GCC-VERSION1: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
Chandler Carruth12036002011-10-05 06:38:03 +0000122// CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7/crtbegin.o"
123// CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7"
Chandler Carruthdbc21442011-10-05 03:09:51 +0000124// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
125// RUN: -ccc-host-triple i386-unknown-linux -m32 \
Chandler Carruth12036002011-10-05 06:38:03 +0000126// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing2/bin \
Chandler Carruthdbc21442011-10-05 03:09:51 +0000127// RUN: --sysroot=%S/Inputs/basic_linux_tree \
128// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s
129// CHECK-GCC-VERSION2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
Chandler Carruth12036002011-10-05 06:38:03 +0000130// CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o"
131// CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x"
Chandler Carruthdbc21442011-10-05 03:09:51 +0000132// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
133// RUN: -ccc-host-triple i386-unknown-linux -m32 \
Chandler Carruth12036002011-10-05 06:38:03 +0000134// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing3/bin \
Chandler Carruthdbc21442011-10-05 03:09:51 +0000135// RUN: --sysroot=%S/Inputs/basic_linux_tree \
136// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s
137// CHECK-GCC-VERSION3: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
Chandler Carruth12036002011-10-05 06:38:03 +0000138// CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o"
139// CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5"
Chandler Carruthcb2e00f2011-11-05 23:24:30 +0000140// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
141// RUN: -ccc-host-triple i386-unknown-linux -m32 \
142// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing4/bin \
143// RUN: --sysroot=%S/Inputs/basic_linux_tree \
144// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION4 %s
145// CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
146// CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o"
147// CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99"
Chandler Carruthd936d9d2011-11-09 03:46:20 +0000148//
149// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
150// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
151// RUN: -ccc-host-triple i386-unknown-linux \
152// RUN: --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
153// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
154// CHECK-UBUNTU-11-04: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
155// CHECK-UBUNTU-11-04: "{{.*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
156// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
157// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu"
158// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
159// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
160// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib"
161// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib"