[PATCH] D16264: For FreeBSD, use _p variants of libraries for linking C++ programs
Dimitry Andric via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 16 16:08:37 PST 2016
dim created this revision.
dim added reviewers: compnerd, davide, dws, emaste.
dim added subscribers: rpokala, cfe-commits.
Herald added a subscriber: emaste.
As reported in https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD,
C++ programs compiled for profiling (using `-pg`) should be linked with
`-lc++_p` (or `-lstdc++_p`, depending on the `-stdlib=` setting), not
with the regular C++ libraries.
Add a `FreeBSD::AddCXXStdlibLibArgs()` override to handle this, and add
a test case for it.
This review is intended to replace D16102.
http://reviews.llvm.org/D16264
Files:
lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
test/Driver/freebsd.cpp
Index: test/Driver/freebsd.cpp
===================================================================
--- test/Driver/freebsd.cpp
+++ test/Driver/freebsd.cpp
@@ -4,3 +4,10 @@
// RUN: | FileCheck --check-prefix=CHECK-NINE %s
// CHECK-TEN: -lc++
// CHECK-NINE: -lstdc++
+
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PG-TEN %s
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-TEN: -lc++_p
+// CHECK-PG-NINE: -lstdc++_p
Index: lib/Driver/ToolChains.h
===================================================================
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -725,6 +725,8 @@
void AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const override;
bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault() const override;
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3116,6 +3116,22 @@
}
}
+void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ CXXStdlibType Type = GetCXXStdlibType(Args);
+ bool Profiling = Args.hasArg(options::OPT_pg);
+
+ switch (Type) {
+ case ToolChain::CST_Libcxx:
+ CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+ break;
+
+ case ToolChain::CST_Libstdcxx:
+ CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++");
+ break;
+ }
+}
+
Tool *FreeBSD::buildAssembler() const {
return new tools::freebsd::Assembler(*this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16264.45085.patch
Type: text/x-patch
Size: 1913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160117/23463272/attachment-0001.bin>
More information about the cfe-commits
mailing list