diff --git a/debian/patches/hurd/hurd-cxx-paths.diff b/debian/patches/hurd/hurd-cxx-paths.diff index c5392f39..2b00630e 100644 --- a/debian/patches/hurd/hurd-cxx-paths.diff +++ b/debian/patches/hurd/hurd-cxx-paths.diff @@ -2,121 +2,11 @@ hurd: find c++ headers This should be factorized with Linux.cpp and the GNU/kFreeBSD case. -Index: llvm-toolchain-9-9.0.0/clang/lib/Driver/ToolChains/Hurd.cpp +Index: llvm-toolchain-snapshot_11~++20200207025749+c29003813ab/clang/lib/Driver/ToolChains/Hurd.cpp =================================================================== ---- llvm-toolchain-9-9.0.0.orig/clang/lib/Driver/ToolChains/Hurd.cpp -+++ llvm-toolchain-9-9.0.0/clang/lib/Driver/ToolChains/Hurd.cpp -@@ -61,21 +61,107 @@ static StringRef getOSLibDir(const llvm: - return Triple.isArch32Bit() ? "lib" : "lib64"; - } - -+static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs, -+ const Multilib &Multilib, -+ StringRef InstallPath, -+ ToolChain::path_list &Paths) { -+ if (const auto &PathsCallback = Multilibs.filePathsCallback()) -+ for (const auto &Path : PathsCallback(Multilib)) -+ addPathIfExists(D, InstallPath + Path, Paths); -+} -+ - 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(); -+ -+ // Cross-compiling binutils and GCC installations (vanilla and openSUSE at -+ // least) put various tools in a triple-prefixed directory off of the parent -+ // of the GCC installation. We use the GCC triple here to ensure that we end -+ // up with tools that support the same amount of cross compiling as the -+ // detected GCC installation. For example, if we find a GCC installation -+ // targeting x86_64, but it is a bi-arch GCC installation, it can also be -+ // used to target i386. -+ // FIXME: This seems unlikely to be Linux- or Hurd-specific. -+ ToolChain::path_list &PPaths = getProgramPaths(); -+ if (GCCInstallation.isValid()) { -+ PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + -+ GCCInstallation.getTriple().str() + "/bin") -+ .str()); -+ } -+ -+ // 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 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. -+ // Add the multilib suffixed paths where they are available. -+ if (GCCInstallation.isValid()) { -+ const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); -+ const std::string &LibPath = GCCInstallation.getParentLibPath(); -+ -+ // Add toolchain / multilib specific file paths. -+ addMultilibsFilePaths(D, Multilibs, SelectedMultilib, -+ GCCInstallation.getInstallPath(), Paths); -+ -+ // Sourcery CodeBench MIPS toolchain holds some libraries under -+ // a biarch-like suffix of the GCC installation. -+ addPathIfExists( -+ D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(), -+ Paths); -+ -+ // GCC cross compiling toolchains will install target libraries which ship -+ // as part of the toolchain under // rather than as -+ // any part of the GCC installation in -+ // //gcc//. This decision is somewhat -+ // debatable, but is the reality today. We need to search this tree even -+ // when we have a sysroot somewhere else. It is the responsibility of -+ // whomever is doing the cross build targeting a sysroot using a GCC -+ // installation that is *not* within the system root to ensure two things: -+ // -+ // 1) Any DSOs that are linked in from this tree or from the install path -+ // above must be present on the system root and found via an -+ // appropriate rpath. -+ // 2) There must not be libraries installed into -+ // // unless they should be preferred over -+ // those within the system root. -+ // -+ // Note that this matches the GCC behavior. See the below comment for where -+ // Clang diverges from GCC's behavior. -+ addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + -+ OSLibDir + SelectedMultilib.osSuffix(), -+ Paths); -+ -+ // If the GCC installation we found is inside of the sysroot, we want to -+ // prefer libraries installed in the parent prefix of the GCC installation. -+ // It is important to *not* use these paths when the GCC installation is -+ // outside of the system root as that can pick up unintended libraries. -+ // This usually happens when there is an external cross compiler on the -+ // host system, and a more minimal sysroot available that is the target of -+ // the cross. Note that GCC does include some of these directories in some -+ // configurations but this seems somewhere between questionable and simply -+ // a bug. -+ if (StringRef(LibPath).startswith(SysRoot)) { -+ addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths); -+ addPathIfExists(D, LibPath + "/../" + OSLibDir, 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)) { -@@ -85,8 +175,40 @@ Hurd::Hurd(const Driver &D, const llvm:: +--- 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); @@ -159,7 +49,7 @@ Index: llvm-toolchain-9-9.0.0/clang/lib/Driver/ToolChains/Hurd.cpp // 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)) -@@ -153,6 +275,17 @@ void Hurd::AddClangSystemIncludeArgs(con +@@ -157,6 +189,17 @@ void Hurd::AddClangSystemIncludeArgs(con // Lacking those, try to detect the correct set of system includes for the // target triple.