From 9fb73635a7a2f9b6f6da07bdf165939aa453f481 Mon Sep 17 00:00:00 2001 From: Gianfranco Costamagna Date: Thu, 19 Jan 2023 09:03:54 +0100 Subject: [PATCH 01/15] update changelog --- debian/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index 61f5a357..a9e6c011 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium * Adjust some lintian overrides * Disable flang on s390x. Seems that it is breaking + + [ Gianfranco Costamagna ] * Update print lldb python patch, following what was done in automake for newer python From 86944b9db1c1a7afff36f82f59be9439c702db76 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 31 Jan 2023 23:19:06 +0100 Subject: [PATCH 02/15] Fix disabling amdgpu on non-Linux --- debian/changelog | 3 +++ debian/patches/amdgpu-nonlinux.patch | 20 ++++++++++++++++++++ debian/patches/series | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 debian/patches/amdgpu-nonlinux.patch diff --git a/debian/changelog b/debian/changelog index a9e6c011..16191b65 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium * Update print lldb python patch, following what was done in automake for newer python + [ Samuel Thibault ] + * Fix disabling amdgpu on non-Linux. + -- Sylvestre Ledru Sun, 15 Jan 2023 10:54:41 +0100 llvm-toolchain-15 (1:15.0.7-1) unstable; urgency=medium diff --git a/debian/patches/amdgpu-nonlinux.patch b/debian/patches/amdgpu-nonlinux.patch new file mode 100644 index 00000000..2c0098ed --- /dev/null +++ b/debian/patches/amdgpu-nonlinux.patch @@ -0,0 +1,20 @@ +https://reviews.llvm.org/D143017 + +[Libomptarget] Fix disabling amdgpu on non-Linux. + +Previously, on non-Linux, amdgpu would get enabled whatever the CPU +architecture. + +Index: llvm-toolchain-15-15.0.7/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt +=================================================================== +--- llvm-toolchain-15-15.0.7.orig/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt ++++ llvm-toolchain-15-15.0.7/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt +@@ -27,7 +27,7 @@ if(NOT LIBOMPTARGET_DEP_LIBELF_FOUND) + return() + endif() + +-if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux") ++if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux")) + libomptarget_say("Not building AMDGPU plugin: only support AMDGPU in Linux x86_64, ppc64le, or aarch64 hosts") + return() + endif() diff --git a/debian/patches/series b/debian/patches/series index bee43cb8..b918a51a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -158,3 +158,5 @@ protobuf_3.21.patch add-arm-vcmpz-test.patch fix-mesa-build.patch link-grpc.diff + +amdgpu-nonlinux.patch From 0af59c9be3e5ce1ecf902371ed3d9d0e006bc6ff Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Fri, 17 Feb 2023 17:33:38 +0100 Subject: [PATCH 03/15] Don't run chrpath for libclang on powerpc and powerpcspe --- debian/changelog | 3 +++ debian/rules | 2 ++ 2 files changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index 16191b65..0e13d098 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,9 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium [ Samuel Thibault ] * Fix disabling amdgpu on non-Linux. + [ John Paul Adrian Glaubitz ] + * Don't run chrpath for libclang on powerpc and powerpcspe + -- Sylvestre Ledru Sun, 15 Jan 2023 10:54:41 +0100 llvm-toolchain-15 (1:15.0.7-1) unstable; urgency=medium diff --git a/debian/rules b/debian/rules index d6400d17..0432f5ff 100755 --- a/debian/rules +++ b/debian/rules @@ -988,8 +988,10 @@ override_dh_auto_install: # Only run on executable, not script chrpath -d `find $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/ -type f -executable -exec file -i '{}' \; | grep 'x-executable; charset=binary'|cut -d: -f1` +ifeq (,$(filter $(DEB_HOST_ARCH), powerpc powerpcspe)) # To fix custom-library-search-path chrpath -d $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION)*/lib/linux/*.so +endif : # libclang cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/ && \ From 020513f6164f6574ec725d363dd0017788679d21 Mon Sep 17 00:00:00 2001 From: Cordell Bloor Date: Wed, 8 Mar 2023 12:50:40 -0700 Subject: [PATCH 04/15] Backport support for HIP in /usr --- debian/changelog | 3 + debian/patches/amdgpu-usr-search-paths.patch | 123 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 127 insertions(+) create mode 100644 debian/patches/amdgpu-usr-search-paths.patch diff --git a/debian/changelog b/debian/changelog index 0e13d098..1a4c0843 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,9 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium [ John Paul Adrian Glaubitz ] * Don't run chrpath for libclang on powerpc and powerpcspe + [ Cordell Bloor ] + * Backport support for HIP in /usr + -- Sylvestre Ledru Sun, 15 Jan 2023 10:54:41 +0100 llvm-toolchain-15 (1:15.0.7-1) unstable; urgency=medium diff --git a/debian/patches/amdgpu-usr-search-paths.patch b/debian/patches/amdgpu-usr-search-paths.patch new file mode 100644 index 00000000..9006a853 --- /dev/null +++ b/debian/patches/amdgpu-usr-search-paths.patch @@ -0,0 +1,123 @@ +From 082593ff7aff68060bd66dccfa43493d07d9c255 Mon Sep 17 00:00:00 2001 +From: "Yaxun (Sam) Liu" +Date: Tue, 11 Oct 2022 18:53:59 -0400 +Subject: [PATCH] [HIP] Detect HIP for Debian/Fedora + +HIP is installed at /usr or /usr/local on Debin/Fedora, +and the version file is at {root}/share/hip/version. + +Reviewed by: Artem Belevich + +Differential Revision: https://reviews.llvm.org/D135796 +--- + clang/lib/Driver/ToolChains/AMDGPU.cpp | 42 ++++++++++++++++++++------ + clang/lib/Driver/ToolChains/ROCm.h | 1 + + clang/test/Driver/hip-version.hip | 8 +++++ + 3 files changed, 41 insertions(+), 10 deletions(-) + +diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp +index 6246568710916..261594171564e 100644 +--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp +@@ -10,12 +10,14 @@ + #include "CommonArgs.h" + #include "clang/Basic/TargetID.h" + #include "clang/Driver/Compilation.h" ++#include "clang/Driver/Distro.h" + #include "clang/Driver/DriverDiagnostic.h" + #include "clang/Driver/InputInfo.h" + #include "clang/Driver/Options.h" + #include "llvm/Option/ArgList.h" + #include "llvm/Support/Error.h" + #include "llvm/Support/FileUtilities.h" ++#include "llvm/Support/Host.h" + #include "llvm/Support/LineIterator.h" + #include "llvm/Support/Path.h" + #include "llvm/Support/VirtualFileSystem.h" +@@ -306,6 +308,14 @@ RocmInstallationDetector::getInstallationPathCandidates() { + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); + ++ Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple())); ++ if (Dist.IsDebian() || Dist.IsRedhat()) { ++ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", ++ /*StrictChecking=*/true); ++ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", ++ /*StrictChecking=*/true); ++ } ++ + DoPrintROCmSearchDirs(); + return ROCmSearchDirs; + } +@@ -461,18 +471,30 @@ void RocmInstallationDetector::detectHIPRuntime() { + llvm::sys::path::append(IncludePath, "include"); + LibPath = InstallPath; + llvm::sys::path::append(LibPath, "lib"); +- +- llvm::ErrorOr> VersionFile = +- FS.getBufferForFile(BinPath + "/.hipVersion"); +- if (!VersionFile && Candidate.StrictChecking) +- continue; +- +- if (HIPVersionArg.empty() && VersionFile) +- if (parseHIPVersionFile((*VersionFile)->getBuffer())) ++ SharePath = InstallPath; ++ llvm::sys::path::append(SharePath, "share"); ++ ++ // If HIP version file can be found and parsed, use HIP version from there. ++ for (const auto &VersionFilePath : ++ {std::string(SharePath) + "/hip/version", ++ std::string(BinPath) + "/.hipVersion"}) { ++ llvm::ErrorOr> VersionFile = ++ FS.getBufferForFile(VersionFilePath); ++ if (!VersionFile) + continue; ++ if (HIPVersionArg.empty() && VersionFile) ++ if (parseHIPVersionFile((*VersionFile)->getBuffer())) ++ continue; + +- HasHIPRuntime = true; +- return; ++ HasHIPRuntime = true; ++ return; ++ } ++ // Otherwise, if -rocm-path is specified (no strict checking), use the ++ // default HIP version or specified by --hip-version. ++ if (!Candidate.StrictChecking) { ++ HasHIPRuntime = true; ++ return; ++ } + } + HasHIPRuntime = false; + } +diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h +index 33baaa887043e..b16deecdebec5 100644 +--- a/clang/lib/Driver/ToolChains/ROCm.h ++++ b/clang/lib/Driver/ToolChains/ROCm.h +@@ -107,6 +107,7 @@ class RocmInstallationDetector { + SmallString<0> LibPath; + SmallString<0> LibDevicePath; + SmallString<0> IncludePath; ++ SmallString<0> SharePath; + llvm::StringMap LibDeviceMap; + + // Libraries that are always linked. +diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip +index a9bac813a9195..4ef9e4ade0881 100644 +--- a/clang/test/Driver/hip-version.hip ++++ b/clang/test/Driver/hip-version.hip +@@ -9,6 +9,14 @@ + // RUN: --target=amdgcn-amd-amdhsa \ + // RUN: | FileCheck -check-prefixes=FOUND %s + ++// RUN: rm -rf %t/Inputs ++// RUN: mkdir -p %t/Inputs ++// RUN: cp -r %S/Inputs/rocm %t/Inputs ++// RUN: mkdir -p %t/Inputs/rocm/share/hip ++// RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version ++// RUN: %clang -v --rocm-path=%t/Inputs/rocm 2>&1 \ ++// RUN: | FileCheck -check-prefixes=FOUND %s ++ + // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd + + // When --rocm-path is set and .hipVersion is not found, use default version diff --git a/debian/patches/series b/debian/patches/series index b918a51a..7961162d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -160,3 +160,4 @@ fix-mesa-build.patch link-grpc.diff amdgpu-nonlinux.patch +amdgpu-usr-search-paths.patch From 8bbef9430567a15dea3c4cd09d79f1d7497135b7 Mon Sep 17 00:00:00 2001 From: Cordell Bloor Date: Thu, 9 Mar 2023 00:56:25 -0700 Subject: [PATCH 05/15] Add Debian paths for rocm-device-libs to search list --- debian/changelog | 3 +- debian/patches/amdgpu-bitcode-multiarch.patch | 60 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 debian/patches/amdgpu-bitcode-multiarch.patch diff --git a/debian/changelog b/debian/changelog index 1a4c0843..daadbcc8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,7 +14,8 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium * Don't run chrpath for libclang on powerpc and powerpcspe [ Cordell Bloor ] - * Backport support for HIP in /usr + * Backport support for HIP in /usr and add Debian paths + for rocm-device-libs to search list (Closes: #1031808) -- Sylvestre Ledru Sun, 15 Jan 2023 10:54:41 +0100 diff --git a/debian/patches/amdgpu-bitcode-multiarch.patch b/debian/patches/amdgpu-bitcode-multiarch.patch new file mode 100644 index 00000000..b2a1cd06 --- /dev/null +++ b/debian/patches/amdgpu-bitcode-multiarch.patch @@ -0,0 +1,60 @@ +From efa9394d72968e0c84c2c9283476c70807f60b80 Mon Sep 17 00:00:00 2001 +From: Cordell Bloor +Date: Wed, 8 Mar 2023 02:57:51 -0700 +Subject: [PATCH] Search for the bitcode libraries in a multiarch directory + +The Debian path for the rocm-device-libs is +/usr/lib/$(DEB_HOST_MULTIARCH)/amdgcn/bitcode + +Forwarded: not-needed +--- + clang/lib/Driver/ToolChains/AMDGPU.cpp | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp +index f20b28a66c67..2e8e56b39ff6 100644 +--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp +@@ -14,9 +14,11 @@ + #include "clang/Driver/DriverDiagnostic.h" + #include "clang/Driver/InputInfo.h" + #include "clang/Driver/Options.h" ++#include "llvm/ADT/Triple.h" + #include "llvm/Option/ArgList.h" + #include "llvm/Support/Error.h" + #include "llvm/Support/FileUtilities.h" ++#include "llvm/Support/Host.h" + #include "llvm/Support/LineIterator.h" + #include "llvm/Support/Path.h" + #include "llvm/Support/VirtualFileSystem.h" +@@ -422,16 +424,21 @@ void RocmInstallationDetector::detectDeviceLibrary() { + // The possible structures are: + // - ${ROCM_ROOT}/amdgcn/bitcode/* + // - ${ROCM_ROOT}/lib/* ++ // - ${ROCM_ROOT}/lib//amdgcn/bitcode/* + // - ${ROCM_ROOT}/lib/bitcode/* +- // so try to detect these layouts. +- static constexpr std::array SubDirsList[] = { +- {"amdgcn", "bitcode"}, +- {"lib", ""}, +- {"lib", "bitcode"}, ++ // so try to detect these layouts. Note that bitcode is associated with the ++ // compiler that built it (not the target architecture). ++ llvm::Triple HostTriple(llvm::sys::getProcessTriple()); ++ std::string Multiarch = Twine(HostTriple.getArchName() + "-linux-gnu").str(); ++ static const std::array SubDirsList[] = { ++ {"amdgcn", "bitcode", "", ""}, ++ {"lib", "", "", ""}, ++ {"lib", Multiarch, "amdgcn", "bitcode"}, ++ {"lib", "bitcode", "", ""}, + }; + + // Make a path by appending sub-directories to InstallPath. +- auto MakePath = [&](const llvm::ArrayRef &SubDirs) { ++ auto MakePath = [&](const llvm::ArrayRef &SubDirs) { + auto Path = CandidatePath; + for (auto SubDir : SubDirs) + llvm::sys::path::append(Path, SubDir); +-- +2.39.2 + diff --git a/debian/patches/series b/debian/patches/series index 7961162d..52067f5f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -161,3 +161,4 @@ link-grpc.diff amdgpu-nonlinux.patch amdgpu-usr-search-paths.patch +amdgpu-bitcode-multiarch.patch From 787cd5c4400f8991862141b301376a95cbf7e3a3 Mon Sep 17 00:00:00 2001 From: Cordell Bloor Date: Thu, 9 Mar 2023 01:53:43 -0700 Subject: [PATCH 06/15] d/qualify-clang.sh: add test for hip-lang --- debian/qualify-clang.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 1804077f..d0e300fa 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -1665,6 +1665,18 @@ if test ! -f /usr/lib/llvm-$VERSION/lib/libclangBasic.a; then exit 1 fi +# check that the hip language is functioning +echo "Testing HIP language ..." +echo "if this fails, please run" +echo "apt-get install hipcc" +if test $VERSION -eq 15; then + cat > foo.hip < +int main() { return 0; } +EOF + clang++-15 -x hip -lamdhip64 foo.hip +fi + #clean up rm -f a.out bar crash-* foo foo.* lldb-cmd.txt main.* test_fuzzer.cc foo.* o rm -rf output matmul.* *profraw opt.ll a.json default.profdata test test.cpp From c7394d42a6efb9b0ccd35002364dc59b77f73bd3 Mon Sep 17 00:00:00 2001 From: Cordell Bloor Date: Thu, 9 Mar 2023 02:32:15 -0700 Subject: [PATCH 07/15] Move amdgpu patches to their own subdirectory --- .../bitcode-multiarch.patch} | 0 .../{amdgpu-nonlinux.patch => amdgpu/nonlinux.patch} | 0 .../usr-search-paths.patch} | 0 debian/patches/series | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename debian/patches/{amdgpu-bitcode-multiarch.patch => amdgpu/bitcode-multiarch.patch} (100%) rename debian/patches/{amdgpu-nonlinux.patch => amdgpu/nonlinux.patch} (100%) rename debian/patches/{amdgpu-usr-search-paths.patch => amdgpu/usr-search-paths.patch} (100%) diff --git a/debian/patches/amdgpu-bitcode-multiarch.patch b/debian/patches/amdgpu/bitcode-multiarch.patch similarity index 100% rename from debian/patches/amdgpu-bitcode-multiarch.patch rename to debian/patches/amdgpu/bitcode-multiarch.patch diff --git a/debian/patches/amdgpu-nonlinux.patch b/debian/patches/amdgpu/nonlinux.patch similarity index 100% rename from debian/patches/amdgpu-nonlinux.patch rename to debian/patches/amdgpu/nonlinux.patch diff --git a/debian/patches/amdgpu-usr-search-paths.patch b/debian/patches/amdgpu/usr-search-paths.patch similarity index 100% rename from debian/patches/amdgpu-usr-search-paths.patch rename to debian/patches/amdgpu/usr-search-paths.patch diff --git a/debian/patches/series b/debian/patches/series index 52067f5f..af7b175a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -159,6 +159,6 @@ add-arm-vcmpz-test.patch fix-mesa-build.patch link-grpc.diff -amdgpu-nonlinux.patch -amdgpu-usr-search-paths.patch -amdgpu-bitcode-multiarch.patch +amdgpu/nonlinux.patch +amdgpu/usr-search-paths.patch +amdgpu/bitcode-multiarch.patch From 10acff747eff84d1fcf8b5ca77bb4ae0268587d3 Mon Sep 17 00:00:00 2001 From: Faidon Liambotis Date: Thu, 9 Mar 2023 19:48:23 +0200 Subject: [PATCH 08/15] Remove debian/patches/wasm-*, old cruft from a mv Commit 2084cb7 moved the wasm patches to debian/patches/wasm/, but the older, now unused (not referenced in d/p/series) files remained behind on the three-way merge for the 15 branch. Remove them. --- debian/patches/wasm-compiler-rt-default.diff | 31 ---------- debian/patches/wasm-sysroot-usr.diff | 62 -------------------- 2 files changed, 93 deletions(-) delete mode 100644 debian/patches/wasm-compiler-rt-default.diff delete mode 100644 debian/patches/wasm-sysroot-usr.diff diff --git a/debian/patches/wasm-compiler-rt-default.diff b/debian/patches/wasm-compiler-rt-default.diff deleted file mode 100644 index 351fcc79..00000000 --- a/debian/patches/wasm-compiler-rt-default.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- a/clang/lib/Driver/ToolChains/WebAssembly.cpp -+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp -@@ -369,6 +369,18 @@ ToolChain::RuntimeLibType WebAssembly::G - return ToolChain::RLT_CompilerRT; - } - -+ToolChain::RuntimeLibType WebAssembly::GetRuntimeLibType( -+ const ArgList &Args) const { -+ if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) { -+ StringRef Value = A->getValue(); -+ if (Value != "compiler-rt") -+ getDriver().Diag(clang::diag::err_drv_unsupported_rtlib_for_platform) -+ << Value << "WebAssembly"; -+ } -+ -+ return ToolChain::RLT_CompilerRT; -+} -+ - ToolChain::CXXStdlibType - WebAssembly::GetCXXStdlibType(const ArgList &Args) const { - if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { ---- a/clang/lib/Driver/ToolChains/WebAssembly.h -+++ b/clang/lib/Driver/ToolChains/WebAssembly.h -@@ -61,6 +61,7 @@ private: - llvm::opt::ArgStringList &CC1Args, - Action::OffloadKind DeviceOffloadKind) const override; - RuntimeLibType GetDefaultRuntimeLibType() const override; -+ RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override; - CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; - void - AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, diff --git a/debian/patches/wasm-sysroot-usr.diff b/debian/patches/wasm-sysroot-usr.diff deleted file mode 100644 index ae73057b..00000000 --- a/debian/patches/wasm-sysroot-usr.diff +++ /dev/null @@ -1,62 +0,0 @@ ---- a/clang/lib/Driver/ToolChains/WebAssembly.cpp -+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp -@@ -174,7 +174,7 @@ WebAssembly::WebAssembly(const Driver &D - - getProgramPaths().push_back(getDriver().getInstalledDir()); - -- auto SysRoot = getDriver().SysRoot; -+ std::string SysRoot = computeSysRoot(); - if (getTriple().getOS() == llvm::Triple::UnknownOS) { - // Theoretically an "unknown" OS should mean no standard libraries, however - // it could also mean that a custom set of libraries is in use, so just add -@@ -402,6 +402,7 @@ void WebAssembly::AddClangSystemIncludeA - return; - - const Driver &D = getDriver(); -+ std::string SysRoot = computeSysRoot(); - - if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { - SmallString<128> P(D.ResourceDir); -@@ -427,10 +428,10 @@ void WebAssembly::AddClangSystemIncludeA - - if (getTriple().getOS() != llvm::Triple::UnknownOS) { - const std::string MultiarchTriple = -- getMultiarchTriple(D, getTriple(), D.SysRoot); -- addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include/" + MultiarchTriple); -+ getMultiarchTriple(D, getTriple(), SysRoot); -+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include/" + MultiarchTriple); - } -- addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include"); -+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include"); - } - - void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, -@@ -478,6 +479,17 @@ Tool *WebAssembly::buildLinker() const { - return new tools::wasm::Linker(*this); - } - -+std::string WebAssembly::computeSysRoot() const { -+ if (!getDriver().SysRoot.empty()) -+ return getDriver().SysRoot; -+ -+ std::string Path = "/usr"; -+ if (getVFS().exists(Path)) -+ return Path; -+ -+ return std::string(); -+} -+ - void WebAssembly::addLibCxxIncludePaths( - const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const { ---- a/clang/lib/Driver/ToolChains/WebAssembly.h -+++ b/clang/lib/Driver/ToolChains/WebAssembly.h -@@ -89,6 +89,8 @@ private: - llvm::opt::ArgStringList &CC1Args) const; - void addLibStdCXXIncludePaths(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const; -+ -+ std::string computeSysRoot() const override; - }; - - } // end namespace toolchains From 14ef8ad6b575f8b262b944c006935cb3870bfd0a Mon Sep 17 00:00:00 2001 From: Faidon Liambotis Date: Thu, 9 Mar 2023 19:53:49 +0200 Subject: [PATCH 09/15] Update wasm-sysroot-usr.diff to fix #1029010 Update the wasm-sysroot-usr.diff patch to restore functionality that was accidentally dropped when the patch was forward-ported from 14 to 15. This resolves an issue in which clang++ builds would fail if libc++-15-dev was installed alongside libc++-15-dev-wasm32. This issue was rightfully caught in the autopkgtests, and has prevented the package from migrating to testing, something that should hopefully be resolved now. Closes: #1029010, #1032317 --- debian/changelog | 7 ++++++ debian/patches/wasm/wasm-sysroot-usr.diff | 27 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/debian/changelog b/debian/changelog index 0e13d098..663a6dac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium + [ Sylvestre Ledru ] * Adjust some lintian overrides * Disable flang on s390x. Seems that it is breaking @@ -13,6 +14,12 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium [ John Paul Adrian Glaubitz ] * Don't run chrpath for libclang on powerpc and powerpcspe + [ Faidon Liambotis ] + * Update the wasm-sysroot-usr.diff patch to restore functionality that was + accidentally dropped when the patch was forward-ported from 14 to 15. This + resolves an issue in which clang++ builds would fail if libc++-15-dev was + installed alongside libc++-15-dev-wasm32. (Closes: #1029010, #1032317) + -- Sylvestre Ledru Sun, 15 Jan 2023 10:54:41 +0100 llvm-toolchain-15 (1:15.0.7-1) unstable; urgency=medium diff --git a/debian/patches/wasm/wasm-sysroot-usr.diff b/debian/patches/wasm/wasm-sysroot-usr.diff index e3270aa2..6587c1bd 100644 --- a/debian/patches/wasm/wasm-sysroot-usr.diff +++ b/debian/patches/wasm/wasm-sysroot-usr.diff @@ -57,6 +57,33 @@ void WebAssembly::addLibCxxIncludePaths( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { +@@ -499,7 +519,9 @@ void WebAssembly::addLibCxxIncludePaths( + } + + // Second add the generic one. +- addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version); ++ // don't include the host architecture's headers in the search path ++ if (!getDriver().SysRoot.empty()) ++ addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version); + } + + void WebAssembly::addLibStdCXXIncludePaths( +@@ -546,8 +568,11 @@ void WebAssembly::addLibStdCXXIncludePat + addSystemInclude(DriverArgs, CC1Args, TargetDir); + } + +- // Second add the generic one. +- addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version); +- // Third the backward one. +- addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward"); ++ // don't include the host architecture's headers in the search path ++ if (!getDriver().SysRoot.empty()) { ++ // Second add the generic one. ++ addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version); ++ // Third the backward one. ++ addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward"); ++ } + } --- a/clang/lib/Driver/ToolChains/WebAssembly.h +++ b/clang/lib/Driver/ToolChains/WebAssembly.h @@ -89,6 +89,8 @@ private: From fba26ac2f1a1f83c398ef2b86812fb415a598980 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 10 Mar 2023 19:01:21 +0100 Subject: [PATCH 10/15] fix conflicts --- debian/changelog | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3aa32961..86f2278b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,5 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium -<<<<<<< [ Sylvestre Ledru ] * Adjust some lintian overrides * Disable flang on s390x. Seems that it is breaking @@ -20,24 +19,10 @@ llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium accidentally dropped when the patch was forward-ported from 14 to 15. This resolves an issue in which clang++ builds would fail if libc++-15-dev was installed alongside libc++-15-dev-wasm32. (Closes: #1029010, #1032317) -======= - * Adjust some lintian overrides - * Disable flang on s390x. Seems that it is breaking - - [ Gianfranco Costamagna ] - * Update print lldb python patch, following what was done - in automake for newer python - - [ Samuel Thibault ] - * Fix disabling amdgpu on non-Linux. - - [ John Paul Adrian Glaubitz ] - * Don't run chrpath for libclang on powerpc and powerpcspe [ Cordell Bloor ] * Backport support for HIP in /usr and add Debian paths for rocm-device-libs to search list (Closes: #1031808) ->>>>>>> -- Sylvestre Ledru Sun, 15 Jan 2023 10:54:41 +0100 From 14ad9dd6d5f594efdcc91d89e11cf6c08b03bd16 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 10 Mar 2023 21:40:50 +0100 Subject: [PATCH 11/15] hip: don't hardcode the version --- debian/qualify-clang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index d0e300fa..ca333a71 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -1674,7 +1674,7 @@ if test $VERSION -eq 15; then #include int main() { return 0; } EOF - clang++-15 -x hip -lamdhip64 foo.hip + clang++-$VERSION -x hip -lamdhip64 foo.hip fi #clean up From 57695b959bfb11171756646322f4dd4e145b1c92 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 10 Mar 2023 21:42:02 +0100 Subject: [PATCH 12/15] hip: fix the test --- debian/qualify-clang.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index ca333a71..decb6082 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -1667,14 +1667,13 @@ fi # check that the hip language is functioning echo "Testing HIP language ..." -echo "if this fails, please run" -echo "apt-get install hipcc" -if test $VERSION -eq 15; then +if dpkg -l|grep -q hipcc; then cat > foo.hip < int main() { return 0; } EOF clang++-$VERSION -x hip -lamdhip64 foo.hip + rm -f foo.hip hip fi #clean up From 7e4d599aa88e360593c9f03b174e9ad1614d02c8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 10 Mar 2023 19:15:57 +0100 Subject: [PATCH 13/15] rebase of the patch --- debian/patches/amdgpu/bitcode-multiarch.patch | 19 +++------ debian/patches/amdgpu/usr-search-paths.patch | 39 +++++++++---------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/debian/patches/amdgpu/bitcode-multiarch.patch b/debian/patches/amdgpu/bitcode-multiarch.patch index b2a1cd06..88e2ef55 100644 --- a/debian/patches/amdgpu/bitcode-multiarch.patch +++ b/debian/patches/amdgpu/bitcode-multiarch.patch @@ -11,11 +11,11 @@ Forwarded: not-needed clang/lib/Driver/ToolChains/AMDGPU.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp -index f20b28a66c67..2e8e56b39ff6 100644 ---- a/clang/lib/Driver/ToolChains/AMDGPU.cpp -+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp -@@ -14,9 +14,11 @@ +Index: llvm-toolchain-15-15.0.7/clang/lib/Driver/ToolChains/AMDGPU.cpp +=================================================================== +--- llvm-toolchain-15-15.0.7.orig/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ llvm-toolchain-15-15.0.7/clang/lib/Driver/ToolChains/AMDGPU.cpp +@@ -14,6 +14,7 @@ #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/InputInfo.h" #include "clang/Driver/Options.h" @@ -23,11 +23,7 @@ index f20b28a66c67..2e8e56b39ff6 100644 #include "llvm/Option/ArgList.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileUtilities.h" -+#include "llvm/Support/Host.h" - #include "llvm/Support/LineIterator.h" - #include "llvm/Support/Path.h" - #include "llvm/Support/VirtualFileSystem.h" -@@ -422,16 +424,21 @@ void RocmInstallationDetector::detectDeviceLibrary() { +@@ -423,16 +424,21 @@ void RocmInstallationDetector::detectDev // The possible structures are: // - ${ROCM_ROOT}/amdgcn/bitcode/* // - ${ROCM_ROOT}/lib/* @@ -55,6 +51,3 @@ index f20b28a66c67..2e8e56b39ff6 100644 auto Path = CandidatePath; for (auto SubDir : SubDirs) llvm::sys::path::append(Path, SubDir); --- -2.39.2 - diff --git a/debian/patches/amdgpu/usr-search-paths.patch b/debian/patches/amdgpu/usr-search-paths.patch index 9006a853..96e21c1f 100644 --- a/debian/patches/amdgpu/usr-search-paths.patch +++ b/debian/patches/amdgpu/usr-search-paths.patch @@ -15,10 +15,10 @@ Differential Revision: https://reviews.llvm.org/D135796 clang/test/Driver/hip-version.hip | 8 +++++ 3 files changed, 41 insertions(+), 10 deletions(-) -diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp -index 6246568710916..261594171564e 100644 ---- a/clang/lib/Driver/ToolChains/AMDGPU.cpp -+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp +Index: llvm-toolchain-15-15.0.7/clang/lib/Driver/ToolChains/AMDGPU.cpp +=================================================================== +--- llvm-toolchain-15-15.0.7.orig/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ llvm-toolchain-15-15.0.7/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -10,12 +10,14 @@ #include "CommonArgs.h" #include "clang/Basic/TargetID.h" @@ -34,7 +34,7 @@ index 6246568710916..261594171564e 100644 #include "llvm/Support/LineIterator.h" #include "llvm/Support/Path.h" #include "llvm/Support/VirtualFileSystem.h" -@@ -306,6 +308,14 @@ RocmInstallationDetector::getInstallationPathCandidates() { +@@ -306,6 +308,14 @@ RocmInstallationDetector::getInstallatio ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, /*StrictChecking=*/true); @@ -49,11 +49,13 @@ index 6246568710916..261594171564e 100644 DoPrintROCmSearchDirs(); return ROCmSearchDirs; } -@@ -461,18 +471,30 @@ void RocmInstallationDetector::detectHIPRuntime() { +@@ -461,18 +471,30 @@ void RocmInstallationDetector::detectHIP llvm::sys::path::append(IncludePath, "include"); LibPath = InstallPath; llvm::sys::path::append(LibPath, "lib"); -- ++ SharePath = InstallPath; ++ llvm::sys::path::append(SharePath, "share"); + - llvm::ErrorOr> VersionFile = - FS.getBufferForFile(BinPath + "/.hipVersion"); - if (!VersionFile && Candidate.StrictChecking) @@ -61,9 +63,6 @@ index 6246568710916..261594171564e 100644 - - if (HIPVersionArg.empty() && VersionFile) - if (parseHIPVersionFile((*VersionFile)->getBuffer())) -+ SharePath = InstallPath; -+ llvm::sys::path::append(SharePath, "share"); -+ + // If HIP version file can be found and parsed, use HIP version from there. + for (const auto &VersionFilePath : + {std::string(SharePath) + "/hip/version", @@ -90,11 +89,11 @@ index 6246568710916..261594171564e 100644 } HasHIPRuntime = false; } -diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h -index 33baaa887043e..b16deecdebec5 100644 ---- a/clang/lib/Driver/ToolChains/ROCm.h -+++ b/clang/lib/Driver/ToolChains/ROCm.h -@@ -107,6 +107,7 @@ class RocmInstallationDetector { +Index: llvm-toolchain-15-15.0.7/clang/lib/Driver/ToolChains/ROCm.h +=================================================================== +--- llvm-toolchain-15-15.0.7.orig/clang/lib/Driver/ToolChains/ROCm.h ++++ llvm-toolchain-15-15.0.7/clang/lib/Driver/ToolChains/ROCm.h +@@ -107,6 +107,7 @@ private: SmallString<0> LibPath; SmallString<0> LibDevicePath; SmallString<0> IncludePath; @@ -102,12 +101,12 @@ index 33baaa887043e..b16deecdebec5 100644 llvm::StringMap LibDeviceMap; // Libraries that are always linked. -diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip -index a9bac813a9195..4ef9e4ade0881 100644 ---- a/clang/test/Driver/hip-version.hip -+++ b/clang/test/Driver/hip-version.hip +Index: llvm-toolchain-15-15.0.7/clang/test/Driver/hip-version.hip +=================================================================== +--- llvm-toolchain-15-15.0.7.orig/clang/test/Driver/hip-version.hip ++++ llvm-toolchain-15-15.0.7/clang/test/Driver/hip-version.hip @@ -9,6 +9,14 @@ - // RUN: --target=amdgcn-amd-amdhsa \ + // RUN: -target amdgcn-amd-amdhsa \ // RUN: | FileCheck -check-prefixes=FOUND %s +// RUN: rm -rf %t/Inputs From 0382d978c5b658bdc2d2898eef1b1954d24fd9f3 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 10 Mar 2023 19:20:06 +0100 Subject: [PATCH 14/15] Yeah, we would like to have this version in bookworm (Closes: #1032316) --- debian/changelog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 86f2278b..976f0c75 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ -llvm-toolchain-15 (1:15.0.7-2) UNRELEASED; urgency=medium +llvm-toolchain-15 (1:15.0.7-2) unstable; urgency=medium [ Sylvestre Ledru ] + * Yeah, we would like to have this version in bookworm + (Closes: #1032316) * Adjust some lintian overrides * Disable flang on s390x. Seems that it is breaking From 33f02a8a945a14636661799fcf823048e8ac09b7 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 10 Mar 2023 21:54:01 +0100 Subject: [PATCH 15/15] add --rocm-path=/usr as it is necessary --- debian/qualify-clang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index decb6082..f247d0e5 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -1672,7 +1672,7 @@ if dpkg -l|grep -q hipcc; then #include int main() { return 0; } EOF - clang++-$VERSION -x hip -lamdhip64 foo.hip + clang++-$VERSION --rocm-path=/usr -x hip -lamdhip64 foo.hip rm -f foo.hip hip fi