[PATCH] D59721: [WebAssembly] Make driver -pthread imply linker --shared-memory
Thomas Lively via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 22 15:06:42 PDT 2019
tlively created this revision.
tlively added reviewers: sbc100, aheejin.
Herald added subscribers: cfe-commits, jfb, sunfish, jgravelle-google, dschuff.
Herald added a project: clang.
This eliminates a linker error the user might otherwise see about how
using the 'atomics' feature requires --shared-memory.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59721
Files:
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c
Index: clang/test/Driver/wasm-toolchain.c
===================================================================
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -41,9 +41,10 @@
// 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
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -62,8 +62,10 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59721.191955.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190322/e779e392/attachment.bin>
More information about the cfe-commits
mailing list