1 // A basic clang -cc1 command-line. WebAssembly is somewhat special in 2 // enabling -fvisibility=hidden by default. 3 4 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 2>&1 \ 5 // RUN: | FileCheck -check-prefix=CC1 %s 6 // CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-fvisibility" "hidden" {{.*}} 7 8 // Ditto, but ensure that a user -fvisibility=default disables the default 9 // -fvisibility=hidden. 10 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 14 15 // A basic C link command-line with unknown OS. 16 17 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \ 18 // RUN: | FileCheck -check-prefix=LINK %s 19 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" 20 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" 21 22 // A basic C link command-line with optimization with unknown OS. 23 24 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \ 25 // RUN: | FileCheck -check-prefix=LINK_OPT %s 26 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" 27 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" 28 29 // A basic C link command-line with known OS. 30 31 // RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \ 32 // RUN: | FileCheck -check-prefix=LINK_KNOWN %s 33 // LINK_KNOWN: clang{{.*}}" "-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" 35 36 // A basic C link command-line with optimization with known OS. 37 38 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \ 39 // RUN: | FileCheck -check-prefix=LINK_OPT_KNOWN %s 40 // LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" 41 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" 42 43 // A basic C compile command-line with known OS. 44 45 // RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \ 46 // RUN: | FileCheck -check-prefix=COMPILE %s 47 // COMPILE: clang{{.*}}" "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include" 48 49 // Thread-related command line tests. 50 51 // '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory 52 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 53 // RUN: --sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \ 54 // RUN: | FileCheck -check-prefix=PTHREAD %s 55 // PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals" "-target-feature" "+sign-ext" 56 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory" 57 58 // '-pthread' not allowed with '-mno-atomics' 59 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 60 // RUN: --sysroot=/foo %s -pthread -mno-atomics 2>&1 \ 61 // RUN: | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s 62 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics' 63 64 // '-pthread' not allowed with '-mno-bulk-memory' 65 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 66 // RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \ 67 // RUN: | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s 68 // PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with '-mno-bulk-memory' 69 70 // '-pthread' not allowed with '-mno-mutable-globals' 71 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 72 // RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \ 73 // RUN: | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s 74 // PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with '-mno-mutable-globals' 75 76 // '-pthread' not allowed with '-mno-sign-ext' 77 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 78 // RUN: --sysroot=/foo %s -pthread -mno-sign-ext 2>&1 \ 79 // RUN: | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s 80 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext' 81 82 // '-fwasm-exceptions' sets +exception-handling and +reference-types 83 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 84 // RUN: --sysroot=/foo %s -fwasm-exceptions 2>&1 \ 85 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS %s 86 // WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-target-feature" "+reference-types" 87 88 // '-fwasm-exceptions' not allowed with '-mno-exception-handling' 89 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 90 // RUN: --sysroot=/foo %s -fwasm-exceptions -mno-exception-handling 2>&1 \ 91 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s 92 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling' 93 94 // '-fwasm-exceptions' not allowed with '-mno-reference-types' 95 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 96 // RUN: --sysroot=/foo %s -fwasm-exceptions -mno-reference-types 2>&1 \ 97 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_REFTYPES %s 98 // WASM_EXCEPTIONS_NO_REFTYPES: invalid argument '-fwasm-exceptions' not allowed with '-mno-reference-types' 99 100 // '-fwasm-exceptions' not allowed with 101 // '-mllvm -enable-emscripten-cxx-exceptions' 102 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \ 103 // RUN: --sysroot=/foo %s -fwasm-exceptions -mllvm -enable-emscripten-cxx-exceptions 2>&1 \ 104 // RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_EMSCRIPTEN_EH %s 105 // WASM_EXCEPTIONS_EMSCRIPTEN_EH: invalid argument '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions' 106 107 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s 108 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address" 109 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping" 110 111 // Basic exec-model tests. 112 113 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \ 114 // RUN: | FileCheck -check-prefix=CHECK-COMMAND %s 115 // CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" 116 // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" 117 118 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \ 119 // RUN: | FileCheck -check-prefix=CHECK-REACTOR %s 120 // CHECK-REACTOR: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" 121 // CHECK-REACTOR: wasm-ld{{.*}}" "crt1-reactor.o" "--entry" "_initialize" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" 122 123 // -fPIC implies +mutable-globals 124 125 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -fPIC 2>&1 \ 126 // RUN: | FileCheck -check-prefix=CHECK-PIC %s 127 // CHECK-PIC: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+mutable-globals" 128 129 // '-mno-mutable-globals' is not allowed with '-fPIC' 130 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \ 131 // RUN: | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s 132 // PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with '-mno-mutable-globals' 133