[PATCH] D82677: [AIX] Modify AIX customized clang driver toolchain to include AIX system headers in search path
Shuhong Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 12:36:01 PDT 2020
ShuhongL created this revision.
ShuhongL added reviewers: daltenty, stevewan.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
ShuhongL retitled this revision from "Modify AIX customized clang driver toolchain to include AIX system headers in search path" to "[AIX] Modify AIX customized clang driver toolchain to include AIX system headers in search path".
Modify the AIX customized clang toolchain to include AIX os wrapper headers in the search path
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82677
Files:
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AIX.h
clang/lib/Frontend/InitHeaderSearch.cpp
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -381,6 +381,7 @@
case llvm::Triple::Linux:
case llvm::Triple::Hurd:
case llvm::Triple::Solaris:
+ case llvm::Triple::AIX:
llvm_unreachable("Include management is handled in the driver.");
break;
case llvm::Triple::Win32:
@@ -424,6 +425,7 @@
case llvm::Triple::Hurd:
case llvm::Triple::Solaris:
case llvm::Triple::WASI:
+ case llvm::Triple::AIX:
return;
case llvm::Triple::Win32:
Index: clang/lib/Driver/ToolChains/AIX.h
===================================================================
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -63,6 +63,10 @@
bool isPIEDefault() const override { return false; }
bool isPICDefaultForced() const override { return true; }
+ void
+ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) 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
@@ -13,12 +13,15 @@
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
using AIX = clang::driver::toolchains::AIX;
using namespace clang::driver;
using namespace clang::driver::tools;
+using namespace clang::driver::toolchains;
using namespace llvm::opt;
+using namespace llvm::sys;
void aix::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
@@ -161,6 +164,40 @@
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
}
+void AIX::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
+ // Check if -nostdinc is specified as a driver option
+ if (DriverArgs.hasArg(options::OPT_nostdinc))
+ return;
+
+ const Driver &D = getDriver();
+ SmallString<128> PathAIX(
+ path::parent_path(path::parent_path(D.ClangExecutable)));
+ path::append(PathAIX, "/include/aix");
+
+ // Append AIX headers to the beginning of the -isystem list (order matters)
+ // to override system headers
+ auto *const It =
+ std::find_if(CC1Args.begin(), CC1Args.end(), [&](const auto &arg) {
+ return std::string(arg) == "-isystem";
+ });
+
+ if (It != CC1Args.end()) {
+ auto *const InsertIt = CC1Args.insert(It, "-isystem");
+ CC1Args.insert(InsertIt + 1, DriverArgs.MakeArgString(PathAIX.str()));
+ } else {
+ CC1Args.push_back("-isystem");
+ CC1Args.push_back(DriverArgs.MakeArgString(PathAIX.str()));
+ }
+
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+ SmallString<128> P(D.ResourceDir);
+ path::append(P, "/include");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+ }
+ addSystemInclude(DriverArgs, CC1Args, "/usr/include");
+}
+
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: D82677.273811.patch
Type: text/x-patch
Size: 3388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200626/e47e5511/attachment-0001.bin>
More information about the cfe-commits
mailing list