nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchpatch,
5 cmake,
6 ninja,
7 zlib,
8 zstd,
9 llvm,
10 python3,
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-device-libs";
24 # In-tree with ROCm LLVM
25 inherit (llvm.llvm) version;
26 src = llvm.llvm.monorepoSrc;
27 sourceRoot = "${finalAttrs.src.name}/amd/device-libs";
28 strictDeps = true;
29 __structuredAttrs = true;
30
31 postPatch =
32 # Use our sysrooted toolchain instead of direct clang target
33 ''
34 substituteInPlace cmake/OCL.cmake \
35 --replace-fail '$<TARGET_FILE:clang>' "${llvm.rocm-toolchain}/bin/clang"
36 '';
37
38 patches = [
39 ./cmake.patch
40 (fetchpatch {
41 name = "cmake-4-compat-dont-set-cmp0053.patch";
42 url = "https://github.com/ROCm/llvm-project/commit/a18cc4c7cb51f94182b6018c7c73acde1b8ebddb.patch";
43 hash = "sha256-kp/Ld0IhjWgRbRR9R/CKdkI9ELvPkQSAMqPsAPFxzhM=";
44 relative = "amd/device-libs";
45 })
46 ];
47
48 nativeBuildInputs = [
49 cmake
50 ninja
51 python3
52 llvm.rocm-toolchain
53 ];
54
55 buildInputs = [
56 llvm.llvm
57 llvm.clang-unwrapped
58 zlib
59 zstd
60 ];
61
62 cmakeFlags = [
63 "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
64 ];
65
66 meta = {
67 description = "Set of AMD-specific device-side language runtime libraries";
68 homepage = "https://github.com/ROCm/ROCm-Device-Libs";
69 license = lib.licenses.ncsa;
70 maintainers = with lib.maintainers; [ lovesegfault ];
71 teams = [ lib.teams.rocm ];
72 platforms = lib.platforms.linux;
73 };
74})