2 // RUN: --target=aarch64-pc-freebsd11 %s \
3 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
4 // RUN: | FileCheck --check-prefix=CHECK-ARM64 %s
5 // CHECK-ARM64: "-cc1" "-triple" "aarch64-pc-freebsd11"
6 // CHECK-ARM64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
7 // CHECK-ARM64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
10 // RUN: --target=powerpc-pc-freebsd %s \
11 // RUN: --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
12 // RUN: | FileCheck --check-prefix=CHECK-PPC %s
13 // CHECK-PPC: "-cc1" "-triple" "powerpc-pc-freebsd"
14 // CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
15 // CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
18 // RUN: --target=powerpc64-pc-freebsd %s \
19 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
20 // RUN: | FileCheck --check-prefix=CHECK-PPC64 %s
21 // CHECK-PPC64: "-cc1" "-triple" "powerpc64-pc-freebsd"
22 // CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
23 // CHECK-PPC64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
26 // RUN: --target=powerpc64le-unknown-freebsd13 %s \
27 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
28 // RUN: | FileCheck --check-prefix=CHECK-PPC64LE %s
29 // CHECK-PPC64LE: "-cc1" "-triple" "powerpc64le-unknown-freebsd13"
30 // CHECK-PPC64LE: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
31 // CHECK-PPC64LE: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
34 // Check that -m32 properly adjusts the toolchain flags.
36 // RUN: %clang --target=x86_64-pc-freebsd -m32 %s \
37 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
38 // RUN: | FileCheck --check-prefix=CHECK-LIB32 %s
39 // CHECK-LIB32: "-cc1" "-triple" "i386-pc-freebsd"
40 // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
42 // RUN: %clang --target=x86_64-pc-freebsd -m32 %s 2>&1 \
43 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
44 // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s
45 // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
47 // Check that O32 MIPS uses /usr/lib32 on a 64-bit tree.
49 // RUN: %clang --target=mips-freebsd12 %s \
50 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
51 // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s
53 // Check that MIPS passes the correct linker emulation.
55 // RUN: %clang --target=mips-freebsd -### %s %s 2>&1 \
56 // RUN: | FileCheck --check-prefix=CHECK-MIPS-LD %s
57 // CHECK-MIPS-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmip_fbsd"
58 // RUN: %clang --target=mipsel-freebsd -### %s %s 2>&1 \
59 // RUN: | FileCheck --check-prefix=CHECK-MIPSEL-LD %s
60 // CHECK-MIPSEL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmip_fbsd"
61 // RUN: %clang --target=mips64-freebsd -### %s %s 2>&1 \
62 // RUN: | FileCheck --check-prefix=CHECK-MIPS64-LD %s
63 // CHECK-MIPS64-LD: ld{{.*}}" {{.*}} "-m" "elf64btsmip_fbsd"
64 // RUN: %clang --target=mips64el-freebsd -### %s %s 2>&1 \
65 // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
66 // CHECK-MIPS64EL-LD: ld{{.*}}" {{.*}} "-m" "elf64ltsmip_fbsd"
67 // RUN: %clang --target=mips64-freebsd -mabi=n32 -### %s %s 2>&1 \
68 // RUN: | FileCheck --check-prefix=CHECK-MIPSN32-LD %s
69 // CHECK-MIPSN32-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmipn32_fbsd"
70 // RUN: %clang --target=mips64el-freebsd -mabi=n32 -### %s %s 2>&1 \
71 // RUN: | FileCheck --check-prefix=CHECK-MIPSN32EL-LD %s
72 // CHECK-MIPSN32EL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmipn32_fbsd"
74 // Check that RISC-V passes the correct linker emulation.
76 // RUN: %clang --target=riscv64-freebsd -### %s %s 2>&1 \
77 // RUN: | FileCheck --check-prefix=CHECK-RV64I-LD %s
78 // CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv"
80 // Check that the new linker flags are passed to FreeBSD
81 // RUN: %clang --target=x86_64-pc-freebsd10.0 -m32 %s \
82 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
83 // RUN: | FileCheck --check-prefix=CHECK-LDFLAGS_HASH %s
84 // RUN: %clang --target=x86_64-pc-freebsd -m32 %s \
85 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
86 // RUN: | FileCheck --check-prefix=CHECK-LDFLAGS_HASH %s
87 // CHECK-LDFLAGS_HASH: --hash-style=both
88 // CHECK-LDFLAGS_HASH: --enable-new-dtags
90 // Check that we do not pass --hash-style=gnu and --hash-style=both to linker
91 // and provide correct path to the dynamic linker for MIPS platforms.
92 // Also verify that we tell the assembler to target the right ISA and ABI.
93 // RUN: %clang -### %s 2>&1 \
94 // RUN: --target=mips-unknown-freebsd10.0 \
95 // RUN: | FileCheck --check-prefix=CHECK-MIPS %s
96 // CHECK-MIPS: "{{[^" ]*}}ld{{[^" ]*}}"
97 // CHECK-MIPS: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
98 // CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
99 // RUN: %clang -### %s 2>&1 \
100 // RUN: --target=mipsel-unknown-freebsd10.0 \
101 // RUN: | FileCheck --check-prefix=CHECK-MIPSEL %s
102 // CHECK-MIPSEL: "{{[^" ]*}}ld{{[^" ]*}}"
103 // CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
104 // CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
105 // RUN: %clang -### %s 2>&1 \
106 // RUN: --target=mips64-unknown-freebsd10.0 \
107 // RUN: | FileCheck --check-prefix=CHECK-MIPS64 %s
108 // CHECK-MIPS64: "{{[^" ]*}}ld{{[^" ]*}}"
109 // CHECK-MIPS64: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
110 // CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
111 // RUN: %clang -### %s 2>&1 \
112 // RUN: --target=mips64el-unknown-freebsd10.0 \
113 // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL %s
114 // CHECK-MIPS64EL: "{{[^" ]*}}ld{{[^" ]*}}"
115 // CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
116 // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
118 // RUN: %clang --target=x86_64-pc-freebsd -static %s \
119 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
120 // RUN: | FileCheck --check-prefix=CHECK-STATIC %s
121 // CHECK-STATIC: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
122 // CHECK-STATIC: crt1.o
123 // CHECK-STATIC: crtbeginT.o
125 // RUN: %clang --target=x86_64-pc-freebsd -shared %s \
126 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
127 // RUN: | FileCheck --check-prefix=CHECK-SHARED %s
128 // CHECK-SHARED: ld{{.*}}" "--eh-frame-hdr" "-shared"
129 // CHECK-SHARED: crti.o
130 // CHECK-SHARED: crtbeginS.o
132 // RUN: %clang --target=x86_64-pc-freebsd -pie %s \
133 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
134 // RUN: | FileCheck --check-prefix=CHECK-PIE %s
136 // CHECK-PIE: Scrt1.o
137 // CHECK-PIE: crtbeginS.o
139 // RUN: %clang --target=x86_64-pc-freebsd %s \
140 // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
141 // RUN: | FileCheck --check-prefix=CHECK-NORMAL %s
142 // CHECK-NORMAL: crt1.o
143 // CHECK-NORMAL: crtbegin.o
145 // RUN: %clang -### %s --target=arm-unknown-freebsd10.0 -no-integrated-as 2>&1 \
146 // RUN: | FileCheck --check-prefix=CHECK-ARM %s
147 // CHECK-ARM-NOT: "-cc1"{{.*}}" "-exception-model=sjlj"
148 // CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-meabi=5"
149 // CHECK-ARM-NOT: as{{.*}}" "-mfpu=vfp"
150 // CHECK-ARM-NOT: as{{.*}}" "-matpcs"
152 // RUN: %clang -### %s --target=arm-gnueabi-freebsd10.0 -no-integrated-as 2>&1 \
153 // RUN: | FileCheck --check-prefix=CHECK-ARM-EABI %s
154 // CHECK-ARM-EABI-NOT: "-cc1"{{.*}}" "-exception-model=sjlj"
155 // CHECK-ARM-EABI: as{{.*}}" "-mfpu=softvfp" "-meabi=5"
156 // CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
157 // CHECK-ARM-EABI-NOT: as{{.*}}" "-matpcs"
159 // RUN: %clang -### %s --target=arm-gnueabihf-freebsd10.0 -no-integrated-as 2>&1 \
160 // RUN: | FileCheck --check-prefix=CHECK-ARM-EABIHF %s
161 // CHECK-ARM-EABIHF-NOT: "-cc1"{{.*}}" "-exception-model=sjlj"
162 // CHECK-ARM-EABIHF: as{{.*}}" "-mfpu=vfp" "-meabi=5"
163 // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-mfpu=softvfp"
164 // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-matpcs"
166 // RUN: %clang --target=sparc64-unknown-freebsd -### %s -fpic -no-integrated-as 2>&1 \
167 // RUN: | FileCheck --check-prefix=CHECK-SPARC-PIC %s
168 // CHECK-SPARC-PIC: as{{.*}}" "-KPIC
170 // RUN: %clang -mcpu=ultrasparc --target=sparc64-unknown-freebsd -### %s -no-integrated-as 2>&1 \
171 // RUN: | FileCheck --check-prefix=CHECK-SPARC-CPU %s
172 // CHECK-SPARC-CPU: cc1{{.*}}" "-target-cpu" "ultrasparc"
173 // CHECK-SPARC-CPU: as{{.*}}" "-Av9a
175 // Check that -G flags are passed to the linker for mips
176 // RUN: %clang --target=mips-unknown-freebsd -### %s -G0 2>&1 \
177 // RUN: | FileCheck --check-prefix=CHECK-MIPS-G %s
178 // CHECK-MIPS-G: ld{{.*}}" "-G0"
180 // Check CPU type for MIPS
181 // RUN: %clang --target=mips-unknown-freebsd -### -c %s 2>&1 \
182 // RUN: | FileCheck -check-prefix=CHECK-MIPS-CPU %s
183 // RUN: %clang --target=mipsel-unknown-freebsd -### -c %s 2>&1 \
184 // RUN: | FileCheck -check-prefix=CHECK-MIPS-CPU %s
185 // CHECK-MIPS-CPU: "-target-cpu" "mips2"
187 // Check CPU type for MIPS64
188 // RUN: %clang --target=mips64-unknown-freebsd -### -c %s 2>&1 \
189 // RUN: | FileCheck -check-prefix=CHECK-MIPS64-CPU %s
190 // RUN: %clang --target=mips64el-unknown-freebsd -### -c %s 2>&1 \
191 // RUN: | FileCheck -check-prefix=CHECK-MIPS64-CPU %s
192 // CHECK-MIPS64-CPU: "-target-cpu" "mips3"
194 // RUN: %clang --target=ppc64-unknown-freebsd13.0 -### -S %s 2>&1 | \
195 // RUN: FileCheck -check-prefix=PPC64-MUNWIND %s
196 // PPC64-MUNWIND: "-funwind-tables=2"
198 /// -r suppresses -dynamic-linker, default -l and crt*.o like -nostdlib.
199 // RUN: %clang -### %s --target=aarch64-pc-freebsd11 -r \
200 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree 2>&1 | FileCheck %s --check-prefix=RELOCATABLE
202 // RELOCATABLE-NOT: "-dynamic-linker"
203 // RELOCATABLE-NOT: "-l
204 // RELOCATABLE-NOT: crt{{[^./\\]+}}.o
206 // Check that the -X and --no-relax flags are passed to the linker on riscv64
207 // RUN: %clang --target=riscv64-unknown-freebsd -mno-relax -### %s 2>&1 \
208 // RUN: | FileCheck -check-prefix=RISCV64-FLAGS %s
209 // RISCV64-FLAGS: "-X" "--no-relax"