1{ lib, stdenv
2, fetchFromGitHub
3, fetchpatch
4, writeScript
5, rocm-comgr
6}:
7
8stdenv.mkDerivation rec {
9 pname = "rocclr";
10 version = "5.3.1";
11
12 src = fetchFromGitHub {
13 owner = "ROCm-Developer-Tools";
14 repo = "ROCclr";
15 rev = "rocm-${version}";
16 hash = "sha256-dmL9krI/gHGQdOZ53+bQ7WjKcmJ+fZZP0lzF8ITLT4E=";
17 };
18
19 patches = [
20 # Enable support for gfx8 again
21 # See the upstream issue: https://github.com/RadeonOpenCompute/ROCm/issues/1659
22 # And the arch patch: https://github.com/rocm-arch/rocm-arch/pull/742
23 (fetchpatch {
24 url = "https://raw.githubusercontent.com/John-Gee/rocm-arch/d6812d308fee3caf2b6bb01b4d19fe03a6a0e3bd/rocm-opencl-runtime/enable-gfx800.patch";
25 hash = "sha256-59jFDIIsTTZcNns9RyMVWPRUggn/bSlAGrky4quu8B4=";
26 })
27 ];
28
29 prePatch = ''
30 substituteInPlace device/comgrctx.cpp \
31 --replace "libamd_comgr.so" "${rocm-comgr}/lib/libamd_comgr.so"
32 '';
33
34 buildPhase = "";
35
36 installPhase = ''
37 runHook preInstall
38
39 mkdir -p $out
40 cp -r * $out/
41
42 runHook postInstall
43 '';
44
45 passthru.updateScript = writeScript "update.sh" ''
46 #!/usr/bin/env nix-shell
47 #!nix-shell -i bash -p curl jq common-updater-scripts
48 version="$(curl -sL "https://api.github.com/repos/ROCm-Developer-Tools/ROCclr/tags" | jq '.[].name | split("-") | .[1] | select( . != null )' --raw-output | sort -n | tail -1)"
49 update-source-version rocclr "$version"
50 '';
51
52 meta = with lib; {
53 description = "Source package of the Radeon Open Compute common language runtime";
54 homepage = "https://github.com/ROCm-Developer-Tools/ROCclr";
55 license = licenses.mit;
56 maintainers = with maintainers; [ lovesegfault Flakebi ];
57 # rocclr seems to have some AArch64 ifdefs, but does not seem
58 # to be supported yet by the build infrastructure. Recheck in
59 # the future.
60 platforms = [ "x86_64-linux" ];
61 };
62}