xref: /minix3/external/bsd/llvm/dist/clang/test/Driver/freebsd.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang -no-canonical-prefixes \
2*0a6a1f1dSLionel Sambuc // RUN:   -target aarch64-pc-freebsd11 %s                              \
3*0a6a1f1dSLionel Sambuc // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
4*0a6a1f1dSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-ARM64 %s
5*0a6a1f1dSLionel Sambuc // CHECK-ARM64: "-cc1" "-triple" "aarch64-pc-freebsd11"
6*0a6a1f1dSLionel Sambuc // CHECK-ARM64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
7*0a6a1f1dSLionel Sambuc // 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*0a6a1f1dSLionel Sambuc //
9f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes \
10f4a2713aSLionel Sambuc // RUN:   -target powerpc-pc-freebsd8 %s    \
11f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
12f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-PPC %s
13*0a6a1f1dSLionel Sambuc // CHECK-PPC: "-cc1" "-triple" "powerpc-pc-freebsd8"
14f4a2713aSLionel Sambuc // CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
15f4a2713aSLionel Sambuc // 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"
16f4a2713aSLionel Sambuc //
17f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes \
18f4a2713aSLionel Sambuc // RUN:   -target powerpc64-pc-freebsd8 %s                              \
19f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
20f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-PPC64 %s
21*0a6a1f1dSLionel Sambuc // CHECK-PPC64: "-cc1" "-triple" "powerpc64-pc-freebsd8"
22f4a2713aSLionel Sambuc // CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
23f4a2713aSLionel Sambuc // 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"
24f4a2713aSLionel Sambuc //
25f4a2713aSLionel Sambuc //
26f4a2713aSLionel Sambuc // Check that -m32 properly adjusts the toolchain flags.
27f4a2713aSLionel Sambuc //
28f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
29f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
30f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-LIB32 %s
31*0a6a1f1dSLionel Sambuc // CHECK-LIB32: "-cc1" "-triple" "i386-pc-freebsd8"
32f4a2713aSLionel Sambuc // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
33f4a2713aSLionel Sambuc //
34f4a2713aSLionel Sambuc // RUN: %clang -target x86_64-pc-freebsd8 -m32 %s 2>&1 \
35f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
36f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
37f4a2713aSLionel Sambuc // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
38f4a2713aSLionel Sambuc //
39f4a2713aSLionel Sambuc // Check that the new linker flags are passed to FreeBSD
40f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
41f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
42f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS8 %s
43f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd9 -m32 %s \
44f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
45f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
46f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd10.0 -m32 %s \
47f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
48f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
49f4a2713aSLionel Sambuc // CHECK-LDFLAGS8-NOT: --hash-style=both
50f4a2713aSLionel Sambuc // CHECK-LDFLAGS8: --enable-new-dtags
51f4a2713aSLionel Sambuc // CHECK-LDFLAGS9: --hash-style=both
52f4a2713aSLionel Sambuc // CHECK-LDFLAGS9: --enable-new-dtags
53f4a2713aSLionel Sambuc //
54f4a2713aSLionel Sambuc // Check that we do not pass --hash-style=gnu and --hash-style=both to linker
55f4a2713aSLionel Sambuc // and provide correct path to the dynamic linker for MIPS platforms.
56f4a2713aSLionel Sambuc // Also verify that we tell the assembler to target the right ISA and ABI.
57f4a2713aSLionel Sambuc // RUN: %clang %s -### -o %t.o 2>&1 \
58f4a2713aSLionel Sambuc // RUN:     -target mips-unknown-freebsd10.0 \
59f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-MIPS %s
60f4a2713aSLionel Sambuc // CHECK-MIPS: "{{[^" ]*}}ld{{[^" ]*}}"
61f4a2713aSLionel Sambuc // CHECK-MIPS: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
62f4a2713aSLionel Sambuc // CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
63f4a2713aSLionel Sambuc // RUN: %clang %s -### -o %t.o 2>&1 \
64f4a2713aSLionel Sambuc // RUN:     -target mipsel-unknown-freebsd10.0 \
65f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-MIPSEL %s
66f4a2713aSLionel Sambuc // CHECK-MIPSEL: "{{[^" ]*}}ld{{[^" ]*}}"
67f4a2713aSLionel Sambuc // CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
68f4a2713aSLionel Sambuc // CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
69*0a6a1f1dSLionel Sambuc // RUN: %clang %s -### 2>&1 \
70f4a2713aSLionel Sambuc // RUN:     -target mips64-unknown-freebsd10.0 \
71f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-MIPS64 %s
72f4a2713aSLionel Sambuc // CHECK-MIPS64: "{{[^" ]*}}ld{{[^" ]*}}"
73f4a2713aSLionel Sambuc // CHECK-MIPS64: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
74f4a2713aSLionel Sambuc // CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
75*0a6a1f1dSLionel Sambuc // RUN: %clang %s -### 2>&1 \
76f4a2713aSLionel Sambuc // RUN:     -target mips64el-unknown-freebsd10.0 \
77f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL %s
78f4a2713aSLionel Sambuc // CHECK-MIPS64EL: "{{[^" ]*}}ld{{[^" ]*}}"
79f4a2713aSLionel Sambuc // CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
80f4a2713aSLionel Sambuc // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
81f4a2713aSLionel Sambuc 
82f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -static %s \
83f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
84f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
85f4a2713aSLionel Sambuc // CHECK-STATIC: crt1.o
86f4a2713aSLionel Sambuc // CHECK-STATIC: crtbeginT.o
87f4a2713aSLionel Sambuc 
88f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -shared %s \
89f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
90f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
91f4a2713aSLionel Sambuc // CHECK-SHARED: crti.o
92f4a2713aSLionel Sambuc // CHECK-SHARED: crtbeginS.o
93f4a2713aSLionel Sambuc 
94f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -pie %s \
95f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
96f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-PIE %s
97f4a2713aSLionel Sambuc // CHECK-PIE: pie
98f4a2713aSLionel Sambuc // CHECK-PIE: Scrt1.o
99f4a2713aSLionel Sambuc // CHECK-PIE: crtbeginS.o
100f4a2713aSLionel Sambuc 
101f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 %s \
102f4a2713aSLionel Sambuc // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
103f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-NORMAL %s
104f4a2713aSLionel Sambuc // CHECK-NORMAL: crt1.o
105f4a2713aSLionel Sambuc // CHECK-NORMAL: crtbegin.o
106f4a2713aSLionel Sambuc 
107*0a6a1f1dSLionel Sambuc // RUN: %clang %s -### -target arm-unknown-freebsd10.0 -no-integrated-as 2>&1 \
108f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-ARM %s
109*0a6a1f1dSLionel Sambuc // CHECK-ARM: "-cc1"{{.*}}" "-fsjlj-exceptions"
110f4a2713aSLionel Sambuc // CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-matpcs"
111*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
112f4a2713aSLionel Sambuc 
113*0a6a1f1dSLionel Sambuc // RUN: %clang %s -### -target arm-gnueabi-freebsd10.0 -no-integrated-as 2>&1 \
114f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-ARM-EABI %s
115*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABI-NOT: "-cc1"{{.*}}" "-fsjlj-exceptions"
116f4a2713aSLionel Sambuc // CHECK-ARM-EABI: as{{.*}}" "-mfpu=softvfp" "-meabi=5"
117*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
118f4a2713aSLionel Sambuc // CHECK-ARM-EABI-NOT: as{{.*}}" "-matpcs"
119f4a2713aSLionel Sambuc 
120*0a6a1f1dSLionel Sambuc // RUN: %clang %s -### -target arm-gnueabihf-freebsd10.0 -no-integrated-as 2>&1 \
121*0a6a1f1dSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-ARM-EABIHF %s
122*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABIHF-NOT: "-cc1"{{.*}}" "-fsjlj-exceptions"
123*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABIHF: as{{.*}}" "-mfpu=vfp" "-meabi=5"
124*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-mfpu=softvfp"
125*0a6a1f1dSLionel Sambuc // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-matpcs"
126*0a6a1f1dSLionel Sambuc 
127*0a6a1f1dSLionel Sambuc // RUN: %clang -target x86_64-pc-freebsd8 %s -### -flto 2>&1 \
128f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-LTO %s
129f4a2713aSLionel Sambuc // CHECK-LTO: ld{{.*}}" "-plugin{{.*}}LLVMgold.so
130*0a6a1f1dSLionel Sambuc 
131*0a6a1f1dSLionel Sambuc // RUN: %clang -target sparc-unknown-freebsd8 %s -### -fpic -no-integrated-as 2>&1 \
132*0a6a1f1dSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-SPARC-PIE %s
133*0a6a1f1dSLionel Sambuc // CHECK-SPARC-PIE: as{{.*}}" "-KPIC
134*0a6a1f1dSLionel Sambuc 
135*0a6a1f1dSLionel Sambuc // RUN: %clang -mcpu=ultrasparc -target sparc64-unknown-freebsd8 %s -### -no-integrated-as 2>&1 \
136*0a6a1f1dSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-SPARC-CPU %s
137*0a6a1f1dSLionel Sambuc // CHECK-SPARC-CPU: cc1{{.*}}" "-target-cpu" "ultrasparc"
138*0a6a1f1dSLionel Sambuc // CHECK-SPARC-CPU: as{{.*}}" "-Av9a
139