2016-01-07 09:00:21 +08:00
|
|
|
// A basic clang -cc1 command-line. WebAssembly is somewhat special in
|
2018-02-01 02:55:22 +08:00
|
|
|
// enabling -fvisibility=hidden by default.
|
2016-01-07 08:32:04 +08:00
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=CC1 %s
|
2018-02-01 02:55:22 +08:00
|
|
|
// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-fvisibility" "hidden" {{.*}}
|
2016-01-07 08:32:04 +08:00
|
|
|
|
2016-01-07 09:15:05 +08:00
|
|
|
// Ditto, but ensure that a user -fvisibility=default disables the default
|
2016-01-11 19:49:44 +08:00
|
|
|
// -fvisibility=hidden.
|
2016-01-07 09:15:05 +08:00
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
|
2016-01-07 09:15:05 +08:00
|
|
|
// FVISIBILITY_DEFAULT-NOT: hidden
|
|
|
|
|
2019-01-15 14:58:16 +08:00
|
|
|
// A basic C link command-line with unknown OS.
|
2016-01-07 08:32:04 +08:00
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=LINK %s
|
2016-01-07 08:32:04 +08:00
|
|
|
// LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
|
2018-08-08 02:55:41 +08:00
|
|
|
// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
|
2016-01-07 08:32:04 +08:00
|
|
|
|
2019-01-15 14:58:16 +08:00
|
|
|
// A basic C link command-line with optimization with unknown OS.
|
2016-01-07 08:32:04 +08:00
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=LINK_OPT %s
|
2016-01-07 08:32:04 +08:00
|
|
|
// LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
|
2018-08-08 02:55:41 +08:00
|
|
|
// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
|
2019-01-15 14:58:16 +08:00
|
|
|
|
|
|
|
// A basic C link command-line with known OS.
|
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=LINK_KNOWN %s
|
2019-01-15 14:58:16 +08:00
|
|
|
// LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
|
2019-05-01 07:06:07 +08:00
|
|
|
// LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
|
2019-01-15 14:58:16 +08:00
|
|
|
|
|
|
|
// A basic C link command-line with optimization with known OS.
|
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=LINK_OPT_KNOWN %s
|
2019-01-15 14:58:16 +08:00
|
|
|
// LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
|
2019-05-01 07:06:07 +08:00
|
|
|
// LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
|
2019-01-15 14:58:16 +08:00
|
|
|
|
|
|
|
// A basic C compile command-line with known OS.
|
|
|
|
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=COMPILE %s
|
2019-05-01 07:06:07 +08:00
|
|
|
// COMPILE: clang{{.*}}" "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
|
2019-02-12 06:47:50 +08:00
|
|
|
|
|
|
|
// Thread-related command line tests.
|
|
|
|
|
2019-10-18 12:34:26 +08:00
|
|
|
// '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=PTHREAD %s
|
2019-10-18 12:34:26 +08:00
|
|
|
// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals" "-target-feature" "+sign-ext"
|
2019-03-23 06:25:37 +08:00
|
|
|
// PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
|
[WebAssembly] Remove uses of ThreadModel
Summary:
In the clang UI, replaces -mthread-model posix with -matomics as the
source of truth on threading. In the backend, replaces
-thread-model=posix with the atomics target feature, which is now
collected on the WebAssemblyTargetMachine along with all other used
features. These collected features will also be used to emit the
target features section in the future.
The default configuration for the backend is thread-model=posix and no
atomics, which was previously an invalid configuration. This change
makes the default valid because the thread model is ignored.
A side effect of this change is that objects are never emitted with
passive segments. It will instead be up to the linker to decide
whether sections should be active or passive based on whether atomics
are used in the final link.
Reviewers: aheejin, sbc100, dschuff
Subscribers: mehdi_amini, jgravelle-google, hiraditya, sunfish, steven_wu, dexonsmith, rupprecht, jfb, jdoerfert, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D58742
llvm-svn: 355112
2019-03-01 02:39:08 +08:00
|
|
|
|
|
|
|
// '-pthread' not allowed with '-mno-atomics'
|
2019-06-11 00:18:04 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -pthread -mno-atomics 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
|
[WebAssembly] Remove uses of ThreadModel
Summary:
In the clang UI, replaces -mthread-model posix with -matomics as the
source of truth on threading. In the backend, replaces
-thread-model=posix with the atomics target feature, which is now
collected on the WebAssemblyTargetMachine along with all other used
features. These collected features will also be used to emit the
target features section in the future.
The default configuration for the backend is thread-model=posix and no
atomics, which was previously an invalid configuration. This change
makes the default valid because the thread model is ignored.
A side effect of this change is that objects are never emitted with
passive segments. It will instead be up to the linker to decide
whether sections should be active or passive based on whether atomics
are used in the final link.
Reviewers: aheejin, sbc100, dschuff
Subscribers: mehdi_amini, jgravelle-google, hiraditya, sunfish, steven_wu, dexonsmith, rupprecht, jfb, jdoerfert, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D58742
llvm-svn: 355112
2019-03-01 02:39:08 +08:00
|
|
|
// PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
|
[WebAssembly] Implement Address Sanitizer for Emscripten
Summary:
This diff enables address sanitizer on Emscripten.
On Emscripten, real memory starts at the value passed to --global-base.
All memory before this is used as shadow memory, and thus the shadow mapping
function is simply dividing by 8.
Reviewers: tlively, aheejin, sbc100
Reviewed By: sbc100
Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D63742
llvm-svn: 364468
2019-06-27 04:16:14 +08:00
|
|
|
|
2019-07-13 02:23:13 +08:00
|
|
|
// '-pthread' not allowed with '-mno-bulk-memory'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
|
|
|
|
// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with '-mno-bulk-memory'
|
|
|
|
|
|
|
|
// '-pthread' not allowed with '-mno-mutable-globals'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
|
|
|
|
// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with '-mno-mutable-globals'
|
|
|
|
|
2019-10-18 12:34:26 +08:00
|
|
|
// '-pthread' not allowed with '-mno-sign-ext'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -pthread -mno-sign-ext 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
|
|
|
|
// PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext'
|
|
|
|
|
2021-03-24 21:06:58 +08:00
|
|
|
// '-mllvm -emscripten-cxx-exceptions-allowed=foo,bar' sets
|
|
|
|
// '-mllvm --force-attribute=foo:noinline -mllvm --force-attribute=bar:noinline'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -mllvm -enable-emscripten-cxx-exceptions \
|
|
|
|
// RUN: -mllvm -emscripten-cxx-exceptions-allowed=foo,bar 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_NOINLINE %s
|
|
|
|
// EMSCRIPTEN_EH_ALLOWED_NOINLINE: clang{{.*}}" "-cc1" {{.*}} "-mllvm" "--force-attribute=foo:noinline" "-mllvm" "--force-attribute=bar:noinline"
|
|
|
|
|
|
|
|
// '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with
|
|
|
|
// '-mllvm -enable-emscripten-cxx-exceptions'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -mllvm -emscripten-cxx-exceptions-allowed 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
|
|
|
|
// EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
|
|
|
|
2021-08-23 18:55:55 +08:00
|
|
|
// '-fwasm-exceptions' sets +exception-handling and '-mllvm -wasm-enable-eh'
|
2019-09-12 12:01:37 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -fwasm-exceptions 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS %s
|
2021-08-23 18:55:55 +08:00
|
|
|
// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh"
|
2019-09-12 12:01:37 +08:00
|
|
|
|
|
|
|
// '-fwasm-exceptions' not allowed with '-mno-exception-handling'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-exception-handling 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
|
|
|
|
// WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
|
|
|
|
|
2021-08-23 18:55:55 +08:00
|
|
|
// '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
2019-09-12 12:01:37 +08:00
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
2021-08-23 18:55:55 +08:00
|
|
|
// RUN: --sysroot=/foo %s -fwasm-exceptions \
|
|
|
|
// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
|
2019-09-12 12:01:37 +08:00
|
|
|
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_EMSCRIPTEN_EH %s
|
|
|
|
// WASM_EXCEPTIONS_EMSCRIPTEN_EH: invalid argument '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
|
|
|
|
2021-08-23 18:55:55 +08:00
|
|
|
// '-mllvm -wasm-enable-sjlj' sets +exception-handling and
|
|
|
|
// '-exception-model=wasm'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=WASM_SJLJ %s
|
|
|
|
// WASM_SJLJ: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-exception-model=wasm"
|
|
|
|
|
|
|
|
// '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj -mno-exception-handling \
|
|
|
|
// RUN: 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=WASM_SJLJ_NO_EH %s
|
|
|
|
// WASM_SJLJ_NO_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
|
|
|
|
|
|
|
|
// '-mllvm -wasm-enable-sjlj' not allowed with
|
|
|
|
// '-mllvm -enable-emscripten-cxx-exceptions'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
|
|
|
|
// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_EH %s
|
|
|
|
// WASM_SJLJ_EMSCRIPTEN_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
|
|
|
|
|
|
|
// '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
|
|
|
|
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
|
|
|
|
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
|
|
|
|
// RUN: -mllvm -enable-emscripten-sjlj 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_SJLJ %s
|
|
|
|
// WASM_SJLJ_EMSCRIPTEN_SJLJ: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
|
|
|
|
|
[WebAssembly] Implement Address Sanitizer for Emscripten
Summary:
This diff enables address sanitizer on Emscripten.
On Emscripten, real memory starts at the value passed to --global-base.
All memory before this is used as shadow memory, and thus the shadow mapping
function is simply dividing by 8.
Reviewers: tlively, aheejin, sbc100
Reviewed By: sbc100
Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D63742
llvm-svn: 364468
2019-06-27 04:16:14 +08:00
|
|
|
// RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
|
|
|
|
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
|
|
|
|
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
|
2020-04-22 01:35:10 +08:00
|
|
|
|
|
|
|
// Basic exec-model tests.
|
|
|
|
|
2020-06-05 06:55:08 +08:00
|
|
|
// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
|
2020-04-22 01:35:10 +08:00
|
|
|
// RUN: | FileCheck -check-prefix=CHECK-COMMAND %s
|
|
|
|
// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
|
|
|
|
// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
|
|
|
|
|
2020-06-05 06:55:08 +08:00
|
|
|
// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
|
2020-04-22 01:35:10 +08:00
|
|
|
// RUN: | FileCheck -check-prefix=CHECK-REACTOR %s
|
2020-06-05 06:55:08 +08:00
|
|
|
// CHECK-REACTOR: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
|
|
|
|
// CHECK-REACTOR: wasm-ld{{.*}}" "crt1-reactor.o" "--entry" "_initialize" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
|
2020-07-24 06:06:21 +08:00
|
|
|
|
|
|
|
// -fPIC implies +mutable-globals
|
|
|
|
|
|
|
|
// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -fPIC 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=CHECK-PIC %s
|
|
|
|
// CHECK-PIC: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+mutable-globals"
|
|
|
|
|
|
|
|
// '-mno-mutable-globals' is not allowed with '-fPIC'
|
|
|
|
// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
|
|
|
|
// PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with '-mno-mutable-globals'
|