diff --git a/clang/lib/Driver/ToolChains/Haiku.h b/clang/lib/Driver/ToolChains/Haiku.h --- a/clang/lib/Driver/ToolChains/Haiku.h +++ b/clang/lib/Driver/ToolChains/Haiku.h @@ -26,6 +26,9 @@ return getTriple().getArch() == llvm::Triple::x86_64; } + void AddClangSystemIncludeArgs( + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; void addLibCxxIncludePaths( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp b/clang/lib/Driver/ToolChains/Haiku.cpp --- a/clang/lib/Driver/ToolChains/Haiku.cpp +++ b/clang/lib/Driver/ToolChains/Haiku.cpp @@ -8,6 +8,8 @@ #include "Haiku.h" #include "CommonArgs.h" +#include "clang/Config/config.h" +#include "llvm/Support/Path.h" using namespace clang::driver; using namespace clang::driver::toolchains; @@ -21,6 +23,70 @@ } +void Haiku::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const { + const Driver &D = getDriver(); + + if (DriverArgs.hasArg(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; + + // Add dirs specified via 'configure --with-c-include-dirs'. + StringRef CIncludeDirs(C_INCLUDE_DIRS); + if (!CIncludeDirs.empty()) { + SmallVector dirs; + CIncludeDirs.split(dirs, ":"); + for (StringRef dir : dirs) { + StringRef Prefix = + llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : ""; + addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir); + } + return; + } + + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/non-packaged/develop/headers"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/app"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/arch"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/device"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/drivers"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/game"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/interface"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/kernel"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/locale"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/mail"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/media"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/midi"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/midi2"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/net"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/opengl"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/storage"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/support"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/translation"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/add-ons/graphics"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/add-ons/input_server"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/add-ons/mail_daemon"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/add-ons/registrar"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/add-ons/screen_saver"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/add-ons/tracker"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/be_apps/Deskbar"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/be_apps/NetPositive"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/os/be_apps/Tracker"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/3rdparty"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/bsd"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/glibc"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers/posix"); + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/boot/system/develop/headers"); +} + void Haiku::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { addSystemInclude(DriverArgs, CC1Args, diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp --- a/clang/lib/Lex/InitHeaderSearch.cpp +++ b/clang/lib/Lex/InitHeaderSearch.cpp @@ -279,42 +279,6 @@ AddPath(P, System, false); break; } - - case llvm::Triple::Haiku: - AddPath("/boot/system/non-packaged/develop/headers", System, false); - AddPath("/boot/system/develop/headers/os", System, false); - AddPath("/boot/system/develop/headers/os/app", System, false); - AddPath("/boot/system/develop/headers/os/arch", System, false); - AddPath("/boot/system/develop/headers/os/device", System, false); - AddPath("/boot/system/develop/headers/os/drivers", System, false); - AddPath("/boot/system/develop/headers/os/game", System, false); - AddPath("/boot/system/develop/headers/os/interface", System, false); - AddPath("/boot/system/develop/headers/os/kernel", System, false); - AddPath("/boot/system/develop/headers/os/locale", System, false); - AddPath("/boot/system/develop/headers/os/mail", System, false); - AddPath("/boot/system/develop/headers/os/media", System, false); - AddPath("/boot/system/develop/headers/os/midi", System, false); - AddPath("/boot/system/develop/headers/os/midi2", System, false); - AddPath("/boot/system/develop/headers/os/net", System, false); - AddPath("/boot/system/develop/headers/os/opengl", System, false); - AddPath("/boot/system/develop/headers/os/storage", System, false); - AddPath("/boot/system/develop/headers/os/support", System, false); - AddPath("/boot/system/develop/headers/os/translation", System, false); - AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false); - AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false); - AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false); - AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false); - AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false); - AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false); - AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false); - AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false); - AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false); - AddPath("/boot/system/develop/headers/3rdparty", System, false); - AddPath("/boot/system/develop/headers/bsd", System, false); - AddPath("/boot/system/develop/headers/glibc", System, false); - AddPath("/boot/system/develop/headers/posix", System, false); - AddPath("/boot/system/develop/headers", System, false); - break; case llvm::Triple::RTEMS: break; case llvm::Triple::Win32: @@ -388,6 +352,7 @@ case llvm::Triple::PS4: case llvm::Triple::PS5: case llvm::Triple::Fuchsia: + case llvm::Triple::Haiku: case llvm::Triple::Hurd: case llvm::Triple::Linux: case llvm::Triple::Solaris: