1 // RUN: %clang -no-canonical-prefixes \
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"
8 //
9 // RUN: %clang -no-canonical-prefixes \
10 // RUN:   -target powerpc-pc-freebsd8 %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-freebsd8"
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"
16 //
17 // RUN: %clang -no-canonical-prefixes \
18 // RUN:   -target powerpc64-pc-freebsd8 %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-freebsd8"
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"
24 
25 // RUN: %clang -no-canonical-prefixes \
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"
32 
33 //
34 // Check that -m32 properly adjusts the toolchain flags.
35 //
36 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -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-freebsd8"
40 // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
41 //
42 // RUN: %clang -target x86_64-pc-freebsd8 -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
46 //
47 // Check that O32 MIPS uses /usr/lib32 on a 64-bit tree.
48 //
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
52 //
53 // Check that MIPS passes the correct linker emulation.
54 //
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"
73 //
74 // Check that RISC-V passes the correct linker emulation.
75 //
76 // RUN: %clang -target riscv32-freebsd %s -### %s 2>&1 \
77 // RUN:   | FileCheck --check-prefix=CHECK-RV32I-LD %s
78 // CHECK-RV32I-LD: ld{{.*}}" {{.*}} "-m" "elf32lriscv"
79 // RUN: %clang -target riscv64-freebsd %s -### %s 2>&1 \
80 // RUN:   | FileCheck --check-prefix=CHECK-RV64I-LD %s
81 // CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv"
82 //
83 // Check that the new linker flags are passed to FreeBSD
84 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
85 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
86 // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS8 %s
87 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd9 -m32 %s \
88 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
89 // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
90 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd10.0 -m32 %s \
91 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
92 // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
93 // CHECK-LDFLAGS8-NOT: --hash-style=both
94 // CHECK-LDFLAGS8: --enable-new-dtags
95 // CHECK-LDFLAGS9: --hash-style=both
96 // CHECK-LDFLAGS9: --enable-new-dtags
97 //
98 // Check that we do not pass --hash-style=gnu and --hash-style=both to linker
99 // and provide correct path to the dynamic linker for MIPS platforms.
100 // Also verify that we tell the assembler to target the right ISA and ABI.
101 // RUN: %clang %s -### -o %t.o 2>&1 \
102 // RUN:     -target mips-unknown-freebsd10.0 \
103 // RUN:   | FileCheck --check-prefix=CHECK-MIPS %s
104 // CHECK-MIPS: "{{[^" ]*}}ld{{[^" ]*}}"
105 // CHECK-MIPS: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
106 // CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
107 // RUN: %clang %s -### -o %t.o 2>&1 \
108 // RUN:     -target mipsel-unknown-freebsd10.0 \
109 // RUN:   | FileCheck --check-prefix=CHECK-MIPSEL %s
110 // CHECK-MIPSEL: "{{[^" ]*}}ld{{[^" ]*}}"
111 // CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
112 // CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
113 // RUN: %clang %s -### 2>&1 \
114 // RUN:     -target mips64-unknown-freebsd10.0 \
115 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64 %s
116 // CHECK-MIPS64: "{{[^" ]*}}ld{{[^" ]*}}"
117 // CHECK-MIPS64: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
118 // CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
119 // RUN: %clang %s -### 2>&1 \
120 // RUN:     -target mips64el-unknown-freebsd10.0 \
121 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL %s
122 // CHECK-MIPS64EL: "{{[^" ]*}}ld{{[^" ]*}}"
123 // CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
124 // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
125 
126 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -static %s \
127 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
128 // RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
129 // CHECK-STATIC: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
130 // CHECK-STATIC: crt1.o
131 // CHECK-STATIC: crtbeginT.o
132 
133 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -shared %s \
134 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
135 // RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
136 // CHECK-SHARED: crti.o
137 // CHECK-SHARED: crtbeginS.o
138 
139 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -pie %s \
140 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
141 // RUN:   | FileCheck --check-prefix=CHECK-PIE %s
142 // CHECK-PIE: pie
143 // CHECK-PIE: Scrt1.o
144 // CHECK-PIE: crtbeginS.o
145 
146 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 %s \
147 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
148 // RUN:   | FileCheck --check-prefix=CHECK-NORMAL %s
149 // CHECK-NORMAL: crt1.o
150 // CHECK-NORMAL: crtbegin.o
151 
152 // RUN: %clang %s -### -target arm-unknown-freebsd10.0 -no-integrated-as 2>&1 \
153 // RUN:   | FileCheck --check-prefix=CHECK-ARM %s
154 // CHECK-ARM: "-cc1"{{.*}}" "-fsjlj-exceptions"
155 // CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-matpcs"
156 // CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
157 
158 // RUN: %clang %s -### -target arm-gnueabi-freebsd10.0 -no-integrated-as 2>&1 \
159 // RUN:   | FileCheck --check-prefix=CHECK-ARM-EABI %s
160 // CHECK-ARM-EABI-NOT: "-cc1"{{.*}}" "-fsjlj-exceptions"
161 // CHECK-ARM-EABI: as{{.*}}" "-mfpu=softvfp" "-meabi=5"
162 // CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
163 // CHECK-ARM-EABI-NOT: as{{.*}}" "-matpcs"
164 
165 // RUN: %clang %s -### -target arm-gnueabihf-freebsd10.0 -no-integrated-as 2>&1 \
166 // RUN:   | FileCheck --check-prefix=CHECK-ARM-EABIHF %s
167 // CHECK-ARM-EABIHF-NOT: "-cc1"{{.*}}" "-fsjlj-exceptions"
168 // CHECK-ARM-EABIHF: as{{.*}}" "-mfpu=vfp" "-meabi=5"
169 // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-mfpu=softvfp"
170 // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-matpcs"
171 
172 // RUN: %clang -target sparc-unknown-freebsd8 %s -### -fpic -no-integrated-as 2>&1 \
173 // RUN:   | FileCheck --check-prefix=CHECK-SPARC-PIE %s
174 // CHECK-SPARC-PIE: as{{.*}}" "-KPIC
175 
176 // RUN: %clang -mcpu=ultrasparc -target sparc64-unknown-freebsd8 %s -### -no-integrated-as 2>&1 \
177 // RUN:   | FileCheck --check-prefix=CHECK-SPARC-CPU %s
178 // CHECK-SPARC-CPU: cc1{{.*}}" "-target-cpu" "ultrasparc"
179 // CHECK-SPARC-CPU: as{{.*}}" "-Av9a
180 
181 // Check that -G flags are passed to the linker for mips
182 // RUN: %clang -target mips-unknown-freebsd %s -### -G0 2>&1 \
183 // RUN:   | FileCheck --check-prefix=CHECK-MIPS-G %s
184 // CHECK-MIPS-G: ld{{.*}}" "-G0"
185 
186 // Check CPU type for MIPS
187 // RUN: %clang -target mips-unknown-freebsd -### -c %s 2>&1 \
188 // RUN:   | FileCheck -check-prefix=CHECK-MIPS-CPU %s
189 // RUN: %clang -target mipsel-unknown-freebsd -### -c %s 2>&1 \
190 // RUN:   | FileCheck -check-prefix=CHECK-MIPS-CPU %s
191 // CHECK-MIPS-CPU: "-target-cpu" "mips2"
192 
193 // Check CPU type for MIPS64
194 // RUN: %clang -target mips64-unknown-freebsd -### -c %s 2>&1 \
195 // RUN:   | FileCheck -check-prefix=CHECK-MIPS64-CPU %s
196 // RUN: %clang -target mips64el-unknown-freebsd -### -c %s 2>&1 \
197 // RUN:   | FileCheck -check-prefix=CHECK-MIPS64-CPU %s
198 // CHECK-MIPS64-CPU: "-target-cpu" "mips3"
199 
200 // Check that the integrated assembler is enabled for SPARC64
201 // RUN: %clang -target sparc64-unknown-freebsd -### -c %s 2>&1 \
202 // RUN:   | FileCheck -check-prefix=CHECK-IAS %s
203 // CHECK-IAS-NOT: "-no-integrated-as"
204 
205 // RUN: %clang -target ppc64-unknown-freebsd13.0 -### -S %s 2>&1 | \
206 // RUN: FileCheck -check-prefix=PPC64-MUNWIND %s
207 // PPC64-MUNWIND: -munwind-table
208