[PATCH] Bitrig switches C++ standard library

Richard Smith richard at metafoo.co.uk
Thu May 1 16:31:48 PDT 2014


On Thu, May 1, 2014 at 3:22 PM, Patrick Wildt <mail at patrick-wildt.de> wrote:

> On Thu, May 01, 2014 at 03:08:07PM -0700, Richard Smith wrote:
> > On Thu, May 1, 2014 at 1:46 PM, Patrick Wildt <mail at patrick-wildt.de>
> wrote:
> >
> > > Hi,
> > >
> > > 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.
> > >
> > > \Patrick
> > >
> > > diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
> > > index 9465be8..d8ed34f 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");
> > >
> >
> > Should this be controlled by the -pthread switch, or do you need it for
> all
> > C++ builds for some reason?
>
> Yes, it is needed for all C++ builds due to libc++abi dependency on
> pthread specific symbols.


OK! Committed as r207813. Thanks!

> >      break;
> > >    case ToolChain::CST_Libstdcxx:
> > >      CmdArgs.push_back("-lstdc++");
> > > diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
> > > index ad4d4c1..b1a0627 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 876a9cd..d36d204 100644
> > > --- a/test/Driver/bitrig.c
> > > +++ b/test/Driver/bitrig.c
> > > @@ -4,15 +4,15 @@
> > >  // 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-STDLIB %s
> > > +// CHECK-LD-CXX-STDLIB: clang{{.*}}" "-cc1" "-triple"
> "amd64-pc-bitrig"
> > > +// 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: %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"
> > > -
> > >  // RUN: %clang -no-canonical-prefixes -target amd64-pc-bitrig
> -pthread %s
> > > -### 2>&1 \
> > >  // RUN:   | FileCheck --check-prefix=CHECK-PTHREAD %s
> > >  // CHECK-PTHREAD: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
> > >
> > > _______________________________________________
> > > cfe-commits mailing list
> > > cfe-commits at cs.uiuc.edu
> > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> > >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140501/6de3ab63/attachment.html>


More information about the cfe-commits mailing list