about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/rocm-modules/6
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-05-03 15:14:25 +0200
committerAlyssa Ross <hi@alyssa.is>2024-05-07 11:19:19 +0200
commitd92b2b6a1bbd322dd65a8b6f51019610d350046e (patch)
tree7f7c21927b9cc05676501f297c51eb76b49e326c /nixpkgs/pkgs/development/rocm-modules/6
parent93c9e56b40530cc627d921cfc255c05b495d4017 (diff)
parent49050352f602fe87d16ff7b2b6a05b79eb20dc6f (diff)
downloadnixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.gz
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.bz2
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.lz
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.xz
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.tar.zst
nixlib-d92b2b6a1bbd322dd65a8b6f51019610d350046e.zip
Merge remote-tracking branch 'nixpkgs/nixos-unstable-small'
Conflicts:
	nixpkgs/nixos/modules/services/mail/mailman.nix
	nixpkgs/nixos/modules/services/mail/public-inbox.nix
	nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/pkgs/development/rocm-modules/6')
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/0001-Compile-transupp.c-as-part-of-the-library.patch104
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/clr/default.nix27
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/default.nix27
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/hiprand/default.nix76
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/base.nix11
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-1/clang-unwrapped.nix2
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-2/libc.nix10
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch36
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix2
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix10
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix12
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix2
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/miopen/default.nix9
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/mivisionx/0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch25
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/mivisionx/default.nix4
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/rccl/default.nix4
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/rocblas/default.nix170
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/rocm-runtime/default.nix10
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/rocprim/default.nix9
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/rocrand/default.nix3
-rw-r--r--nixpkgs/pkgs/development/rocm-modules/6/tensile/default.nix20
21 files changed, 382 insertions, 191 deletions
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/0001-Compile-transupp.c-as-part-of-the-library.patch b/nixpkgs/pkgs/development/rocm-modules/6/0001-Compile-transupp.c-as-part-of-the-library.patch
new file mode 100644
index 000000000000..0a09a8845c13
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/6/0001-Compile-transupp.c-as-part-of-the-library.patch
@@ -0,0 +1,104 @@
+From 4a0584f7c05641143151ebdc1be1163bebf9d35d Mon Sep 17 00:00:00 2001
+From: Las <las@protonmail.ch>
+Date: Sun, 3 Jan 2021 18:35:37 +0000
+Subject: [PATCH] Compile transupp.c as part of the library
+
+The exported symbols are made weak to not conflict with users
+of the library that already vendor this functionality.
+---
+ CMakeLists.txt |  4 ++--
+ transupp.c     | 14 +++++++-------
+ 2 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 0ca6f98..a9a0fae 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -533,7 +533,7 @@ set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
+   jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
+   jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c
+   jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c
+-  jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
++  jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c transupp.c)
+ 
+ if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
+   set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
+@@ -1489,7 +1489,7 @@ install(EXPORT ${CMAKE_PROJECT_NAME}Targets
+ 
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
+   ${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
+-  ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h
++  ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h ${CMAKE_CURRENT_SOURCE_DIR}/transupp.h
+   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ 
+ include(cmakescripts/BuildPackages.cmake)
+diff --git a/transupp.c b/transupp.c
+index 6e86077..2da49a7 100644
+--- a/transupp.c
++++ b/transupp.c
+@@ -1386,7 +1386,7 @@ jt_read_integer(const char **strptr, JDIMENSION *result)
+  * This code is loosely based on XParseGeometry from the X11 distribution.
+  */
+ 
+-GLOBAL(boolean)
++GLOBAL(boolean) __attribute__((weak))
+ jtransform_parse_crop_spec(jpeg_transform_info *info, const char *spec)
+ {
+   info->crop = FALSE;
+@@ -1486,7 +1486,7 @@ trim_bottom_edge(jpeg_transform_info *info, JDIMENSION full_height)
+  * and transformation is not perfect.  Otherwise returns TRUE.
+  */
+ 
+-GLOBAL(boolean)
++GLOBAL(boolean) __attribute__((weak))
+ jtransform_request_workspace(j_decompress_ptr srcinfo,
+                              jpeg_transform_info *info)
+ {
+@@ -2033,7 +2033,7 @@ adjust_exif_parameters(JOCTET *data, unsigned int length, JDIMENSION new_width,
+  * to jpeg_write_coefficients().
+  */
+ 
+-GLOBAL(jvirt_barray_ptr *)
++GLOBAL(jvirt_barray_ptr *) __attribute__((weak))
+ jtransform_adjust_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+                              jvirt_barray_ptr *src_coef_arrays,
+                              jpeg_transform_info *info)
+@@ -2152,7 +2152,7 @@ jtransform_adjust_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+  * Note that some transformations will modify the source data arrays!
+  */
+ 
+-GLOBAL(void)
++GLOBAL(void) __attribute__((weak))
+ jtransform_execute_transform(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+                              jvirt_barray_ptr *src_coef_arrays,
+                              jpeg_transform_info *info)
+@@ -2264,7 +2264,7 @@ jtransform_execute_transform(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+  *           (may use custom action then)
+  */
+ 
+-GLOBAL(boolean)
++GLOBAL(boolean) __attribute__((weak))
+ jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height,
+                              int MCU_width, int MCU_height,
+                              JXFORM_CODE transform)
+@@ -2303,7 +2303,7 @@ jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height,
+  * This must be called before jpeg_read_header() to have the desired effect.
+  */
+ 
+-GLOBAL(void)
++GLOBAL(void) __attribute__((weak))
+ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
+ {
+ #ifdef SAVE_MARKERS_SUPPORTED
+@@ -2331,7 +2331,7 @@ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
+  * JFIF APP0 or Adobe APP14 markers if selected.
+  */
+ 
+-GLOBAL(void)
++GLOBAL(void) __attribute__((weak))
+ jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+                       JCOPY_OPTION option)
+ {
+-- 
+2.29.2
+
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/clr/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/clr/default.nix
index 05acf86478d3..dedda194c828 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/clr/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/clr/default.nix
@@ -3,6 +3,7 @@
 , callPackage
 , fetchFromGitHub
 , fetchpatch
+, fetchurl
 , rocmUpdateScript
 , makeWrapper
 , cmake
@@ -34,6 +35,16 @@ let
     "--set HSA_PATH ${rocm-runtime}"
     "--set ROCM_PATH $out"
   ];
+
+  # https://github.com/NixOS/nixpkgs/issues/305641
+  # Not needed when 3.29.2 is in unstable
+  cmake' = cmake.overrideAttrs(old: rec {
+    version = "3.29.2";
+    src = fetchurl {
+      url = "https://cmake.org/files/v${lib.versions.majorMinor version}/cmake-${version}.tar.gz";
+      hash = "sha256-NttLaSaqt0G6bksuotmckZMiITIwi03IJNQSPLcwNS4=";
+    };
+  });
 in stdenv.mkDerivation (finalAttrs: {
   pname = "clr";
   version = "6.0.2";
@@ -52,7 +63,7 @@ in stdenv.mkDerivation (finalAttrs: {
 
   nativeBuildInputs = [
     makeWrapper
-    cmake
+    cmake'
     perl
     python3Packages.python
     python3Packages.cppheaderparser
@@ -100,6 +111,16 @@ in stdenv.mkDerivation (finalAttrs: {
       url = "https://github.com/ROCm/clr/commit/77c581a3ebd47b5e2908973b70adea66891159ee.patch";
       hash = "sha256-auBedbd7rghlKav7A9V6l64J7VmtE9GizIdi5gWj+fs=";
     })
+    (fetchpatch {
+      name = "extend-hip-isa-compatibility-check.patch";
+      url = "https://salsa.debian.org/rocm-team/rocm-hipamd/-/raw/d6d20142c37e1dff820950b16ff8f0523241d935/debian/patches/0026-extend-hip-isa-compatibility-check.patch";
+      hash = "sha256-eG0ALZZQLRzD7zJueJFhi2emontmYy6xx8Rsm346nQI=";
+    })
+    (fetchpatch {
+      name = "improve-rocclr-isa-compatibility-check.patch";
+      url = "https://salsa.debian.org/rocm-team/rocm-hipamd/-/raw/d6d20142c37e1dff820950b16ff8f0523241d935/debian/patches/0025-improve-rocclr-isa-compatibility-check.patch";
+      hash = "sha256-8eowuRiOAdd9ucKv4Eg9FPU7c6367H3eP3fRAGfXc6Y=";
+    })
   ];
 
   postPatch = ''
@@ -113,6 +134,10 @@ in stdenv.mkDerivation (finalAttrs: {
 
     substituteInPlace hipamd/src/hip_embed_pch.sh \
       --replace "\''$LLVM_DIR/bin/clang" "${clang}/bin/clang"
+
+    # https://lists.debian.org/debian-ai/2024/02/msg00178.html
+    substituteInPlace rocclr/utils/flags.hpp \
+      --replace-fail "HIP_USE_RUNTIME_UNBUNDLER, false" "HIP_USE_RUNTIME_UNBUNDLER, true"
   '';
 
   postInstall = ''
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/default.nix
index e4e745f74b56..e74df33a7bfb 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/default.nix
@@ -150,7 +150,10 @@ in rec {
     stdenv = llvm.rocmClangStdenv;
   };
 
-  hiprand = rocrand; # rocrand includes hiprand
+  hiprand = callPackage ./hiprand {
+    inherit rocmUpdateScript rocm-cmake clr rocrand;
+    stdenv = llvm.rocmClangStdenv;
+  };
 
   rocfft = callPackage ./rocfft {
     inherit rocmUpdateScript rocm-cmake rocrand rocfft clr;
@@ -191,7 +194,7 @@ in rec {
   };
 
   rocblas = callPackage ./rocblas {
-    inherit rocblas rocmUpdateScript rocm-cmake clr tensile;
+    inherit rocmUpdateScript rocm-cmake clr tensile;
     inherit (llvm) openmp;
     stdenv = llvm.rocmClangStdenv;
   };
@@ -236,9 +239,9 @@ in rec {
   # hipTensor - Only supports GFX9
 
   miopengemm= throw ''
-    'miopen-opencl' has been deprecated.
+    'miopengemm' has been deprecated.
     It is still available for some time as part of rocmPackages_5.
-  ''; # Added 2024-3-3;
+  ''; # Added 2024-3-3
 
   composable_kernel = callPackage ./composable_kernel {
     inherit rocmUpdateScript rocm-cmake clr;
@@ -264,7 +267,7 @@ in rec {
   miopen-opencl= throw ''
     'miopen-opencl' has been deprecated.
     It is still available for some time as part of rocmPackages_5.
-  ''; # Added 2024-3-3;
+  ''; # Added 2024-3-3
 
   migraphx = callPackage ./migraphx {
     inherit rocmUpdateScript rocm-cmake rocblas composable_kernel miopen clr half rocm-device-libs;
@@ -313,6 +316,9 @@ in rec {
         rev = "640d7ee1917fcd3b6a5271aa6cf4576bccc7c5fb";
         sha256 = "sha256-T52whJ7nZi8jerJaZtYInC2YDN0QM+9tUDqiNr6IsNY=";
       };
+
+      # overwrite all patches, since patches for newer version do not apply
+      patches = [ ./0001-Compile-transupp.c-as-part-of-the-library.patch ];
     };
   };
 
@@ -322,12 +328,11 @@ in rec {
     useCPU = false;
   };
 
-  mivisionx-opencl = mivisionx.override {
-    rpp = rpp-opencl;
-    miopen = miopen-opencl;
-    useOpenCL = true;
-    useCPU = false;
-  };
+  mivisionx-opencl = throw ''
+    'mivisionx-opencl' has been deprecated.
+    Other versions of mivisionx are still available.
+    It is also still available for some time as part of rocmPackages_5.
+  ''; # Added 2024-3-24
 
   mivisionx-cpu = mivisionx.override {
     rpp = rpp-cpu;
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/hiprand/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/hiprand/default.nix
new file mode 100644
index 000000000000..7251a0e5a07e
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/6/hiprand/default.nix
@@ -0,0 +1,76 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rocmUpdateScript
+, cmake
+, rocm-cmake
+, clr
+, rocrand
+, gtest
+, buildTests ? false
+, gpuTargets ? [ ]
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "hiprand";
+  version = "6.0.2";
+
+  outputs = [
+    "out"
+  ] ++ lib.optionals buildTests [
+    "test"
+  ];
+
+  src = fetchFromGitHub {
+    owner = "ROCm";
+    repo = "hipRAND";
+    rev = "rocm-${finalAttrs.version}";
+    hash = "sha256-uGHzOhUX5JEknVFwhHhWFdPmwLS/TuaXYMeItS7tXIg=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    rocm-cmake
+    clr
+  ];
+
+  buildInputs = [ rocrand ] ++ (lib.optionals buildTests [ gtest ]);
+
+  cmakeFlags = [
+    "-DCMAKE_C_COMPILER=hipcc"
+    "-DCMAKE_CXX_COMPILER=hipcc"
+    "-DHIP_ROOT_DIR=${clr}"
+    # Manually define CMAKE_INSTALL_<DIR>
+    # See: https://github.com/NixOS/nixpkgs/pull/197838
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  ] ++ lib.optionals (gpuTargets != [ ]) [
+    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
+  ] ++ lib.optionals buildTests [
+    "-DBUILD_TEST=ON"
+  ];
+
+  postInstall = lib.optionalString buildTests ''
+    mkdir -p $test/bin
+    mv $out/bin/test_* $test/bin
+    rm -r $out/bin/hipRAND
+    # Fail if bin/ isn't actually empty
+    rmdir $out/bin
+  '';
+
+  passthru.updateScript = rocmUpdateScript {
+    name = finalAttrs.pname;
+    owner = finalAttrs.src.owner;
+    repo = finalAttrs.src.repo;
+  };
+
+  meta = with lib; {
+    description = "A HIP wrapper for rocRAND and cuRAND";
+    homepage = "https://github.com/ROCm/hipRAND";
+    license = with licenses; [ mit ];
+    maintainers = teams.rocm.members;
+    platforms = platforms.linux;
+    broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "7.0.0";
+  };
+})
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/base.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/base.nix
index 95f57b052045..caa2ebe42823 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/base.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/base.nix
@@ -133,7 +133,14 @@ in stdenv.mkDerivation (finalAttrs: {
     "-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped"
   ] ++ extraCMakeFlags;
 
-  postPatch = lib.optionalString finalAttrs.passthru.isLLVM ''
+  prePatch = ''
+    cd ../
+    chmod -R u+w .
+  '';
+
+  postPatch = ''
+    cd ${targetDir}
+  '' + lib.optionalString finalAttrs.passthru.isLLVM ''
     patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh
   '' + lib.optionalString (buildTests && finalAttrs.passthru.isLLVM) ''
     # FileSystem permissions tests fail with various special bits
@@ -141,7 +148,7 @@ in stdenv.mkDerivation (finalAttrs: {
     rm unittests/Support/Path.cpp
 
     substituteInPlace unittests/Support/CMakeLists.txt \
-      --replace "Path.cpp" ""
+      --replace-fail "Path.cpp" ""
   '' + extraPostPatch;
 
   doCheck = buildTests;
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-1/clang-unwrapped.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-1/clang-unwrapped.nix
index 5a61732ffd2d..1cf60223def6 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-1/clang-unwrapped.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-1/clang-unwrapped.nix
@@ -20,7 +20,7 @@ callPackage ../base.nix rec {
     ln -s ../cmake/Modules/FindLibEdit.cmake cmake/modules
 
     substituteInPlace CMakeLists.txt \
-      --replace "include(CheckIncludeFile)" "include(CheckIncludeFile)''\nfind_package(LibEdit)"
+      --replace-fail "include(CheckIncludeFile)" "include(CheckIncludeFile)''\nfind_package(LibEdit)"
 
     # `No such file or directory: '/build/source/clang/tools/scan-build/bin/scan-build'`
     rm test/Analysis/scan-build/*.test
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-2/libc.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-2/libc.nix
index 7e7cf9c2a608..2446723ef5fe 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-2/libc.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-2/libc.nix
@@ -14,11 +14,11 @@ callPackage ../base.nix rec {
     # `Failed to match ... against ...` `Match value not within tolerance value of MPFR result:`
     # We need a better way, but I don't know enough sed magic and patching `CMakeLists.txt` isn't working...
     substituteInPlace ../libc/test/src/math/log10_test.cpp \
-      --replace "i < N" "i < 0" \
-      --replace "test(mpfr::RoundingMode::Nearest);" "" \
-      --replace "test(mpfr::RoundingMode::Downward);" "" \
-      --replace "test(mpfr::RoundingMode::Upward);" "" \
-      --replace "test(mpfr::RoundingMode::TowardZero);" ""
+      --replace-fail "i < N" "i < 0" \
+      --replace-fail "test(mpfr::RoundingMode::Nearest);" "" \
+      --replace-fail "test(mpfr::RoundingMode::Downward);" "" \
+      --replace-fail "test(mpfr::RoundingMode::Upward);" "" \
+      --replace-fail "test(mpfr::RoundingMode::TowardZero);" ""
   '';
 
   checkTargets = [ "check-${targetName}" ];
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch
deleted file mode 100644
index f4221a088136..000000000000
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From f1d1e10ec7e1061bf0b90abbc1e298d9438a5e74 Mon Sep 17 00:00:00 2001
-From: Scott Linder <Scott.Linder@amd.com>
-Date: Mon, 11 Sep 2023 18:37:37 +0000
-Subject: [PATCH] [HeterogeneousDWARF] Update MLIR DI Metadata handling
-
-Pass a default DW_MSPACE_LLVM_none to satisfy new API
-
-Change-Id: I50df461f00b5510a715f55f61107122318102d22
----
- lib/Target/LLVMIR/DebugTranslation.cpp | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/lib/Target/LLVMIR/DebugTranslation.cpp b/lib/Target/LLVMIR/DebugTranslation.cpp
-index 2053f5bcef06aa6..635ee5d7e5fefdc 100644
---- a/lib/Target/LLVMIR/DebugTranslation.cpp
-+++ b/lib/Target/LLVMIR/DebugTranslation.cpp
-@@ -148,7 +148,8 @@ llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
-       /*File=*/nullptr, /*Line=*/0,
-       /*Scope=*/nullptr, translate(attr.getBaseType()), attr.getSizeInBits(),
-       attr.getAlignInBits(), attr.getOffsetInBits(),
--      /*DWARFAddressSpace=*/std::nullopt, /*Flags=*/llvm::DINode::FlagZero);
-+      /*DWARFAddressSpace=*/std::nullopt, llvm::dwarf::DW_MSPACE_LLVM_none,
-+      /*Flags=*/llvm::DINode::FlagZero);
- }
- 
- llvm::DIFile *DebugTranslation::translateImpl(DIFileAttr attr) {
-@@ -185,7 +186,8 @@ DebugTranslation::translateImpl(DILocalVariableAttr attr) {
-       llvmCtx, translate(attr.getScope()), getMDStringOrNull(attr.getName()),
-       translate(attr.getFile()), attr.getLine(), translate(attr.getType()),
-       attr.getArg(),
--      /*Flags=*/llvm::DINode::FlagZero, attr.getAlignInBits(),
-+      /*Flags=*/llvm::DINode::FlagZero, llvm::dwarf::DW_MSPACE_LLVM_none,
-+      attr.getAlignInBits(),
-       /*Annotations=*/nullptr);
- }
- 
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix
index 91f34265f85f..a0e1935d3c5f 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix
@@ -68,6 +68,6 @@ wrapCCWith rec {
 
     # GPU compilation uses builtin `lld`
     substituteInPlace $out/bin/{clang,clang++} \
-      --replace "-MM) dontLink=1 ;;" "-MM | --cuda-device-only) dontLink=1 ;;''\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;"
+      --replace-fail "-MM) dontLink=1 ;;" "-MM | --cuda-device-only) dontLink=1 ;;''\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;"
   '';
 }
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix
index 1fd72ee67188..c395dd792db0 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix
@@ -21,13 +21,13 @@ in callPackage ../base.nix rec {
   # `clspv` tests fail, unresolved calls
   extraPostPatch = ''
     substituteInPlace CMakeLists.txt \
-      --replace "find_program( LLVM_CLANG clang PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
+      --replace-fail "find_program( LLVM_CLANG clang PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
         "find_program( LLVM_CLANG clang PATHS \"${clang}/bin\" NO_DEFAULT_PATH )" \
-      --replace "find_program( LLVM_SPIRV llvm-spirv PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
+      --replace-fail "find_program( LLVM_SPIRV llvm-spirv PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
         "find_program( LLVM_SPIRV llvm-spirv PATHS \"${spirv}/bin\" NO_DEFAULT_PATH )" \
-      --replace "  spirv-mesa3d-" "" \
-      --replace "  spirv64-mesa3d-" "" \
-      --replace "NOT \''${t} MATCHES" \
+      --replace-fail "  spirv-mesa3d-" "" \
+      --replace-fail "  spirv64-mesa3d-" "" \
+      --replace-fail "NOT \''${t} MATCHES" \
         "NOT \''${ARCH} STREQUAL \"clspv\" AND NOT \''${ARCH} STREQUAL \"clspv64\" AND NOT \''${t} MATCHES"
   '';
 
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix
index 6de685ea2771..8b71b3fb2977 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix
@@ -7,6 +7,7 @@
 , glslang
 , shaderc
 , lit
+, fetchpatch
 }:
 
 callPackage ../base.nix rec {
@@ -17,9 +18,12 @@ callPackage ../base.nix rec {
   targetDir = targetName;
 
   # Fix `DebugTranslation.cpp:139:10: error: no matching function for call to 'get'`
-  # We patch at a different source root, so we modify the patch and include it locally
-  # https://github.com/ROCm/llvm-project/commit/f1d1e10ec7e1061bf0b90abbc1e298d9438a5e74.patch
-  extraPatches = [ ./0000-mlir-fix-debugtranslation.patch ];
+  extraPatches = [
+    (fetchpatch {
+      url = "https://github.com/ROCm/llvm-project/commit/f1d1e10ec7e1061bf0b90abbc1e298d9438a5e74.patch";
+      hash = "sha256-3c91A9InMKxm+JcnWxoUeOU68y5I6w1AAXx6T9UByqI=";
+    })
+  ];
   extraNativeBuildInputs = [ clr ];
 
   extraBuildInputs = [
@@ -41,7 +45,7 @@ callPackage ../base.nix rec {
   extraPostPatch = ''
     # `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
     substituteInPlace CMakeLists.txt \
-      --replace "EXISTS \''${UNITTEST_DIR}/googletest/include/gtest/gtest.h" "FALSE"
+      --replace-fail "EXISTS \''${UNITTEST_DIR}/googletest/include/gtest/gtest.h" "FALSE"
 
     # Mainly `No such file or directory`
     cat ${./1001-mlir-failing-tests.list} | xargs -d \\n rm
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix
index e001f33dfd43..da5c2e16f5d3 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix
@@ -11,7 +11,7 @@ callPackage ../base.nix rec {
   extraPostPatch = ''
     # `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
     substituteInPlace CMakeLists.txt \
-      --replace "NOT TARGET gtest" "FALSE"
+      --replace-fail "NOT TARGET gtest" "FALSE"
   '';
 
   checkTargets = [ "check-${targetName}" ];
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/miopen/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/miopen/default.nix
index f78bcb602e69..0b57cf6592cb 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/miopen/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/miopen/default.nix
@@ -116,6 +116,11 @@ in stdenv.mkDerivation (finalAttrs: {
       url = "https://github.com/ROCm/MIOpen/commit/3413d2daaeb44b7d6eadcc03033a5954a118491e.patch";
       hash = "sha256-ST4snUcTmmSI1Ogx815KEX9GdMnmubsavDzXCGJkiKs=";
     })
+    (fetchpatch {
+      name = "Extend-MIOpen-ISA-compatibility.patch";
+      url = "https://github.com/GZGavinZhao/MIOpen/commit/416088b534618bd669a765afce59cfc7197064c1.patch";
+      hash = "sha256-OwONCA68y8s2GqtQj+OtotXwUXQ5jM8tpeM92iaD4MU=";
+    })
   ];
 
   outputs = [
@@ -155,6 +160,7 @@ in stdenv.mkDerivation (finalAttrs: {
     python3Packages.breathe
     python3Packages.myst-parser
   ] ++ lib.optionals buildTests [
+    gtest
     zlib
   ];
 
@@ -185,6 +191,9 @@ in stdenv.mkDerivation (finalAttrs: {
     substituteInPlace test/gtest/CMakeLists.txt \
       --replace "include(googletest)" ""
 
+    substituteInPlace test/gtest/CMakeLists.txt \
+      --replace-fail " gtest_main " " ${gtest}/lib/libgtest.so ${gtest}/lib/libgtest_main.so "
+
     ln -sf ${gfx900} src/kernels/gfx900.kdb
     ln -sf ${gfx906} src/kernels/gfx906.kdb
     ln -sf ${gfx908} src/kernels/gfx908.kdb
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch b/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch
new file mode 100644
index 000000000000..18946835e12e
--- /dev/null
+++ b/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch
@@ -0,0 +1,25 @@
+From f0e66bd446d44df1d30faaad520613f5fb7f5916 Mon Sep 17 00:00:00 2001
+From: Martin Schwaighofer <mschwaig@users.noreply.github.com>
+Date: Sat, 30 Mar 2024 15:36:52 +0100
+Subject: [PATCH] set __STDC_CONSTANT_MACROS to make rocAL compile
+
+---
+ CMakeLists.txt | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 42b139b6..509915f1 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -149,6 +149,8 @@ message("-- ${Cyan}     -D MIGRAPHX=${MIGRAPHX} [Turn ON/OFF MIGraphX Module (de
+ message("-- ${Cyan}     -D BACKEND=${BACKEND} [Select MIVisionX Backend [options:CPU/OPENCL/HIP](default:HIP)]${ColourReset}")
+ message("-- ${Cyan}     -D BUILD_WITH_AMD_ADVANCE=${BUILD_WITH_AMD_ADVANCE} [Turn ON/OFF Build for AMD advanced GPUs(default:OFF)]${ColourReset}")
+ 
++add_definitions(-D__STDC_CONSTANT_MACROS)
++
+ add_subdirectory(amd_openvx)
+ add_subdirectory(amd_openvx_extensions)
+ add_subdirectory(utilities)
+-- 
+2.43.0
+
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/default.nix
index e3e6172709fe..8459dff1c892 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/mivisionx/default.nix
@@ -46,6 +46,10 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-d32lcJq24MXeIWbNbo6putWaol5kF2io6cz4ZuL+DbE=";
   };
 
+  patches = [
+    ./0001-set-__STDC_CONSTANT_MACROS-to-make-rocAL-compile.patch
+  ];
+
   nativeBuildInputs = [
     cmake
     rocm-cmake
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/rccl/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/rccl/default.nix
index cdbbd70440c2..a830883b4f82 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/rccl/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/rccl/default.nix
@@ -65,7 +65,9 @@ stdenv.mkDerivation (finalAttrs: {
 
     # Really strange behavior, `#!/usr/bin/env perl` should work...
     substituteInPlace CMakeLists.txt \
-      --replace "\''$ \''${hipify-perl_executable}" "${perl}/bin/perl ${hipify}/bin/hipify-perl"
+      --replace "\''$ \''${hipify-perl_executable}" "${perl}/bin/perl ${hipify}/bin/hipify-perl" \
+      --replace-warn "-parallel-jobs=12" "-parallel-jobs=1" \
+      --replace-warn "-parallel-jobs=16" "-parallel-jobs=1"
   '';
 
   postInstall = lib.optionalString buildTests ''
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/rocblas/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/rocblas/default.nix
index 296167bb6f28..f93cceddd68a 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/rocblas/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/rocblas/default.nix
@@ -1,7 +1,7 @@
-{ rocblas
-, lib
+{ lib
 , stdenv
 , fetchFromGitHub
+, fetchpatch
 , rocmUpdateScript
 , runCommand
 , cmake
@@ -21,57 +21,26 @@
 , buildBenchmarks ? false
 , tensileLogic ? "asm_full"
 , tensileCOVersion ? "default"
-, tensileSepArch ? true
-, tensileLazyLib ? true
+# https://github.com/ROCm/Tensile/issues/1757
+# Allows gfx101* users to use rocBLAS normally.
+# Turn the below two values to `true` after the fix has been cherry-picked
+# into a release. Just backporting that single fix is not enough because it
+# depends on some previous commits.
+, tensileSepArch ? false
+, tensileLazyLib ? false
 , tensileLibFormat ? "msgpack"
-, gpuTargets ? [ "all" ]
+# `gfx940`, `gfx941` are not present in this list because they are early
+# engineering samples, and all final MI300 hardware are `gfx942`:
+# https://github.com/NixOS/nixpkgs/pull/298388#issuecomment-2032791130
+#
+# `gfx1012` is not present in this list because the ISA compatibility patches
+# would force all `gfx101*` GPUs to run as `gfx1010`, so `gfx101*` GPUs will
+# always try to use `gfx1010` code objects, hence building for `gfx1012` is
+# useless: https://github.com/NixOS/nixpkgs/pull/298388#issuecomment-2076327152
+, gpuTargets ? [ "gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx942;gfx1010;gfx1030;gfx1100;gfx1101;gfx1102" ]
 }:
 
-let
-  # NOTE: Update the default GPU targets on every update
-  gfx80 = (rocblas.override {
-    gpuTargets = [
-      "gfx803"
-    ];
-  }).overrideAttrs { pname = "rocblas-tensile-gfx80"; };
-
-  gfx90 = (rocblas.override {
-    gpuTargets = [
-      "gfx900"
-      "gfx906:xnack-"
-      "gfx908:xnack-"
-      "gfx90a:xnack+"
-      "gfx90a:xnack-"
-    ];
-  }).overrideAttrs { pname = "rocblas-tensile-gfx90"; };
-
-  gfx94 = (rocblas.override {
-    gpuTargets = [
-      "gfx940"
-      "gfx941"
-      "gfx942"
-    ];
-  }).overrideAttrs { pname = "rocblas-tensile-gfx94"; };
-
-  gfx10 = (rocblas.override {
-    gpuTargets = [
-      "gfx1010"
-      "gfx1012"
-      "gfx1030"
-    ];
-  }).overrideAttrs { pname = "rocblas-tensile-gfx10"; };
-
-  gfx11 = (rocblas.override {
-    gpuTargets = [
-      "gfx1100"
-      "gfx1101"
-      "gfx1102"
-    ];
-  }).overrideAttrs { pname = "rocblas-tensile-gfx11"; };
-
-  # Unfortunately, we have to do two full builds, otherwise we get overlapping _fallback.dat files
-  fallbacks = rocblas.overrideAttrs { pname = "rocblas-tensile-fallbacks"; };
-in stdenv.mkDerivation (finalAttrs: {
+stdenv.mkDerivation (finalAttrs: {
   pname = "rocblas";
   version = "6.0.2";
 
@@ -94,6 +63,8 @@ in stdenv.mkDerivation (finalAttrs: {
     cmake
     rocm-cmake
     clr
+  ] ++ lib.optionals buildTensile [
+    tensile
   ];
 
   buildInputs = [
@@ -114,80 +85,41 @@ in stdenv.mkDerivation (finalAttrs: {
   ];
 
   cmakeFlags = [
-    "-DCMAKE_C_COMPILER=hipcc"
-    "-DCMAKE_CXX_COMPILER=hipcc"
-    "-Dpython=python3"
-    "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
-    "-DBUILD_WITH_TENSILE=${if buildTensile then "ON" else "OFF"}"
-    # Manually define CMAKE_INSTALL_<DIR>
-    # See: https://github.com/NixOS/nixpkgs/pull/197838
-    "-DCMAKE_INSTALL_BINDIR=bin"
-    "-DCMAKE_INSTALL_LIBDIR=lib"
-    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    (lib.cmakeFeature "CMAKE_C_COMPILER" "hipcc")
+    (lib.cmakeFeature "CMAKE_CXX_COMPILER" "hipcc")
+    (lib.cmakeFeature "python" "python3")
+    (lib.cmakeFeature "AMDGPU_TARGETS" (lib.concatStringsSep ";" gpuTargets))
+    (lib.cmakeBool "BUILD_WITH_TENSILE" buildTensile)
+    (lib.cmakeBool "ROCM_SYMLINK_LIBS" false)
+    (lib.cmakeFeature "ROCBLAS_TENSILE_LIBRARY_DIR" "lib/rocblas")
+    (lib.cmakeBool "BUILD_CLIENTS_TESTS" buildTests)
+    (lib.cmakeBool "BUILD_CLIENTS_BENCHMARKS" buildBenchmarks)
+    # rocblas header files are not installed unless we set this
+    (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include")
   ] ++ lib.optionals buildTensile [
-    "-DVIRTUALENV_HOME_DIR=/build/source/tensile"
-    "-DTensile_TEST_LOCAL_PATH=/build/source/tensile"
-    "-DTensile_ROOT=/build/source/tensile/${python3.sitePackages}/Tensile"
-    "-DTensile_LOGIC=${tensileLogic}"
-    "-DTensile_CODE_OBJECT_VERSION=${tensileCOVersion}"
-    "-DTensile_SEPARATE_ARCHITECTURES=${if tensileSepArch then "ON" else "OFF"}"
-    "-DTensile_LAZY_LIBRARY_LOADING=${if tensileLazyLib then "ON" else "OFF"}"
-    "-DTensile_LIBRARY_FORMAT=${tensileLibFormat}"
-  ] ++ lib.optionals buildTests [
-    "-DBUILD_CLIENTS_TESTS=ON"
-  ] ++ lib.optionals buildBenchmarks [
-    "-DBUILD_CLIENTS_BENCHMARKS=ON"
+    (lib.cmakeBool "BUILD_WITH_PIP" false)
+    (lib.cmakeFeature "Tensile_LOGIC" tensileLogic)
+    (lib.cmakeFeature "Tensile_CODE_OBJECT_VERSION" tensileCOVersion)
+    (lib.cmakeBool "Tensile_SEPARATE_ARCHITECTURES" tensileSepArch)
+    (lib.cmakeBool "Tensile_LAZY_LIBRARY_LOADING" tensileLazyLib)
+    (lib.cmakeFeature "Tensile_LIBRARY_FORMAT" tensileLibFormat)
+    (lib.cmakeBool "Tensile_PRINT_DEBUG" true)
   ] ++ lib.optionals (buildTests || buildBenchmarks) [
-    "-DCMAKE_CXX_FLAGS=-I${amd-blis}/include/blis"
+    (lib.cmakeFeature "CMAKE_CXX_FLAGS" "-I${amd-blis}/include/blis")
   ];
 
-  postPatch = lib.optionalString (finalAttrs.pname != "rocblas") ''
-    # Return early and install tensile files manually
-    substituteInPlace library/src/CMakeLists.txt \
-      --replace "set_target_properties( TensileHost PROPERTIES OUTPUT_NAME" "return()''\nset_target_properties( TensileHost PROPERTIES OUTPUT_NAME"
-  '' + lib.optionalString (buildTensile && finalAttrs.pname == "rocblas") ''
-    # Link the prebuilt Tensile files
-    mkdir -p build/Tensile/library
-
-    for path in ${gfx80} ${gfx90} ${gfx94} ${gfx10} ${gfx11} ${fallbacks}; do
-      ln -s $path/lib/rocblas/library/* build/Tensile/library
-    done
-
-    unlink build/Tensile/library/TensileManifest.txt
-  '' + lib.optionalString buildTensile ''
-    # Tensile REALLY wants to write to the nix directory if we include it normally
-    cp -a ${tensile} tensile
-    chmod +w -R tensile
-
-    # Rewrap Tensile
-    substituteInPlace tensile/bin/{.t*,.T*,*} \
-      --replace "${tensile}" "/build/source/tensile"
-
-    substituteInPlace CMakeLists.txt \
-      --replace "include(virtualenv)" "" \
-      --replace "virtualenv_install(\''${Tensile_TEST_LOCAL_PATH})" ""
-  '';
+  patches = [
+    (fetchpatch {
+      name = "Extend-rocBLAS-HIP-ISA-compatibility.patch";
+      url = "https://github.com/GZGavinZhao/rocBLAS/commit/89b75ff9cc731f71f370fad90517395e117b03bb.patch";
+      hash = "sha256-W/ohOOyNCcYYLOiQlPzsrTlNtCBdJpKVxO8s+4G7sjo=";
+    })
+  ];
 
-  postInstall = lib.optionalString (finalAttrs.pname == "rocblas") ''
-    ln -sf ${fallbacks}/lib/rocblas/library/TensileManifest.txt $out/lib/rocblas/library
-  '' + lib.optionalString (finalAttrs.pname != "rocblas") ''
-    mkdir -p $out/lib/rocblas/library
-    rm -rf $out/share
-  '' + lib.optionalString (finalAttrs.pname != "rocblas" && finalAttrs.pname != "rocblas-tensile-fallbacks") ''
-    rm Tensile/library/{TensileManifest.txt,*_fallback.dat}
-    mv Tensile/library/* $out/lib/rocblas/library
-  '' + lib.optionalString (finalAttrs.pname == "rocblas-tensile-fallbacks") ''
-    mv Tensile/library/{TensileManifest.txt,*_fallback.dat} $out/lib/rocblas/library
-  '' + lib.optionalString buildTests ''
-    mkdir -p $test/bin
-    cp -a $out/bin/* $test/bin
-    rm $test/bin/*-bench || true
-  '' + lib.optionalString buildBenchmarks ''
-    mkdir -p $benchmark/bin
-    cp -a $out/bin/* $benchmark/bin
-    rm $benchmark/bin/*-test || true
-  '' + lib.optionalString (buildTests || buildBenchmarks ) ''
-    rm -rf $out/bin
+  # Pass $NIX_BUILD_CORES to Tensile
+  postPatch = ''
+    substituteInPlace cmake/build-options.cmake \
+      --replace-fail 'Tensile_CPU_THREADS ""' 'Tensile_CPU_THREADS "$ENV{NIX_BUILD_CORES}"'
   '';
 
   passthru.updateScript = rocmUpdateScript {
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/rocm-runtime/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/rocm-runtime/default.nix
index 8c3d0cdc976d..f603b708265d 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/rocm-runtime/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/rocm-runtime/default.nix
@@ -1,6 +1,7 @@
 { lib
 , stdenv
 , fetchFromGitHub
+, fetchpatch
 , rocmUpdateScript
 , pkg-config
 , cmake
@@ -42,6 +43,15 @@ stdenv.mkDerivation (finalAttrs: {
     libxml2
   ];
 
+  patches = [
+    (fetchpatch {
+      name = "extend-isa-compatibility-check.patch";
+      url = "https://salsa.debian.org/rocm-team/rocr-runtime/-/raw/076026d43bbee7f816b81fea72f984213a9ff961/debian/patches/0004-extend-isa-compatibility-check.patch";
+      hash = "sha256-cC030zVGS4kNXwaztv5cwfXfVwOldpLGV9iYgEfPEnY=";
+      stripLen = 1;
+    })
+  ];
+
   postPatch = ''
     patchShebangs image/blit_src/create_hsaco_ascii_file.sh
     patchShebangs core/runtime/trap_handler/create_trap_handler_header.sh
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/rocprim/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/rocprim/default.nix
index e9996cae61e7..3e8525655141 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/rocprim/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/rocprim/default.nix
@@ -1,4 +1,5 @@
 { lib
+, fetchpatch
 , stdenv
 , fetchFromGitHub
 , rocmUpdateScript
@@ -31,6 +32,14 @@ stdenv.mkDerivation (finalAttrs: {
     hash = "sha256-nWvq26qRPZ6Au1rc5cR74TKArcdUFg7O9djFi8SvMeM=";
   };
 
+  patches = [
+    (fetchpatch {
+      name = "arch-conversion-marco.patch";
+      url = "https://salsa.debian.org/rocm-team/rocprim/-/raw/70c8aaee3cf545d92685f4ed9bf8f41e3d4d570c/debian/patches/arch-conversion-macro.patch";
+      hash = "sha256-oXdmbCArOB5bKE8ozDFrSh4opbO+c4VI6PNhljeUSms=";
+    })
+  ];
+
   nativeBuildInputs = [
     cmake
     rocm-cmake
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/rocrand/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/rocrand/default.nix
index f09ff3b12059..7d0e80b5af4e 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/rocrand/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/rocrand/default.nix
@@ -29,7 +29,6 @@ stdenv.mkDerivation (finalAttrs: {
     repo = "rocRAND";
     rev = "rocm-${finalAttrs.version}";
     hash = "sha256-BBkcYOP+zh3OQTxuSkeiJizwnE9Gr5Jbhx0e8SU/mmU=";
-    fetchSubmodules = true; # For inline hipRAND
   };
 
   nativeBuildInputs = [
@@ -68,6 +67,8 @@ stdenv.mkDerivation (finalAttrs: {
     mkdir -p $benchmark/bin
     mv $out/bin/benchmark_* $benchmark/bin
   '' + lib.optionalString (buildTests || buildBenchmarks) ''
+    rm -r $out/bin/rocRAND
+    # Fail if bin/ isn't actually empty
     rmdir $out/bin
   '';
 
diff --git a/nixpkgs/pkgs/development/rocm-modules/6/tensile/default.nix b/nixpkgs/pkgs/development/rocm-modules/6/tensile/default.nix
index af33fd789e84..6df403249e9a 100644
--- a/nixpkgs/pkgs/development/rocm-modules/6/tensile/default.nix
+++ b/nixpkgs/pkgs/development/rocm-modules/6/tensile/default.nix
@@ -1,6 +1,7 @@
 { lib
 , stdenv
 , fetchFromGitHub
+, fetchpatch
 , rocmUpdateScript
 , buildPythonPackage
 , pytestCheckHook
@@ -34,6 +35,19 @@ buildPythonPackage rec {
     joblib
   ];
 
+  patches = [
+    (fetchpatch {
+      name = "Extend-Tensile-HIP-ISA-compatibility.patch";
+      url = "https://github.com/GZGavinZhao/Tensile/commit/855cb15839849addb0816a6dde45772034a3e41f.patch";
+      hash = "sha256-d+fVf/vz+sxGqJ96vuxe0jRMgbC5K6j5FQ5SJ1e3Sl8=";
+    })
+    (fetchpatch {
+      name = "Don-t-copy-file-twice-in-copyStaticFiles.patch";
+      url = "https://github.com/GZGavinZhao/Tensile/commit/9e14d5a00a096bddac605910a0e4dfb4c35bb0d5.patch";
+      hash = "sha256-gOzjJyD1K056OFQ+hK5nbUeBhxLTIgQLoT+0K12SypI=";
+    })
+  ];
+
   doCheck = false; # Too many errors, not sure how to set this up properly
 
   nativeCheckInputs = [
@@ -42,9 +56,9 @@ buildPythonPackage rec {
     rocminfo
   ];
 
-  preCheck = ''
-    export ROCM_PATH=${rocminfo}
-  '';
+  env = {
+    ROCM_PATH = rocminfo;
+  };
 
   pythonImportsCheck = [ "Tensile" ];