[clang] f347633 - [Driver] move DragonFly header search path management to the driver
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 29 20:19:31 PDT 2023
Author: Brad Smith
Date: 2023-08-29T23:18:42-04:00
New Revision: f3476332e4531a667063b8980de1fbc5fb4a6251
URL: https://github.com/llvm/llvm-project/commit/f3476332e4531a667063b8980de1fbc5fb4a6251
DIFF: https://github.com/llvm/llvm-project/commit/f3476332e4531a667063b8980de1fbc5fb4a6251.diff
LOG: [Driver] move DragonFly header search path management to the driver
As has been done for other OS's. Move the header path management to the driver.
Also I noticed with D89690 that the library paths were updated for GCC 8, but
the C++ header path was not. So I also fixed that while here.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D158376
Added:
Modified:
clang/lib/Driver/ToolChains/DragonFly.cpp
clang/lib/Driver/ToolChains/DragonFly.h
clang/lib/Lex/InitHeaderSearch.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp b/clang/lib/Driver/ToolChains/DragonFly.cpp
index ba901407715f32..6f46864105e9c0 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -12,6 +12,7 @@
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -195,6 +196,33 @@ DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple,
getFilePaths().push_back("/usr/lib/gcc80");
}
+void DragonFly::AddClangSystemIncludeArgs(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ const Driver &D = getDriver();
+
+ if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
+ return;
+
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+ SmallString<128> Dir(D.ResourceDir);
+ llvm::sys::path::append(Dir, "include");
+ addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ }
+
+ if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+ return;
+
+ addExternCSystemInclude(DriverArgs, CC1Args,
+ concat(D.SysRoot, "/usr/include"));
+}
+
+void DragonFly::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ addLibStdCXXIncludePaths(concat(getDriver().SysRoot, "/usr/include/c++/8.0"), "", "",
+ DriverArgs, CC1Args);
+}
+
Tool *DragonFly::buildAssembler() const {
return new tools::dragonfly::Assembler(*this);
}
diff --git a/clang/lib/Driver/ToolChains/DragonFly.h b/clang/lib/Driver/ToolChains/DragonFly.h
index 3ed5acefaefb51..42ce960c5bdbd9 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.h
+++ b/clang/lib/Driver/ToolChains/DragonFly.h
@@ -55,6 +55,13 @@ class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
bool IsMathErrnoDefault() const override { return false; }
+ void
+ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+ void addLibStdCxxIncludePaths(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
index 1531871411f980..2c2fb767ca1ef9 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -307,9 +307,6 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(
break;
}
break;
- case llvm::Triple::DragonFly:
- AddPath("/usr/include/c++/5.0", CXXSystem, false);
- break;
default:
break;
}
@@ -319,6 +316,7 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
const llvm::Triple &triple) {
switch (triple.getOS()) {
case llvm::Triple::AIX:
+ case llvm::Triple::DragonFly:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Emscripten:
case llvm::Triple::FreeBSD:
More information about the cfe-commits
mailing list