diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -141,7 +141,7 @@ options::OPT_fno_use_init_array, true)) CC1Args.push_back("-fuse-init-array"); - // '-pthread' implies '-target-feature +atomics' + // '-pthread' implies target features atomics and bulk-memory if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread, false)) { if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics, @@ -149,8 +149,15 @@ getDriver().Diag(diag::err_drv_argument_not_allowed_with) << "-pthread" << "-mno-atomics"; + if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory, + options::OPT_mbulk_memory, false)) + getDriver().Diag(diag::err_drv_argument_not_allowed_with) + << "-pthread" + << "-mno-bulk-memory"; CC1Args.push_back("-target-feature"); CC1Args.push_back("+atomics"); + CC1Args.push_back("-target-feature"); + CC1Args.push_back("+bulk-memory"); } } diff --git a/clang/test/Driver/wasm-toolchain.c b/clang/test/Driver/wasm-toolchain.c --- a/clang/test/Driver/wasm-toolchain.c +++ b/clang/test/Driver/wasm-toolchain.c @@ -48,11 +48,11 @@ // Thread-related command line tests. -// '-pthread' sets '-target-feature +atomics' and '--shared-memory' +// '-pthread' sets +atomics, +bulk-memory, and --shared-memory // 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 -// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" +// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory" // '-pthread' not allowed with '-mno-atomics' @@ -61,6 +61,12 @@ // RUN: | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics' +// '-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=BULK_MEM_NO_ATOMICS %s +// BULK_MEM_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-bulk-memory' + // 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"