[PATCH] D85315: [AIX][Clang] Add C++ linker option to the driver toolchain

Shuhong Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 5 07:53:28 PDT 2020


ShuhongL created this revision.
ShuhongL added reviewers: daltenty, hubert.reinterpretcast, stevewan.
ShuhongL added a project: LLVM.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
ShuhongL requested review of this revision.

Add C++ linker option to the AIX clang driver toolchain


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85315

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h


Index: clang/lib/Driver/ToolChains/AIX.h
===================================================================
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -67,6 +67,11 @@
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                             llvm::opt::ArgStringList &CC1Args) const override;
 
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+                           llvm::opt::ArgStringList &CmdArgs) const override;
+
+  CXXStdlibType GetDefaultCXXStdlibType() const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AIX.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -149,6 +149,9 @@
     CmdArgs.push_back("-lc");
   }
 
+  if (getToolChain().ShouldLinkCXXStdlib(Args))
+    getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
                                          Exec, CmdArgs, Inputs));
@@ -197,6 +200,21 @@
   addSystemInclude(DriverArgs, CC1Args, UP.str());
 }
 
+void AIX::AddCXXStdlibLibArgs(const llvm::opt::ArgList &DriverArgs,
+                              llvm::opt::ArgStringList &CC1Args) const {
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx:
+    CC1Args.push_back("-lc++");
+    break;
+  case ToolChain::CST_Libstdcxx:
+    llvm_unreachable("linking libstdc++ unimplemented.");
+  }
+}
+
+ToolChain::CXXStdlibType AIX::GetDefaultCXXStdlibType() const {
+  return ToolChain::CST_Libcxx;
+}
+
 auto AIX::buildAssembler() const -> Tool * { return new aix::Assembler(*this); }
 
 auto AIX::buildLinker() const -> Tool * { return new aix::Linker(*this); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85315.283245.patch
Type: text/x-patch
Size: 1928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200805/83cbc873/attachment.bin>


More information about the cfe-commits mailing list