]> granicus.if.org Git - clang/commitdiff
[WebAssembly] Make driver -pthread imply linker --shared-memory
authorThomas Lively <tlively@google.com>
Fri, 22 Mar 2019 22:25:37 +0000 (22:25 +0000)
committerThomas Lively <tlively@google.com>
Fri, 22 Mar 2019 22:25:37 +0000 (22:25 +0000)
Summary:
This eliminates a linker error the user might otherwise see about how
using the 'atomics' feature requires --shared-memory.

Reviewers: sbc100, aheejin

Subscribers: dschuff, jgravelle-google, sunfish, jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59721

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

lib/Driver/ToolChains/WebAssembly.cpp
test/Driver/wasm-toolchain.c

index 0104cbbbf4d599ab406bb4ca8e6396c933f7723f..b69588d4c1ea289bc6d999fa599173947e80be38 100644 (file)
@@ -62,8 +62,10 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     if (ToolChain.ShouldLinkCXXStdlib(Args))
       ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
 
-    if (Args.hasArg(options::OPT_pthread))
+    if (Args.hasArg(options::OPT_pthread)) {
       CmdArgs.push_back("-lpthread");
+      CmdArgs.push_back("--shared-memory");
+    }
 
     CmdArgs.push_back("-lc");
     AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
index 9c217ef2e9499505ffa6019c88c9b5ffd55e7ddb..c47e24fa94e63f705b9df069f5398752224f39c7 100644 (file)
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics'
+// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s -pthread 2>&1 | FileCheck -check-prefix=PTHREAD %s
 // PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s -pthread -mno-atomics 2>&1 | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s