blob: cd89c798097d32fc0ac665d69a20b48c92842423 [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 \
96// RUN: -ccc-install-dir %S/Inputs/fake_install_tree \
97// 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:[^"]+]]"
100// CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o"
101// CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0"
102//
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 \
107// RUN: -ccc-install-dir %S/Inputs/fake_install_tree \
108// 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"