Merge branch '10' into '10'

patches/hurd/hurd-cxx-paths.diff: Refresh

See merge request pkg-llvm-team/llvm-toolchain!59
This commit is contained in:
Gianfranco Costamagna 2020-07-20 17:11:25 +00:00
commit ba68c9d75b
2 changed files with 22 additions and 75 deletions

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
llvm-toolchain-10 (1:10.0.1~+rc4-2) UNRELEASED; urgency=medium
* patches/hurd/hurd-cxx-paths.diff: Refresh, some of the factorization was
backported from 11 to 10.
-- Samuel Thibault <sthibault@debian.org> Tue, 07 Jul 2020 18:39:08 +0200
llvm-toolchain-10 (1:10.0.1~+rc4-1) unstable; urgency=medium
* New RC release (of course, I was wrong)

View File

@ -2,10 +2,13 @@ hurd: find c++ headers
This should be factorized with Linux.cpp and the GNU/kFreeBSD case.
Index: llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834/clang/lib/Driver/ToolChains/Hurd.cpp
===================================================================
--- llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834.orig/clang/lib/Driver/ToolChains/Hurd.cpp
+++ llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834/clang/lib/Driver/ToolChains/Hurd.cpp
---
clang/lib/Driver/ToolChains/Hurd.cpp | 146 ++++++++++++++++++++++++++++++++++-
clang/lib/Driver/ToolChains/Hurd.h | 3
2 files changed, 145 insertions(+), 4 deletions(-)
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -61,6 +61,15 @@ static StringRef getOSLibDir(const llvm:
return Triple.isArch32Bit() ? "lib" : "lib64";
}
@ -147,86 +150,28 @@ Index: llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834/clang/lib/Driver/To
if (getTriple().getArch() == llvm::Triple::x86) {
std::string Path = SysRoot + "/usr/include/i386-gnu";
if (D.getVFS().exists(Path))
@@ -174,3 +279,94 @@ void Hurd::addExtraOpts(llvm::opt::ArgSt
@@ -174,3 +279,36 @@ void Hurd::addExtraOpts(llvm::opt::ArgSt
for (const auto &Opt : ExtraOpts)
CmdArgs.push_back(Opt.c_str());
}
+
+static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs,
+ StringRef base) {
+ std::error_code EC;
+ int MaxVersion = 0;
+ std::string MaxVersionString = "";
+ for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+ !EC && LI != LE; LI = LI.increment(EC)) {
+ StringRef VersionText = llvm::sys::path::filename(LI->path());
+ int Version;
+ if (VersionText[0] == 'v' &&
+ !VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+ if (Version > MaxVersion) {
+ MaxVersion = Version;
+ MaxVersionString = VersionText;
+ }
+ }
+ }
+ return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
+}
+
+void Hurd::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ const std::string& SysRoot = computeSysRoot();
+ const std::string LibCXXIncludePathCandidates[] = {
+ DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
+ // If this is a development, non-installed, clang, libcxx will
+ // not be found at ../include/c++ but it likely to be found at
+ // one of the following two locations:
+ DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
+ DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
+ for (const auto &IncludePath : LibCXXIncludePathCandidates) {
+ if (IncludePath.empty() || !getVFS().exists(IncludePath))
+ continue;
+ // Use the first candidate that exists.
+ addSystemInclude(DriverArgs, CC1Args, IncludePath);
+ return;
+ }
+}
+
+void Hurd::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ // Try generic GCC detection first.
+ if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args))
+ return;
+
+ // We need a detected GCC installation on Hurd to provide libstdc++'s
+ // headers.
+ if (!GCCInstallation.isValid())
+ return;
+
+ // By default, look for the C++ headers in an include directory adjacent to
+ // the lib directory of the GCC installation. Note that this is expect to be
+ // equivalent to '/usr/include/c++/X.Y' in almost all cases.
+ StringRef LibDir = GCCInstallation.getParentLibPath();
+ StringRef InstallDir = GCCInstallation.getInstallPath();
+ StringRef TripleStr = GCCInstallation.getTriple().str();
+ const Multilib &Multilib = GCCInstallation.getMultilib();
+ const std::string GCCMultiarchTriple = getMultiarchTriple(
+ getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
+ const std::string TargetMultiarchTriple =
+ getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
+ const GCCVersion &Version = GCCInstallation.getVersion();
+
+ // The primary search for libstdc++ supports multiarch variants.
+ if (addLibStdCXXIncludePaths(LibDir.str() + "/../include",
+ "/c++/" + Version.Text, TripleStr,
+ GCCMultiarchTriple, TargetMultiarchTriple,
+ Multilib.includeSuffix(), DriverArgs, CC1Args))
+ return;
+
+ // Otherwise, fall back on a bunch of options which don't use multiarch
+ // layouts for simplicity.
+ const std::string LibStdCXXIncludePathCandidates[] = {
+ // Gentoo is weird and places its headers inside the GCC install,
+ // so if the first attempt to find the headers fails, try these patterns.
+ InstallDir.str() + "/include/g++-v" + Version.Text,
+ InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +
+ Version.MinorStr,
+ InstallDir.str() + "/include/g++-v" + Version.MajorStr,
+ // Android standalone toolchain has C++ headers in yet another place.
+ LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
+ // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
@ -242,17 +187,12 @@ Index: llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834/clang/lib/Driver/To
+ break;
+ }
+}
Index: llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834/clang/lib/Driver/ToolChains/Hurd.h
===================================================================
--- llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834.orig/clang/lib/Driver/ToolChains/Hurd.h
+++ llvm-toolchain-10_10.0.1~++20200502100653+d4d4c6bf834/clang/lib/Driver/ToolChains/Hurd.h
@@ -26,6 +26,12 @@ public:
--- a/clang/lib/Driver/ToolChains/Hurd.h
+++ b/clang/lib/Driver/ToolChains/Hurd.h
@@ -26,6 +26,9 @@ public:
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;
+ void addLibStdCxxIncludePaths(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;