1 // A basic clang -cc1 command-line. WebAssembly is somewhat special in
2 // enabling -fvisibility=hidden by default.
4 // RUN: %clang -### %s --target=wasm32-unknown-unknown 2>&1 \
5 // RUN: | FileCheck -check-prefix=CC1 %s
6 // CC1: "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-fvisibility=hidden" {{.*}}
8 // Ditto, but ensure that a user -fvisibility=default disables the default
9 // -fvisibility=hidden.
11 // RUN: %clang -### %s --target=wasm32-unknown-unknown -fvisibility=default 2>&1 \
12 // RUN: | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
13 // FVISIBILITY_DEFAULT-NOT: hidden
15 // A basic C link command-line with unknown OS.
17 // RUN: %clang -### --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
18 // RUN: | FileCheck -check-prefix=LINK %s
19 // LINK: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
20 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
22 // A basic C link command-line with optimization with unknown OS.
24 // RUN: %clang -### -O2 --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
25 // RUN: | FileCheck -check-prefix=LINK_OPT %s
26 // LINK_OPT: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
27 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
29 // A basic C link command-line with known OS.
31 // RUN: %clang -### --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
32 // RUN: | FileCheck -check-prefix=LINK_KNOWN %s
33 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
34 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
36 // -shared should be passed through to `wasm-ld` and include crt1-reactor.o with a known OS.
38 // RUN: %clang -### -shared -mexec-model=reactor --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
39 // RUN: | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
40 // LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
41 // LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1-reactor.o" "--entry" "_initialize" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
43 // -shared should be passed through to `wasm-ld` and include crt1-reactor.o with an unknown OS.
45 // RUN: %clang -### -shared -mexec-model=reactor --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
46 // RUN: | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
47 // LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
48 // LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "crt1-reactor.o" "--entry" "_initialize" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
50 // A basic C link command-line with optimization with known OS.
52 // RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
53 // RUN: | FileCheck -check-prefix=LINK_OPT_KNOWN %s
54 // LINK_OPT_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
55 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
57 // A basic C compile command-line with known OS.
59 // RUN: %clang -### --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
60 // RUN: | FileCheck -check-prefix=COMPILE %s
61 // COMPILE: "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
63 // -fPIC should work on a known OS
65 // RUN: %clang -### -fPIC --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
66 // RUN: | FileCheck -check-prefix=COMPILE_KNOWN_PIC %s
67 // COMPILE_KNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
69 // -fPIC should work on an unknown OS
71 // RUN: %clang -### -fPIC --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
72 // RUN: | FileCheck -check-prefix=COMPILE_UNKNOWN_PIC %s
73 // COMPILE_UNKNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2"
75 // Thread-related command line tests.
77 // '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory
78 // RUN: %clang -### --target=wasm32-unknown-unknown \
79 // RUN: --sysroot=/foo %s -pthread 2>&1 \
80 // RUN: | FileCheck -check-prefix=PTHREAD %s
81 // PTHREAD: "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals" "-target-feature" "+sign-ext"
82 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
84 // '-pthread' not allowed with '-mno-atomics'
85 // RUN: not %clang -### --target=wasm32-unknown-unknown \
86 // RUN: --sysroot=/foo %s -pthread -mno-atomics 2>&1 \
87 // RUN: | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
88 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
90 // '-pthread' not allowed with '-mno-bulk-memory'
91 // RUN: not %clang -### --target=wasm32-unknown-unknown \
92 // RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
93 // RUN: | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
94 // PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with '-mno-bulk-memory'
96 // '-pthread' not allowed with '-mno-mutable-globals'
97 // RUN: not %clang -### --target=wasm32-unknown-unknown \
98 // RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
99 // RUN: | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
100 // PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with '-mno-mutable-globals'
102 // '-pthread' not allowed with '-mno-sign-ext'
103 // RUN: not %clang -### --target=wasm32-unknown-unknown \
104 // RUN: --sysroot=/foo %s -pthread -mno-sign-ext 2>&1 \
105 // RUN: | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
106 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext'
108 // '-mllvm -emscripten-cxx-exceptions-allowed=foo,bar' sets
109 // '-mllvm --force-attribute=foo:noinline -mllvm --force-attribute=bar:noinline'
110 // RUN: %clang -### --target=wasm32-unknown-unknown \
111 // RUN: --sysroot=/foo %s -mllvm -enable-emscripten-cxx-exceptions \
112 // RUN: -mllvm -emscripten-cxx-exceptions-allowed=foo,bar 2>&1 \
113 // RUN: | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_NOINLINE %s
114 // EMSCRIPTEN_EH_ALLOWED_NOINLINE: "-cc1" {{.*}} "-mllvm" "--force-attribute=foo:noinline" "-mllvm" "--force-attribute=bar:noinline"
116 // '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with
117 // '-mllvm -enable-emscripten-cxx-exceptions'
118 // RUN: not %clang -### --target=wasm32-unknown-unknown \
119 // RUN: --sysroot=/foo %s -mllvm -emscripten-cxx-exceptions-allowed 2>&1 \
120 // RUN: | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
121 // EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with '-mllvm -enable-emscripten-cxx-exceptions'
123 // '-fwasm-exceptions' sets +exception-handling and '-mllvm -wasm-enable-eh'
124 // RUN: %clang -### --target=wasm32-unknown-unknown \
125 // RUN: --sysroot=/foo %s -fwasm-exceptions 2>&1 \
126 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS %s
127 // WASM_EXCEPTIONS: "-cc1" {{.*}} "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh"
129 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
130 // RUN: not %clang -### --target=wasm32-unknown-unknown \
131 // RUN: --sysroot=/foo %s -fwasm-exceptions -mno-exception-handling 2>&1 \
132 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
133 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
135 // '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
136 // RUN: not %clang -### --target=wasm32-unknown-unknown \
137 // RUN: --sysroot=/foo %s -fwasm-exceptions \
138 // RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
139 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_EMSCRIPTEN_EH %s
140 // WASM_EXCEPTIONS_EMSCRIPTEN_EH: invalid argument '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
142 // '-mllvm -wasm-enable-sjlj' sets +exception-handling and
143 // '-exception-model=wasm'
144 // RUN: %clang -### --target=wasm32-unknown-unknown \
145 // RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj 2>&1 \
146 // RUN: | FileCheck -check-prefix=WASM_SJLJ %s
147 // WASM_SJLJ: "-cc1" {{.*}} "-target-feature" "+exception-handling" "-exception-model=wasm"
149 // '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
150 // RUN: not %clang -### --target=wasm32-unknown-unknown \
151 // RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj -mno-exception-handling \
153 // RUN: | FileCheck -check-prefix=WASM_SJLJ_NO_EH %s
154 // WASM_SJLJ_NO_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
156 // '-mllvm -wasm-enable-sjlj' not allowed with
157 // '-mllvm -enable-emscripten-cxx-exceptions'
158 // RUN: not %clang -### --target=wasm32-unknown-unknown \
159 // RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
160 // RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
161 // RUN: | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_EH %s
162 // WASM_SJLJ_EMSCRIPTEN_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
164 // '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
165 // RUN: not %clang -### --target=wasm32-unknown-unknown \
166 // RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
167 // RUN: -mllvm -enable-emscripten-sjlj 2>&1 \
168 // RUN: | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_SJLJ %s
169 // WASM_SJLJ_EMSCRIPTEN_SJLJ: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
171 // RUN: %clang -### %s -fsanitize=address --target=wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
172 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
173 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
175 // RUN: not %clang -### %s -fsanitize=function --target=wasm32-unknown-emscripten 2>&1 | FileCheck --check-prefix=FUNCTION %s
176 // FUNCTION: error: unsupported option '-fsanitize=function' for target 'wasm32-unknown-emscripten'
178 // Basic exec-model tests.
180 // RUN: %clang -### %s --target=wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
181 // RUN: | FileCheck -check-prefix=CHECK-COMMAND %s
182 // CHECK-COMMAND: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
183 // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
185 // RUN: %clang -### %s --target=wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
186 // RUN: | FileCheck -check-prefix=CHECK-REACTOR %s
187 // CHECK-REACTOR: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
188 // CHECK-REACTOR: wasm-ld{{.*}}" "crt1-reactor.o" "--entry" "_initialize" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
190 // -fPIC implies +mutable-globals
192 // RUN: %clang -### %s --target=wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -fPIC 2>&1 \
193 // RUN: | FileCheck -check-prefix=CHECK-PIC %s
194 // CHECK-PIC: "-cc1" {{.*}} "-target-feature" "+mutable-globals"
196 // '-mno-mutable-globals' is not allowed with '-fPIC'
197 // RUN: not %clang -### %s --target=wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
198 // RUN: | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
199 // PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with '-mno-mutable-globals'