[PATCH] D46998: [XRay][clang+compiler-rt] Make XRay depend on a C++ standard lib
Dean Michael Berris via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 16 23:26:27 PDT 2018
dberris created this revision.
dberris added reviewers: dblaikie, echristo.
This is related to http://llvm.org/PR32274.
When building with XRay, always depend on a C++ standard library.
We're doing this to automate the linking of the C++ ABI functionality
that the modes use by default. In particular, we depend on some
function-local static initialisation.
The alternative change here is to re-write the modes to only use
libc/pthreads functionality. We're choosing to do this instead as it's
minimally invasive. In the future we can revisit this when we have a
better idea as to why not depending on the C++ ABI functionality is a
better solution.
https://reviews.llvm.org/D46998
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
compiler-rt/test/xray/TestCases/Posix/c-test.cc
Index: compiler-rt/test/xray/TestCases/Posix/c-test.cc
===================================================================
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Posix/c-test.cc
@@ -0,0 +1,4 @@
+// RUN: %clang_xray -g -o %t %s
+// REQUIRES: x86_64-target-arch
+// REQUIRES: built-in-llvm-tree
+int main() {}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -713,7 +713,8 @@
return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
}
-bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, ArgStringList &CmdArgs) {
+bool tools::addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+ ArgStringList &CmdArgs) {
if (Args.hasArg(options::OPT_shared))
return false;
@@ -723,6 +724,11 @@
for (const auto &Mode : TC.getXRayArgs().modeList())
CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode, false));
CmdArgs.push_back("-no-whole-archive");
+
+ // If we're linking a non-C++ application, we'd need to link in the C++
+ // runtime.
+ if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+ TC.AddCXXStdlibLibArgs(Args, CmdArgs);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46998.147245.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180517/322a9690/attachment.bin>
More information about the cfe-commits
mailing list