16 , buildRockCompiler ? false
17 , buildTests ? false # `argument of type 'NoneType' is not iterable`
20 # Theoretically, we could have our MLIR have an output
21 # with the source and built objects so that we can just
22 # use it as the external LLVM repo for this
30 if stdenv.hostPlatform.isx86_64 then "X86"
31 else if stdenv.hostPlatform.isAarch64 then "AArch64"
32 else throw "Unsupported ROCm LLVM platform";
33 in stdenv.mkDerivation (finalAttrs: {
34 pname = "rocmlir${suffix}";
39 ] ++ lib.optionals (!buildRockCompiler) [
43 src = fetchFromGitHub {
46 rev = "rocm-${finalAttrs.version}";
47 hash = "sha256-vPi4UVljohVAfnwDVQqeOVaJPa6v8aV5uBOtqLddTtc=";
55 python3Packages.python
65 propagatedBuildInputs = [
72 "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
73 "-DLLVM_ENABLE_ZSTD=ON"
74 "-DLLVM_ENABLE_ZLIB=ON"
75 "-DLLVM_ENABLE_TERMINFO=ON"
77 # Manually define CMAKE_INSTALL_<DIR>
78 # See: https://github.com/NixOS/nixpkgs/pull/197838
79 "-DCMAKE_INSTALL_BINDIR=bin"
80 "-DCMAKE_INSTALL_LIBDIR=lib"
81 "-DCMAKE_INSTALL_INCLUDEDIR=include"
82 ] ++ lib.optionals buildRockCompiler [
83 "-DBUILD_FAT_LIBROCKCOMPILER=ON"
84 ] ++ lib.optionals (!buildRockCompiler) [
85 "-DROCM_TEST_CHIPSET=gfx000"
91 substituteInPlace mlir/utils/performance/common/CMakeLists.txt \
92 --replace "/opt/rocm" "${clr}"
98 # Certain libs aren't being generated, try enabling tests next update
99 checkTarget = if buildRockCompiler
100 then "librockCompiler"
103 else "check-rocmlir-build-only";
106 libPath = lib.makeLibraryPath [ zstd zlib ncurses clr stdenv.cc.cc ];
107 in lib.optionals (!buildRockCompiler) ''
108 mkdir -p $external/lib
109 cp -a external/llvm-project/llvm/lib/{*.a*,*.so*} $external/lib
110 patchelf --set-rpath $external/lib:$out/lib:${libPath} $external/lib/*.so*
111 patchelf --set-rpath $out/lib:$external/lib:${libPath} $out/{bin/*,lib/*.so*}
114 passthru.updateScript = rocmUpdateScript {
115 name = finalAttrs.pname;
116 owner = finalAttrs.src.owner;
117 repo = finalAttrs.src.repo;
118 page = "tags?per_page=2";
119 filter = ".[1].name | split(\"-\") | .[1]";
123 description = "MLIR-based convolution and GEMM kernel generator";
124 homepage = "https://github.com/ROCm/rocMLIR";
125 license = with licenses; [ asl20 ];
126 maintainers = teams.rocm.members;
127 platforms = platforms.linux;
128 broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "6.0.0";