nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchpatch,
5 cmake,
6 llvm,
7 python3,
8 rocm-device-libs,
9 zlib,
10 zstd,
11}:
12
13let
14 llvmNativeTarget =
15 if stdenv.hostPlatform.isx86_64 then
16 "X86"
17 else if stdenv.hostPlatform.isAarch64 then
18 "AArch64"
19 else
20 throw "Unsupported ROCm LLVM platform";
21in
22stdenv.mkDerivation (finalAttrs: {
23 pname = "rocm-comgr";
24 # In-tree with ROCm LLVM
25 inherit (llvm.llvm) version;
26 src = llvm.llvm.monorepoSrc;
27 sourceRoot = "${finalAttrs.src.name}/amd/comgr";
28 strictDeps = true;
29
30 patches = [
31 # [Comgr] Extend ISA compatibility
32 (fetchpatch {
33 sha256 = "sha256-dgow0kwSWM1TnkqWOZDRQrh5nuF8p5jbYyOLCpQsH4k=";
34 url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/a439e4f37ce71de48d4a979594276e3be0e6278f.patch";
35 relative = "amd/comgr";
36 })
37 #[Comgr] Extend ISA compatibility for CCOB
38 (fetchpatch {
39 sha256 = "sha256-PCi0QHLiEQCTIYRtSSbhOjXANJ3zC3VLdMED1BEfQeg=";
40 url = "https://github.com/GZGavinZhao/rocm-llvm-project/commit/fa80abb77d5ae6f8d89ab956e7ebda9c802a804f.patch";
41 relative = "amd/comgr";
42 })
43 ];
44
45 postPatch = ''
46 substituteInPlace cmake/opencl_pch.cmake \
47 --replace-fail "\''${CLANG_CMAKE_DIR}/../../../" "${llvm.clang-unwrapped.lib}"
48 '';
49
50 nativeBuildInputs = [
51 cmake
52 python3
53 ];
54
55 buildInputs = [
56 llvm.llvm
57 llvm.clang-unwrapped
58 llvm.lld
59 rocm-device-libs
60 zlib
61 zstd
62 ];
63
64 cmakeFlags = [
65 "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
66 ];
67
68 meta = {
69 description = "APIs for compiling and inspecting AMDGPU code objects";
70 homepage = "https://github.com/ROCm/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr";
71 license = lib.licenses.ncsa;
72 maintainers = with lib.maintainers; [ lovesegfault ];
73 teams = [ lib.teams.rocm ];
74 platforms = lib.platforms.linux;
75 };
76})