1 // Test clang changes for NaCl Support including:
2 //    include paths, library paths, emulation, default static
3 //
4 // RUN: %clang -no-canonical-prefixes -### -o %t.o %s \
5 // RUN:     -target i686-unknown-nacl -resource-dir foo 2>&1 \
6 // RUN:   | FileCheck --check-prefix=CHECK-I686 %s
7 // CHECK-I686: {{.*}}clang{{.*}}" "-cc1"
8 // CHECK-I686-NOT: "-fno-use-init-array"
9 // CHECK-I686: "-target-cpu" "pentium4"
10 // CHECK-I686: "-resource-dir" "foo"
11 // CHECK-I686: "-internal-isystem" "foo{{/|\\\\}}include"
12 // CHECK-I686: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}i686-nacl{{/|\\\\}}usr{{/|\\\\}}include"
13 // CHECK-I686: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}include"
14 // CHECK-I686: as{{(.exe)?}}" "--32"
15 // CHECK-I686: ld{{(.exe)?}}"
16 // CHECK-I686: "--build-id"
17 // CHECK-I686: "-m" "elf_i386_nacl"
18 // CHECK-I686: "-static"
19 // CHECK-I686: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}lib32"
20 // CHECK-I686: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}i686-nacl{{/|\\\\}}usr{{/|\\\\}}lib"
21 // CHECK-I686: "-Lfoo{{/|\\\\}}lib{{/|\\\\}}i686-nacl"
22 // CHECK-I686-NOT: -lpthread
23 //
24 // RUN: %clang -no-canonical-prefixes -### -o %t.o %s \
25 // RUN:     -target x86_64-unknown-nacl -resource-dir foo 2>&1 \
26 // RUN:   | FileCheck --check-prefix=CHECK-x86_64 %s
27 // CHECK-x86_64: {{.*}}clang{{.*}}" "-cc1"
28 // CHECK-x86_64-NOT: "-fno-use-init-array"
29 // CHECK-x86_64: "-target-cpu" "x86-64"
30 // CHECK-x86_64: "-resource-dir" "foo"
31 // CHECK-x86_64: "-internal-isystem" "foo{{/|\\\\}}include"
32 // CHECK-x86_64: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}usr{{/|\\\\}}include"
33 // CHECK-x86_64: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}include"
34 // CHECK-x86_64: as{{(.exe)?}}" "--64"
35 // CHECK-x86_64: ld{{(.exe)?}}"
36 // CHECK-x86_64: "--build-id"
37 // CHECK-x86_64: "-m" "elf_x86_64_nacl"
38 // CHECK-x86_64: "-static"
39 // CHECK-x86_64: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}lib"
40 // CHECK-x86_64: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}usr{{/|\\\\}}lib"
41 // CHECK-x86_64: "-Lfoo{{/|\\\\}}lib{{/|\\\\}}x86_64-nacl"
42 // CHECK-X86_64-NOT: -lpthread
43 //
44 // RUN: %clang -no-canonical-prefixes -### -o %t.o %s \
45 // RUN:     -target armv7a-unknown-nacl-gnueabihf -resource-dir foo 2>&1 \
46 // RUN:   | FileCheck --check-prefix=CHECK-ARM %s
47 // CHECK-ARM: {{.*}}clang{{.*}}" "-cc1"
48 // CHECK-ARM-NOT: "-fno-use-init-array"
49 // CHECK-ARM: "-target-cpu" "generic"
50 // CHECK-ARM: "-target-abi" "aapcs-linux"
51 // CHECK-ARM: "-mfloat-abi" "hard"
52 // CHECK-ARM: "-resource-dir" "foo"
53 // CHECK-ARM: "-internal-isystem" "foo{{/|\\\\}}include"
54 // CHECK-ARM: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}usr{{/|\\\\}}include"
55 // CHECK-ARM: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}include"
56 // CHECK-ARM: as{{(.exe)?}}"
57 // CHECK-ARM: "-mfloat-abi=hard"
58 // CHECK-ARM: ld{{(.exe)?}}"
59 // CHECK-ARM: "--build-id"
60 // CHECK-ARM: "-m" "armelf_nacl"
61 // CHECK-ARM: "-static"
62 // CHECK-ARM: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}lib"
63 // CHECK-ARM: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}usr{{/|\\\\}}lib"
64 // CHECK-ARM: "-Lfoo{{/|\\\\}}lib{{/|\\\\}}arm-nacl"
65 // CHECK-ARM-NOT: -lpthread
66 //
67 // RUN: %clang -no-canonical-prefixes -### -o %t.o %s \
68 // RUN:     -target mipsel-unknown-nacl -resource-dir foo 2>&1 \
69 // RUN:   | FileCheck --check-prefix=CHECK-MIPS %s
70 // CHECK-MIPS: {{.*}}clang{{.*}}" "-cc1"
71 // CHECK-MIPS-NOT: "-fno-use-init-array"
72 // CHECK-MIPS: "-target-cpu" "mips32r2"
73 // CHECK-MIPS: "-target-abi" "o32"
74 // CHECK-MIPS: "-mfloat-abi" "hard"
75 // CHECK-MIPS: "-resource-dir" "foo"
76 // CHECK-MIPS: "-internal-isystem" "foo{{/|\\\\}}include"
77 // CHECK-MIPS: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}usr{{/|\\\\}}include"
78 // CHECK-MIPS: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}include"
79 // CHECK-MIPS-NOT: as{{(.exe)?}}"
80 // CHECK-MIPS: ld{{(.exe)?}}"
81 // CHECK-MIPS: "--build-id"
82 // CHECK-MIPS: "-m" "mipselelf_nacl"
83 // CHECK-MIPS: "-static"
84 // CHECK-MIPS: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}lib"
85 // CHECK-MIPS: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}usr{{/|\\\\}}lib"
86 // CHECK-MIPS: "-Lfoo{{/|\\\\}}lib{{/|\\\\}}mipsel-nacl"
87 // CHECK-MIPS: "-lpnacl_legacy"
88 // CHECK-MIPS-NOT: "-lpthread"
89 
90 // Check that even when the target arch is just "arm" (as will be the case when
91 // it is inferred from the binary name) that we get the right ABI flags
92 // RUN: %clang -no-canonical-prefixes -### -o %t.o %s 2>&1 \
93 // RUN:     -target arm-nacl \
94 // RUN:   | FileCheck --check-prefix=CHECK-ARM-NOV7 %s
95 // CHECK-ARM-NOV7: "-triple" "armv7-unknown-nacl-gnueabihf"
96 // CHECK-ARM-NOV7: "-target-abi" "aapcs-linux"
97 // CHECK-ARM-NOV7: "-mfloat-abi" "hard"
98 // CHECK-ARM-NOV7: as{{(.exe)?}}"
99 // CHECK-ARM-NOV7: "-mfloat-abi=hard"
100 
101 // Test clang c++ include dirs and link line when using clang++
102 
103 // RUN: %clangxx -no-canonical-prefixes -### -o %t.o %s \
104 // RUN:     -target armv7a-unknown-nacl-gnueabihf -resource-dir foo 2>&1 \
105 // RUN:   | FileCheck --check-prefix=CHECK-ARM-CXX %s
106 // CHECK-ARM-CXX: {{.*}}clang{{.*}}" "-cc1"
107 // CHECK-ARM-CXX: "-resource-dir" "foo"
108 // CHECK-ARM-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
109 // CHECK-ARM-CXX: "-internal-isystem" "foo{{/|\\\\}}include"
110 // CHECK-ARM-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}usr{{/|\\\\}}include"
111 // CHECK-ARM-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}arm-nacl{{/|\\\\}}include"
112 // CHECK-ARM-CXX: "-lpthread"
113 
114 // RUN: %clangxx -no-canonical-prefixes -### -o %t.o %s \
115 // RUN:     -target i686-unknown-nacl -resource-dir foo 2>&1 \
116 // RUN:   | FileCheck --check-prefix=CHECK-I686-CXX %s
117 // CHECK-I686-CXX: {{.*}}clang{{.*}}" "-cc1"
118 // CHECK-I686-CXX: "-resource-dir" "foo"
119 // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
120 // CHECK-I686-CXX: "-internal-isystem" "foo{{/|\\\\}}include"
121 // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}i686-nacl{{/|\\\\}}usr{{/|\\\\}}include"
122 // CHECK-I686-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}include"
123 // CHECK-I686-CXX: "-lpthread"
124 
125 // RUN: %clangxx -no-canonical-prefixes -### -o %t.o %s \
126 // RUN:     -target x86_64-unknown-nacl -resource-dir foo 2>&1 \
127 // RUN:   | FileCheck --check-prefix=CHECK-x86_64-CXX %s
128 // CHECK-x86_64-CXX: {{.*}}clang{{.*}}" "-cc1"
129 // CHECK-x86_64-CXX: "-resource-dir" "foo"
130 // CHECK-x86_64-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
131 // CHECK-x86_64-CXX: "-internal-isystem" "foo{{/|\\\\}}include"
132 // CHECK-x86_64-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}usr{{/|\\\\}}include"
133 // CHECK-x86_64-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}x86_64-nacl{{/|\\\\}}include"
134 // CHECK-x86_64-CXX: "-lpthread"
135 
136 // RUN: %clangxx -no-canonical-prefixes -### -o %t.o %s \
137 // RUN:     -target mipsel-unknown-nacl -resource-dir foo 2>&1 \
138 // RUN:   | FileCheck --check-prefix=CHECK-MIPS-CXX %s
139 // CHECK-MIPS-CXX: {{.*}}clang{{.*}}" "-cc1"
140 // CHECK-MIPS-CXX: "-resource-dir" "foo"
141 // CHECK-MIPS-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
142 // CHECK-MIPS-CXX: "-internal-isystem" "foo{{/|\\\\}}include"
143 // CHECK-MIPS-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}usr{{/|\\\\}}include"
144 // CHECK-MIPS-CXX: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}mipsel-nacl{{/|\\\\}}include"
145 // CHECK-MIPS-CXX: "-lnacl"
146 // CHECK-MIPS-CXX: "-lpthread"
147