blob: e7663a1f7130a47300da2ca35bed1a226e777d53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
{
lib,
stdenv,
fetchpatch,
cmake,
llvm,
python3,
rocm-device-libs,
zlib,
zstd,
}:
let
llvmNativeTarget =
if stdenv.hostPlatform.isx86_64 then
"X86"
else if stdenv.hostPlatform.isAarch64 then
"AArch64"
else
throw "Unsupported ROCm LLVM platform";
in
stdenv.mkDerivation (finalAttrs: {
pname = "rocm-comgr";
# In-tree with ROCm LLVM
inherit (llvm.llvm) version;
src = llvm.llvm.monorepoSrc;
sourceRoot = "${finalAttrs.src.name}/amd/comgr";
strictDeps = true;
patches = [
# [Comgr] Extend ISA compatibility
(fetchpatch {
hash = "sha256-X2VPGigK582J+a/u2Kg74w25/+CTpVWU9D3Eqgnb2PU=";
url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/7002dc04863d38c57cfd2e6fc60a1cf5a613fd8e.patch";
relative = "amd/comgr";
})
# [Comgr] Extend ISA compatibility for CCOB
(fetchpatch {
hash = "sha256-/50I+PqxL3oaQMqg5vR7+ibUcXO1SvfXBdw/sybRt1o=";
url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/2c1e44fc3eacadcafdd4ada3e3184a092b6f26c5.patch";
relative = "amd/comgr";
})
# Fix: CCOB compat patch used coerced (featureless) name for output filename,
# causing CLR's code_obj_map key to miss when looking up device ISA with features
./fix-ccob-compat-output-filename.patch
];
postPatch =
# Fix relative path assumption for libllvm
''
substituteInPlace cmake/opencl_header.cmake \
--replace-fail "\''${CLANG_CMAKE_DIR}/../../../" "${llvm.clang-unwrapped.lib}"
''
# Bake LLVM root for cfg/includes or HIPRTC can't find C++ stdlib headers (e.g. <type_traits>).
+ ''
substituteInPlace src/comgr-env.cpp \
--replace-fail \
'return EnvLLVMPath;' \
'return EnvLLVMPath ? EnvLLVMPath : "${llvm.rocm-toolchain}";'
'';
nativeBuildInputs = [
cmake
python3
];
buildInputs = [
llvm.llvm
llvm.clang-unwrapped
llvm.lld
rocm-device-libs
zlib
zstd
];
cmakeFlags = [
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
];
meta = {
description = "APIs for compiling and inspecting AMDGPU code objects";
homepage = "https://github.com/ROCm/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr";
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovesegfault ];
teams = [ lib.teams.rocm ];
platforms = lib.platforms.linux;
};
})
|