From 009a77818c53799db2d150e835332df6f5542004 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 1 May 2014 23:24:24 +0000 Subject: [PATCH] Bitrig's standard C++ standard library changed from libstdc++ to libc++. Also, it uses libc++abi and needs pthread. While there, fix the libc++ include path. Patch by Patrick Wildt! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207813 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 22 ++++++++++++++++++---- lib/Driver/ToolChains.h | 1 + test/Driver/bitrig.c | 12 ++++++------ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 9465be8778..d8ed34ff6e 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -2407,6 +2407,21 @@ Tool *Bitrig::buildLinker() const { return new tools::bitrig::Link(*this); } +ToolChain::CXXStdlibType +Bitrig::GetCXXStdlibType(const ArgList &Args) const { + if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { + StringRef Value = A->getValue(); + if (Value == "libstdc++") + return ToolChain::CST_Libstdcxx; + if (Value == "libc++") + return ToolChain::CST_Libcxx; + + getDriver().Diag(diag::err_drv_invalid_stdlib_name) + << A->getAsString(Args); + } + return ToolChain::CST_Libcxx; +} + void Bitrig::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { if (DriverArgs.hasArg(options::OPT_nostdlibinc) || @@ -2416,7 +2431,7 @@ void Bitrig::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, switch (GetCXXStdlibType(DriverArgs)) { case ToolChain::CST_Libcxx: addSystemInclude(DriverArgs, CC1Args, - getDriver().SysRoot + "/usr/include/c++/"); + getDriver().SysRoot + "/usr/include/c++/v1"); break; case ToolChain::CST_Libstdcxx: addSystemInclude(DriverArgs, CC1Args, @@ -2442,9 +2457,8 @@ void Bitrig::AddCXXStdlibLibArgs(const ArgList &Args, switch (GetCXXStdlibType(Args)) { case ToolChain::CST_Libcxx: CmdArgs.push_back("-lc++"); - CmdArgs.push_back("-lcxxrt"); - // Include supc++ to provide Unwind until provided by libcxx. - CmdArgs.push_back("-lgcc"); + CmdArgs.push_back("-lc++abi"); + CmdArgs.push_back("-lpthread"); break; case ToolChain::CST_Libstdcxx: CmdArgs.push_back("-lstdc++"); diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index ad4d4c1585..b1a0627840 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -557,6 +557,7 @@ public: bool IsMathErrnoDefault() const override { return false; } bool IsObjCNonFragileABIDefault() const override { return true; } + CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; diff --git a/test/Driver/bitrig.c b/test/Driver/bitrig.c index 876a9cdb9e..934cb02f22 100644 --- a/test/Driver/bitrig.c +++ b/test/Driver/bitrig.c @@ -4,14 +4,14 @@ // CHECK-LD-C: ld{{.*}}" {{.*}} "-lc" "-lclang_rt.amd64" // RUN: %clangxx -no-canonical-prefixes -target amd64-pc-bitrig %s -### 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-LD-CXX %s -// CHECK-LD-CXX: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig" -// CHECK-LD-CXX: ld{{.*}}" {{.*}} "-lstdc++" "-lm" "-lc" "-lclang_rt.amd64" - -// RUN: %clangxx -stdlib=libc++ -no-canonical-prefixes -target amd64-pc-bitrig %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD-CXX-STDLIB %s // CHECK-LD-CXX-STDLIB: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig" -// CHECK-LD-CXX-STDLIB: ld{{.*}}" {{.*}} "-lc++" "-lcxxrt" "-lgcc" "-lm" "-lc" "-lclang_rt.amd64" +// CHECK-LD-CXX-STDLIB: ld{{.*}}" {{.*}} "-lc++" "-lc++abi" "-lpthread" "-lm" "-lc" "-lclang_rt.amd64" + +// RUN: %clangxx -stdlib=libstdc++ -no-canonical-prefixes -target amd64-pc-bitrig %s -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LD-CXX %s +// CHECK-LD-CXX: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig" +// CHECK-LD-CXX: ld{{.*}}" {{.*}} "-lstdc++" "-lm" "-lc" "-lclang_rt.amd64" // RUN: %clang -no-canonical-prefixes -target amd64-pc-bitrig -pthread %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PTHREAD %s -- 2.40.0