Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -412,6 +412,10 @@ message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3") endif() +if(DEFINED HAIKU_HYBRID_SECONDARY) + add_definitions(-DHAIKU_HYBRID_SECONDARY=${HAIKU_HYBRID_SECONDARY}) +endif() + if(CLANG_ANALYZER_BUILD_Z3) find_package(Z3 4.5) if(Z3_FOUND) Index: lib/Driver/ToolChains/Haiku.cpp =================================================================== --- lib/Driver/ToolChains/Haiku.cpp +++ lib/Driver/ToolChains/Haiku.cpp @@ -20,6 +20,13 @@ Haiku::Haiku(const Driver &D, const llvm::Triple& Triple, const ArgList &Args) : Generic_ELF(D, Triple, Args) { +#ifdef HAIKU_HYBRID_SECONDARY + getProgramPaths().insert(getProgramPaths().begin(), getDriver().SysRoot + + "/system/bin/" HAIKU_HYBRID_SECONDARY); + getFilePaths().clear(); + getFilePaths().push_back(getDriver().SysRoot + "/system/lib/" + HAIKU_HYBRID_SECONDARY); +#endif } void Haiku::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, @@ -30,6 +37,13 @@ void Haiku::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { + +#ifdef HAIKU_HYBRID_SECONDARY + addLibStdCXXIncludePaths(getDriver().SysRoot, "/system/develop/headers" + HAIKU_HYBRID_SECONDARY "/c++", getTriple().str(), "", "", "", + DriverArgs, CC1Args); +#else addLibStdCXXIncludePaths(getDriver().SysRoot, "/system/develop/headers/c++", getTriple().str(), "", "", "", DriverArgs, CC1Args); +#endif } Index: lib/Frontend/InitHeaderSearch.cpp =================================================================== --- lib/Frontend/InitHeaderSearch.cpp +++ lib/Frontend/InitHeaderSearch.cpp @@ -238,7 +238,19 @@ if (HSOpts.UseBuiltinIncludes) { // Ignore the sys root, we *always* look for clang headers relative to // supplied path. +#ifdef HAIKU_HYBRID_SECONDARY + // Remove version from foo/lib/clang/version + StringRef Ver = llvm::sys::path::filename(HSOpts.ResourceDir); + StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir); + // Remove clang from foo/lib/clang + StringRef Clang = llvm::sys::path::filename(NoVer); + SmallString<128> P = llvm::sys::path::parent_path(NoVer); + + // Get foo/include/c++/v1 + llvm::sys::path::append(P, HAIKU_HYBRID_SECONDARY, Clang, Ver); +#else SmallString<128> P = StringRef(HSOpts.ResourceDir); +#endif llvm::sys::path::append(P, "include"); AddUnmappedPath(P, ExternCSystem, false); } @@ -272,7 +284,12 @@ } case llvm::Triple::Haiku: +#ifdef HAIKU_HYBRID_SECONDARY + AddPath("/boot/system/non-packaged/develop/headers/" HAIKU_HYBRID_SECONDARY, + System, false); +#else AddPath("/boot/system/non-packaged/develop/headers", System, false); +#endif 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); @@ -304,6 +321,13 @@ AddPath("/boot/system/develop/headers/bsd", System, false); AddPath("/boot/system/develop/headers/glibc", System, false); AddPath("/boot/system/develop/headers/posix", System, false); +#ifdef HAIKU_HYBRID_SECONDARY + AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY, System, false); + AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY "/os", System, + false); + AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY "/os/opengl", + System, false); +#endif AddPath("/boot/system/develop/headers", System, false); break; case llvm::Triple::RTEMS: