diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Driver/ToolChains/Hurd.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Driver/ToolChains/Hurd.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Hurd.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Hurd.cpp index ee91f7d73b9c..a700d7b9064c 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Hurd.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Hurd.cpp @@ -63,18 +63,33 @@ static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : Generic_ELF(D, Triple, Args) { + GCCInstallation.init(Triple, Args); + Multilibs = GCCInstallation.getMultilibs(); + SelectedMultilib = GCCInstallation.getMultilib(); std::string SysRoot = computeSysRoot(); + ToolChain::path_list &PPaths = getProgramPaths(); + + Generic_GCC::PushPPaths(PPaths); + + // The selection of paths to try here is designed to match the patterns which + // the GCC driver itself uses, as this is part of the GCC-compatible driver. + // This was determined by running GCC in a fake filesystem, creating all + // possible permutations of these directories, and seeing which ones it added + // to the link paths. path_list &Paths = getFilePaths(); - const std::string OSLibDir = getOSLibDir(Triple, Args); + const std::string OSLibDir = std::string(getOSLibDir(Triple, Args)); const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); #ifdef ENABLE_LINKER_BUILD_ID ExtraOpts.push_back("--build-id"); #endif - // If we are currently running Clang inside of the requested system root, add - // its parent library paths to those searched. + Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths); + + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent library paths 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)) { @@ -88,8 +103,11 @@ Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) 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. + Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, 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)) @@ -107,13 +125,6 @@ Tool *Hurd::buildAssembler() const { return new tools::gnutools::Assembler(*this); } -std::string Hurd::computeSysRoot() const { - if (!getDriver().SysRoot.empty()) - return getDriver().SysRoot; - - return std::string(); -} - std::string Hurd::getDynamicLinker(const ArgList &Args) const { if (getArch() == llvm::Triple::x86) return "/lib/ld.so"; @@ -148,7 +159,7 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList &DriverArgs, CIncludeDirs.split(Dirs, ":"); for (StringRef Dir : Dirs) { StringRef Prefix = - llvm::sys::path::is_absolute(Dir) ? StringRef(SysRoot) : ""; + llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot); addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir); } return; @@ -156,6 +167,9 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList &DriverArgs, // Lacking those, try to detect the correct set of system includes for the // target triple. + + AddMultilibIncludeArgs(DriverArgs, CC1Args); + if (getTriple().getArch() == llvm::Triple::x86) { std::string Path = SysRoot + "/usr/include/i386-gnu"; if (D.getVFS().exists(Path)) |