[PATCH] D147834: [clang][driver] Pass `-femulated-tls` through to the linker in LTO mode
Paul Kirth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 10 10:03:42 PDT 2023
paulkirth updated this revision to Diff 512189.
paulkirth marked an inline comment as done.
paulkirth added a comment.
Fix formatting in CHECK lines.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147834/new/
https://reviews.llvm.org/D147834
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/emulated-tls.cpp
Index: clang/test/Driver/emulated-tls.cpp
===================================================================
--- clang/test/Driver/emulated-tls.cpp
+++ clang/test/Driver/emulated-tls.cpp
@@ -29,6 +29,18 @@
// RUN: %clang -### -target i686-pc-openbsd %s -femulated-tls -fno-emulated-tls 2>&1 \
// RUN: | FileCheck -check-prefix=NOEMU %s
+// Test that when lto is used any -emualted-tls flags are passed to the linker
+// LINUX and Android have different defaults for EmulatedTLS
+// RUN: %clang -### -flto --target=riscv64-linux -fno-emulated-tls %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO_NOEMUTLS
+// RUN: %clang -### -flto --target=riscv64-linux-android10000 -femulated-tls %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO_EMUTLS
+// RUN: %clang -### -flto --target=riscv64-linux -femulated-tls %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO_EMUTLS
+// RUN: %clang -### -flto --target=riscv64-linux-android10000 -fno-emulated-tls %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO_NOEMUTLS
+
+
// Default without -f[no-]emulated-tls, will be decided by the target triple.
// DEFAULT-NOT: "-cc1" {{.*}}"-femulated-tls"
@@ -40,3 +52,10 @@
// NOEMU: "-cc1" {{.*}}"-fno-emulated-tls"
// NOEMU-NOT: "-cc1" {{.*}}"-femulated-tls"
+
+// LTO related checks
+// LTO_NOEMUTLS: plugin-opt=-emulated-tls=0
+// LTO_NOEMUTLS-NOT: plugin-opt=-emulated-tls=1
+
+// LTO_EMUTLS: plugin-opt=-emulated-tls=1
+// LTO_EMUTLS-NOT: plugin-opt=-emulated-tls=0
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -764,6 +764,13 @@
D.Diag(clang::diag::warn_drv_fjmc_for_elf_only);
}
+ if (Arg *A = Args.getLastArg(options::OPT_femulated_tls,
+ options::OPT_fno_emulated_tls)) {
+ bool Enable = A->getOption().getID() == options::OPT_femulated_tls;
+ CmdArgs.push_back(Args.MakeArgString(
+ Twine(PluginOptPrefix) + "-emulated-tls=" + (Enable ? "1" : "0")));
+ }
+
if (Args.hasFlag(options::OPT_fstack_size_section,
options::OPT_fno_stack_size_section, false))
CmdArgs.push_back(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147834.512189.patch
Type: text/x-patch
Size: 2237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230410/3d6541c6/attachment.bin>
More information about the cfe-commits
mailing list