[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
llvm-svn: 365935
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 648e5b3..7a40c13 100644
--- 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 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 @@
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");
}
}