]> granicus.if.org Git - clang/commitdiff
[WebAssemby] Enable "-mthread-model single" by default, for now.
authorDan Gohman <dan433584@gmail.com>
Mon, 27 Nov 2017 21:39:16 +0000 (21:39 +0000)
committerDan Gohman <dan433584@gmail.com>
Mon, 27 Nov 2017 21:39:16 +0000 (21:39 +0000)
The WebAssembly standard does not yet have threads, and while it's in the
process of being standardized, it'll take some time for it to make it
through and be available in all popular implementations. With increasing
numbers of people using the LLVM wasm backend through LLVM directly rather
than through Emscripten, it's increasingly important to have friendly
defaults.

See also https://bugs.llvm.org/show_bug.cgi?id=35411

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319101 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/WebAssembly.cpp
lib/Driver/ToolChains/WebAssembly.h

index 1464c150c9c2adbe8361c5d3b38d7accb5543e91..d00d833fbb0803416c12ff11b200218dc175208d 100644 (file)
@@ -135,6 +135,14 @@ void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
                      getDriver().SysRoot + "/include/c++/v1");
 }
 
+std::string WebAssembly::getThreadModel() const {
+  // The WebAssembly MVP does not yet support threads; for now, use the
+  // "single" threading model, which lowers atomics to non-atomic operations.
+  // When threading support is standardized and implemented in popular engines,
+  // this override should be removed.
+  return "single";
+}
+
 Tool *WebAssembly::buildLinker() const {
   return new tools::wasm::Linker(*this);
 }
index 7524361d516fe4864b5376fe10e9ffbbfe9b49e1..8784e12dfb0ecff74bdac20379626cd32c3e2dbd 100644 (file)
@@ -62,6 +62,7 @@ private:
   void AddClangCXXStdlibIncludeArgs(
       const llvm::opt::ArgList &DriverArgs,
       llvm::opt::ArgStringList &CC1Args) const override;
+  std::string getThreadModel() const override;
 
   const char *getDefaultLinker() const override {
     return "lld";