28 "--prefix PATH : $out/bin"
29 "--prefix LD_LIBRARY_PATH : ${rocm-runtime}"
30 "--set HIP_PLATFORM amd"
32 "--set HIP_CLANG_PATH ${clang}/bin"
33 "--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode"
34 "--set HSA_PATH ${rocm-runtime}"
35 "--set ROCM_PATH $out"
38 # https://github.com/NixOS/nixpkgs/issues/305641
39 # Not needed when 3.29.2 is in unstable
40 cmake' = cmake.overrideAttrs(old: rec {
43 url = "https://cmake.org/files/v${lib.versions.majorMinor version}/cmake-${version}.tar.gz";
44 hash = "sha256-NttLaSaqt0G6bksuotmckZMiITIwi03IJNQSPLcwNS4=";
47 in stdenv.mkDerivation (finalAttrs: {
56 src = fetchFromGitHub {
59 rev = "rocm-${finalAttrs.version}";
60 hash = "sha256-1gZJhvBbUFdKH9p/7SRfzEV/fM+gIN2Qvlxf2VbmAIw=";
67 python3Packages.python
68 python3Packages.cppheaderparser
78 propagatedBuildInputs = [
86 "-DCMAKE_POLICY_DEFAULT_CMP0072=NEW" # Prefer newer OpenGL libraries
89 "-DHIP_COMMON_DIR=${hip-common}"
90 "-DHIPCC_BIN_DIR=${hipcc}/bin"
92 "-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
93 "-DROCM_PATH=${rocminfo}"
95 # Temporarily set variables to work around upstream CMakeLists issue
96 # Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed
97 "-DCMAKE_INSTALL_BINDIR=bin"
98 "-DCMAKE_INSTALL_INCLUDEDIR=include"
99 "-DCMAKE_INSTALL_LIBDIR=lib"
103 ./add-missing-operators.patch
104 ./static-functions.patch
108 patchShebangs hipamd/src
110 # We're not on Windows so these are never installed to hipcc...
111 substituteInPlace hipamd/CMakeLists.txt \
112 --replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipcc.bat DESTINATION bin)" "" \
113 --replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" ""
115 substituteInPlace hipamd/src/hip_embed_pch.sh \
116 --replace "\''$LLVM_DIR/bin/clang" "${clang}/bin/clang"
118 substituteInPlace opencl/khronos/icd/loader/icd_platform.h \
119 --replace-fail '#define ICD_VENDOR_PATH "/etc/OpenCL/vendors/";' \
120 '#define ICD_VENDOR_PATH "/run/opengl-driver/etc/OpenCL/vendors/";'
124 patchShebangs $out/bin
126 # hipcc.bin and hipconfig.bin is mysteriously never installed
127 cp -a ${hipcc}/bin/{hipcc.bin,hipconfig.bin} $out/bin
129 wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs}
130 wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs}
131 wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs}
132 wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs}
134 # Just link rocminfo, it's easier
135 ln -s ${rocminfo}/bin/* $out/bin
137 # Replace rocm-opencl-icd functionality
138 mkdir -p $icd/etc/OpenCL/vendors
139 echo "$out/lib/libamdocl64.so" > $icd/etc/OpenCL/vendors/amdocl64.icd
143 # All known and valid general GPU targets
144 # We cannot use this for each ROCm library, as each defines their own supported targets
145 # See: https://github.com/ROCm/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix
146 gpuTargets = lib.forEach [
161 ] (target: "gfx${target}");
163 updateScript = rocmUpdateScript {
164 name = finalAttrs.pname;
165 owner = finalAttrs.src.owner;
166 repo = finalAttrs.src.repo;
167 page = "tags?per_page=1";
168 filter = ".[0].name | split(\"-\") | .[1]";
172 rocm-smi = callPackage ./test-rocm-smi.nix {
174 clr = finalAttrs.finalPackage;
176 opencl-example = callPackage ./test-opencl-example.nix {
177 clr = finalAttrs.finalPackage;
183 description = "AMD Common Language Runtime for hipamd, opencl, and rocclr";
184 homepage = "https://github.com/ROCm/clr";
185 license = with licenses; [ mit ];
186 maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
187 platforms = platforms.linux;
188 broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "6.0.0";