[llvm-branch-commits] [cfe-branch] r261003 - Merging r260851:

Dimitry Andric via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 16 11:56:48 PST 2016


Author: dim
Date: Tue Feb 16 13:56:48 2016
New Revision: 261003

URL: http://llvm.org/viewvc/llvm-project?rev=261003&view=rev
Log:
Merging r260851:
------------------------------------------------------------------------
r260851 | dim | 2016-02-14 17:08:20 +0100 (Sun, 14 Feb 2016) | 13 lines

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.  While here, extend the test case for the proper
passing of -lm and -lm_p.

Reviewers: compnerd, davide, dws, emaste
Reviewed By: compnerd
Differential Revision: http://reviews.llvm.org/D16264

------------------------------------------------------------------------

Modified:
    cfe/branches/release_38/   (props changed)
    cfe/branches/release_38/lib/Driver/ToolChains.cpp
    cfe/branches/release_38/lib/Driver/ToolChains.h
    cfe/branches/release_38/test/Driver/freebsd.cpp

Propchange: cfe/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 16 13:56:48 2016
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:257652,257695,257710,257831,257838,257853,257861,257869-257871,257947,258110,258396,259183,259260,259598,259931,260370,260616,260637
+/cfe/trunk:257652,257695,257710,257831,257838,257853,257861,257869-257871,257947,258110,258396,259183,259260,259598,259931,260370,260616,260637,260851
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_38/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/lib/Driver/ToolChains.cpp?rev=261003&r1=261002&r2=261003&view=diff
==============================================================================
--- cfe/branches/release_38/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/release_38/lib/Driver/ToolChains.cpp Tue Feb 16 13:56:48 2016
@@ -3108,6 +3108,22 @@ void FreeBSD::AddClangCXXStdlibIncludeAr
   }
 }
 
+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);
 }

Modified: cfe/branches/release_38/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/lib/Driver/ToolChains.h?rev=261003&r1=261002&r2=261003&view=diff
==============================================================================
--- cfe/branches/release_38/lib/Driver/ToolChains.h (original)
+++ cfe/branches/release_38/lib/Driver/ToolChains.h Tue Feb 16 13:56:48 2016
@@ -722,6 +722,8 @@ public:
   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;

Modified: cfe/branches/release_38/test/Driver/freebsd.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/test/Driver/freebsd.cpp?rev=261003&r1=261002&r2=261003&view=diff
==============================================================================
--- cfe/branches/release_38/test/Driver/freebsd.cpp (original)
+++ cfe/branches/release_38/test/Driver/freebsd.cpp Tue Feb 16 13:56:48 2016
@@ -2,5 +2,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
-// CHECK-TEN: -lc++
-// CHECK-NINE: -lstdc++
+// CHECK-TEN: "-lc++" "-lm"
+// CHECK-NINE: "-lstdc++" "-lm"
+
+// 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" "-lm_p"
+// CHECK-PG-NINE: "-lstdc++_p" "-lm_p"




More information about the llvm-branch-commits mailing list