From: Thomas Lively Date: Fri, 12 Jul 2019 18:23:13 +0000 (+0000) Subject: [WebAssembly] Make pthread imply bulk-memory, mutable-globals X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03563a98ef9193d8fd997f4b0f71fb46b02ba8c6;p=clang [WebAssembly] Make pthread imply bulk-memory, mutable-globals Summary: This paves the way for using passive segments in pthread builds, which will make separate memory files unnecessary. Mutable globals are also necessary for the upcoming implementation of TLS. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64586 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365935 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/WebAssembly.cpp b/lib/Driver/ToolChains/WebAssembly.cpp index 648e5b3a94..7a40c13c06 100644 --- a/lib/Driver/ToolChains/WebAssembly.cpp +++ b/lib/Driver/ToolChains/WebAssembly.cpp @@ -141,7 +141,7 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs, options::OPT_fno_use_init_array, true)) CC1Args.push_back("-fuse-init-array"); - // '-pthread' implies '-target-feature +atomics' + // '-pthread' implies atomics, bulk-memory, and mutable-globals if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread, false)) { if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics, @@ -149,8 +149,22 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs, 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"; + if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals, + options::OPT_mmutable_globals, false)) + getDriver().Diag(diag::err_drv_argument_not_allowed_with) + << "-pthread" + << "-mno-mutable-globals"; CC1Args.push_back("-target-feature"); CC1Args.push_back("+atomics"); + CC1Args.push_back("-target-feature"); + CC1Args.push_back("+bulk-memory"); + CC1Args.push_back("-target-feature"); + CC1Args.push_back("+mutable-globals"); } } diff --git a/test/Driver/wasm-toolchain.c b/test/Driver/wasm-toolchain.c index 910de4bd59..263fcf7f39 100644 --- a/test/Driver/wasm-toolchain.c +++ b/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, +mutable-globals, 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" "-target-feature" "+mutable-globals" // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory" // '-pthread' not allowed with '-mno-atomics' @@ -61,6 +61,18 @@ // 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=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' + // 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"