mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-06-26 18:21:46 +00:00
Merge branch 'llvm-toolchain-backport-amdgpu-usr-search-paths' into 15
This commit is contained in:
commit
fb55ca741f
19
debian/changelog
vendored
19
debian/changelog
vendored
@ -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
|
||||
@ -19,6 +20,24 @@ 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 <sylvestre@debian.org> Sun, 15 Jan 2023 10:54:41 +0100
|
||||
|
||||
|
60
debian/patches/amdgpu/bitcode-multiarch.patch
vendored
Normal file
60
debian/patches/amdgpu/bitcode-multiarch.patch
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
From efa9394d72968e0c84c2c9283476c70807f60b80 Mon Sep 17 00:00:00 2001
|
||||
From: Cordell Bloor <cgmb@slerp.xyz>
|
||||
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/<multiarch>/amdgcn/bitcode/*
|
||||
// - ${ROCM_ROOT}/lib/bitcode/*
|
||||
- // so try to detect these layouts.
|
||||
- static constexpr std::array<const char *, 2> 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<std::string, 4> SubDirsList[] = {
|
||||
+ {"amdgcn", "bitcode", "", ""},
|
||||
+ {"lib", "", "", ""},
|
||||
+ {"lib", Multiarch, "amdgcn", "bitcode"},
|
||||
+ {"lib", "bitcode", "", ""},
|
||||
};
|
||||
|
||||
// Make a path by appending sub-directories to InstallPath.
|
||||
- auto MakePath = [&](const llvm::ArrayRef<const char *> &SubDirs) {
|
||||
+ auto MakePath = [&](const llvm::ArrayRef<std::string> &SubDirs) {
|
||||
auto Path = CandidatePath;
|
||||
for (auto SubDir : SubDirs)
|
||||
llvm::sys::path::append(Path, SubDir);
|
||||
--
|
||||
2.39.2
|
||||
|
123
debian/patches/amdgpu/usr-search-paths.patch
vendored
Normal file
123
debian/patches/amdgpu/usr-search-paths.patch
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
From 082593ff7aff68060bd66dccfa43493d07d9c255 Mon Sep 17 00:00:00 2001
|
||||
From: "Yaxun (Sam) Liu" <yaxun.liu@amd.com>
|
||||
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<std::unique_ptr<llvm::MemoryBuffer>> 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<std::unique_ptr<llvm::MemoryBuffer>> 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<std::string> 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
|
4
debian/patches/series
vendored
4
debian/patches/series
vendored
@ -159,4 +159,6 @@ add-arm-vcmpz-test.patch
|
||||
fix-mesa-build.patch
|
||||
link-grpc.diff
|
||||
|
||||
amdgpu-nonlinux.patch
|
||||
amdgpu/nonlinux.patch
|
||||
amdgpu/usr-search-paths.patch
|
||||
amdgpu/bitcode-multiarch.patch
|
||||
|
12
debian/qualify-clang.sh
vendored
12
debian/qualify-clang.sh
vendored
@ -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 <<EOF
|
||||
#include <hip/hip_runtime_api.h>
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user