hurd: find c++ headers This should be factorized with Linux.cpp and the GNU/kFreeBSD case. Index: llvm-toolchain-snapshot_11~++20200207025749+c29003813ab/clang/lib/Driver/ToolChains/Hurd.cpp =================================================================== --- llvm-toolchain-snapshot_11~++20200207025749+c29003813ab.orig/clang/lib/Driver/ToolChains/Hurd.cpp +++ llvm-toolchain-snapshot_11~++20200207025749+c29003813ab/clang/lib/Driver/ToolChains/Hurd.cpp @@ -89,8 +89,40 @@ Hurd::Hurd(const Driver &D, const llvm:: addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); - // If we are currently running Clang inside of the requested system root, add - // its parent library path to those searched. + // Try walking via the GCC triple path in case of biarch or multiarch GCC + // installations with strange symlinks. + if (GCCInstallation.isValid()) { + addPathIfExists(D, + SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + + "/../../" + OSLibDir, + Paths); + + // Add the 'other' biarch variant path + Multilib BiarchSibling; + if (GCCInstallation.getBiarchSibling(BiarchSibling)) { + addPathIfExists(D, GCCInstallation.getInstallPath() + + BiarchSibling.gccSuffix(), + Paths); + } + + // See comments above on the multilib variant for details of why this is + // included even from outside the sysroot. + const std::string &LibPath = GCCInstallation.getParentLibPath(); + const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); + const Multilib &Multilib = GCCInstallation.getMultilib(); + addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" + + Multilib.osSuffix(), + Paths); + + // See comments above on the multilib variant for details of why this is + // only included from within the sysroot. + if (StringRef(LibPath).startswith(SysRoot)) + addPathIfExists(D, LibPath, Paths); + } + + // Similar to the logic for GCC above, if we are currently running Clang + // inside of the requested system root, add its parent library path to those + // searched. // FIXME: It's not clear whether we should use the driver's installed // directory ('Dir' below) or the ResourceDir. if (StringRef(D.Dir).startswith(SysRoot)) @@ -157,6 +189,17 @@ void Hurd::AddClangSystemIncludeArgs(con // Lacking those, try to detect the correct set of system includes for the // target triple. + + // Add include directories specific to the selected multilib set and multilib. + if (GCCInstallation.isValid()) { + const auto &Callback = Multilibs.includeDirsCallback(); + if (Callback) { + for (const auto &Path : Callback(GCCInstallation.getMultilib())) + addExternCSystemIncludeIfExists( + DriverArgs, CC1Args, GCCInstallation.getInstallPath() + Path); + } + } + if (getTriple().getArch() == llvm::Triple::x86) { std::string Path = SysRoot + "/usr/include/i386-gnu"; if (D.getVFS().exists(Path))