about summary refs log tree commit diff
path: root/pkgs/development/rocm-modules/6/llvm/stage-3
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/rocm-modules/6/llvm/stage-3')
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch36
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/1000-openmp-failing-tests.list122
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/1001-mlir-failing-tests.list11
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/clang-tools-extra.nix42
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix73
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/flang.nix31
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix36
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/lldb.nix39
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix57
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/openmp.nix54
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix18
-rw-r--r--pkgs/development/rocm-modules/6/llvm/stage-3/pstl.nix15
12 files changed, 534 insertions, 0 deletions
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch b/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch
new file mode 100644
index 000000000000..f4221a088136
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/0000-mlir-fix-debugtranslation.patch
@@ -0,0 +1,36 @@
+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/pkgs/development/rocm-modules/6/llvm/stage-3/1000-openmp-failing-tests.list b/pkgs/development/rocm-modules/6/llvm/stage-3/1000-openmp-failing-tests.list
new file mode 100644
index 000000000000..e53b21b3c535
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/1000-openmp-failing-tests.list
@@ -0,0 +1,122 @@
+runtime/test/tasking/hidden_helper_task/gtid.cpp
+runtime/test/ompt/parallel/parallel_if0.c
+runtime/test/ompt/parallel/serialized.c
+runtime/test/ompt/teams/parallel_team.c
+runtime/test/ompt/teams/serial_teams.c
+runtime/test/ompt/teams/serialized.c
+runtime/test/ompt/teams/team.c
+libomptarget/test/api/assert.c
+libomptarget/test/api/omp_device_managed_memory.c
+libomptarget/test/api/omp_device_memory.c
+libomptarget/test/api/omp_get_device_num.c
+libomptarget/test/api/omp_host_pinned_memory.c
+libomptarget/test/api/omp_host_pinned_memory_alloc.c
+libomptarget/test/api/omp_target_memcpy_async1.c
+libomptarget/test/api/omp_target_memcpy_async2.c
+libomptarget/test/api/omp_target_memcpy_rect_async1.c
+libomptarget/test/api/omp_target_memcpy_rect_async2.c
+libomptarget/test/mapping/array_section_implicit_capture.c
+libomptarget/test/mapping/data_absent_at_exit.c
+libomptarget/test/mapping/data_member_ref.cpp
+libomptarget/test/mapping/declare_mapper_api.cpp
+libomptarget/test/mapping/declare_mapper_target.cpp
+libomptarget/test/mapping/declare_mapper_target_data.cpp
+libomptarget/test/mapping/declare_mapper_target_data_enter_exit.cpp
+libomptarget/test/mapping/firstprivate_aligned.cpp
+libomptarget/test/mapping/has_device_addr.cpp
+libomptarget/test/mapping/implicit_device_ptr.c
+libomptarget/test/mapping/is_device_ptr.cpp
+libomptarget/test/mapping/lambda_mapping.cpp
+libomptarget/test/mapping/low_alignment.c
+libomptarget/test/mapping/map_back_race.cpp
+libomptarget/test/mapping/power_of_two_alignment.c
+libomptarget/test/mapping/pr38704.c
+libomptarget/test/mapping/prelock.cpp
+libomptarget/test/mapping/present/target_data_at_exit.c
+libomptarget/test/mapping/private_mapping.c
+libomptarget/test/mapping/ptr_and_obj_motion.c
+libomptarget/test/mapping/reduction_implicit_map.cpp
+libomptarget/test/mapping/target_derefence_array_pointrs.cpp
+libomptarget/test/mapping/target_map_for_member_data.cpp
+libomptarget/test/mapping/target_update_array_extension.c
+libomptarget/test/mapping/target_use_device_addr.c
+libomptarget/test/offloading/atomic-compare-signedness.c
+libomptarget/test/offloading/bug47654.cpp
+libomptarget/test/offloading/bug49021.cpp
+libomptarget/test/offloading/bug49779.cpp
+libomptarget/test/offloading/bug50022.cpp
+libomptarget/test/offloading/bug51781.c
+libomptarget/test/offloading/bug51982.c
+libomptarget/test/offloading/bug53727.cpp
+libomptarget/test/offloading/complex_reduction.cpp
+libomptarget/test/offloading/cuda_no_devices.c
+libomptarget/test/offloading/d2d_memcpy.c
+libomptarget/test/offloading/dynamic_module.c
+libomptarget/test/offloading/dynamic_module_load.c
+libomptarget/test/offloading/global_constructor.cpp
+libomptarget/test/offloading/lone_target_exit_data.c
+libomptarget/test/offloading/memory_manager.cpp
+libomptarget/test/offloading/parallel_offloading_map.cpp
+libomptarget/test/offloading/static_linking.c
+libomptarget/test/offloading/std_complex_arithmetic.cpp
+libomptarget/test/offloading/target-teams-atomic.c
+libomptarget/test/offloading/target_constexpr_mapping.cpp
+libomptarget/test/offloading/target_critical_region.cpp
+libomptarget/test/offloading/target_depend_nowait.cpp
+libomptarget/test/offloading/target_nowait_target.cpp
+libomptarget/test/offloading/taskloop_offload_nowait.cpp
+libomptarget/test/offloading/test_libc.cpp
+libomptarget/test/ompt/veccopy.c
+libomptarget/test/ompt/veccopy_disallow_both.c
+libomptarget/test/ompt/veccopy_emi.c
+libomptarget/test/ompt/veccopy_emi_map.c
+libomptarget/test/ompt/veccopy_map.c
+libomptarget/test/ompt/veccopy_no_device_init.c
+libomptarget/test/ompt/veccopy_wrong_return.c
+libomptarget/test/api/is_initial_device.c
+libomptarget/test/mapping/declare_mapper_nested_default_mappers_array_subscript.cpp
+libomptarget/test/mapping/declare_mapper_nested_default_mappers_ptr_subscript.cpp
+libomptarget/test/mapping/declare_mapper_nested_default_mappers_var.cpp
+libomptarget/test/mapping/target_pointers_members_map.cpp
+libomptarget/test/api/omp_dynamic_shared_memory_mixed.c
+libomptarget/test/api/omp_env_vars.c
+libomptarget/test/api/omp_get_mapped_ptr.c
+libomptarget/test/api/omp_get_num_devices.c
+libomptarget/test/api/omp_get_num_devices_with_empty_target.c
+libomptarget/test/mapping/alloc_fail.c
+libomptarget/test/mapping/array_section_use_device_ptr.c
+libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
+libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
+libomptarget/test/mapping/declare_mapper_target_update.cpp
+libomptarget/test/mapping/delete_inf_refcount.c
+libomptarget/test/mapping/lambda_by_value.cpp
+libomptarget/test/mapping/ompx_hold/omp_target_disassociate_ptr.c
+libomptarget/test/mapping/ompx_hold/struct.c
+libomptarget/test/mapping/ompx_hold/target-data.c
+libomptarget/test/mapping/ompx_hold/target.c
+libomptarget/test/mapping/present/target.c
+libomptarget/test/mapping/present/target_array_extension.c
+libomptarget/test/mapping/present/target_data.c
+libomptarget/test/mapping/present/target_data_array_extension.c
+libomptarget/test/mapping/present/target_enter_data.c
+libomptarget/test/mapping/present/target_exit_data_delete.c
+libomptarget/test/mapping/present/target_exit_data_release.c
+libomptarget/test/mapping/present/target_update.c
+libomptarget/test/mapping/present/target_update_array_extension.c
+libomptarget/test/mapping/present/zero_length_array_section.c
+libomptarget/test/mapping/present/zero_length_array_section_exit.c
+libomptarget/test/mapping/target_data_array_extension_at_exit.c
+libomptarget/test/mapping/target_has_device_addr.c
+libomptarget/test/mapping/target_implicit_partial_map.c
+libomptarget/test/mapping/target_wrong_use_device_addr.c
+libomptarget/test/offloading/host_as_target.c
+libomptarget/test/offloading/info.c
+libomptarget/test/offloading/offloading_success.c
+libomptarget/test/offloading/offloading_success.cpp
+libomptarget/test/offloading/wtime.c
+libomptarget/test/unified_shared_memory/api.c
+libomptarget/test/unified_shared_memory/associate_ptr.c
+libomptarget/test/unified_shared_memory/close_enter_exit.c
+libomptarget/test/unified_shared_memory/close_manual.c
+libomptarget/test/unified_shared_memory/close_member.c
+libomptarget/test/unified_shared_memory/close_modifier.c
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/1001-mlir-failing-tests.list b/pkgs/development/rocm-modules/6/llvm/stage-3/1001-mlir-failing-tests.list
new file mode 100644
index 000000000000..0b3d2d22592d
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/1001-mlir-failing-tests.list
@@ -0,0 +1,11 @@
+./test/Target/LLVMIR/openmp-llvm.mlir
+./test/mlir-spirv-cpu-runner/double.mlir
+./test/mlir-spirv-cpu-runner/simple_add.mlir
+./test/mlir-vulkan-runner/addf.mlir
+./test/mlir-vulkan-runner/addi.mlir
+./test/mlir-vulkan-runner/addi8.mlir
+./test/mlir-vulkan-runner/mulf.mlir
+./test/mlir-vulkan-runner/smul_extended.mlir
+./test/mlir-vulkan-runner/subf.mlir
+./test/mlir-vulkan-runner/time.mlir
+./test/mlir-vulkan-runner/umul_extended.mlir
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/clang-tools-extra.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/clang-tools-extra.nix
new file mode 100644
index 000000000000..d18673ecb3db
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/clang-tools-extra.nix
@@ -0,0 +1,42 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, clang-unwrapped
+, gtest
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildTests = false; # `invalid operands to binary expression ('std::basic_stringstream<char>' and 'const llvm::StringRef')`
+  targetName = "clang-tools-extra";
+
+  targetProjects = [
+    "clang"
+    "clang-tools-extra"
+  ];
+
+  extraBuildInputs = [ gtest ];
+
+  extraCMakeFlags = [
+    "-DLLVM_INCLUDE_DOCS=OFF"
+    "-DLLVM_INCLUDE_TESTS=OFF"
+    "-DCLANG_INCLUDE_DOCS=OFF"
+    "-DCLANG_INCLUDE_TESTS=ON"
+    "-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON"
+  ];
+
+  extraPostInstall = ''
+    # Remove LLVM and Clang
+    for path in `find ${llvm} ${clang-unwrapped}`; do
+      if [ $path != ${llvm} ] && [ $path != ${clang-unwrapped} ]; then
+        rm -f $out''${path#${llvm}} $out''${path#${clang-unwrapped}} || true
+      fi
+    done
+
+    # Cleanup empty directories
+    find $out -type d -empty -delete
+  '';
+
+  requiredSystemFeatures = [ "big-parallel" ];
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix
new file mode 100644
index 000000000000..91f34265f85f
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/clang.nix
@@ -0,0 +1,73 @@
+{ stdenv
+, wrapCCWith
+, llvm
+, lld
+, clang-unwrapped
+, bintools
+, libc
+, libunwind
+, libcxxabi
+, libcxx
+, compiler-rt
+}:
+
+wrapCCWith rec {
+  inherit libcxx bintools;
+
+  # We do this to avoid HIP pathing problems, and mimic a monolithic install
+  cc = stdenv.mkDerivation (finalAttrs: {
+    inherit (clang-unwrapped) version;
+    pname = "rocm-llvm-clang";
+    dontUnpack = true;
+
+    installPhase = ''
+      runHook preInstall
+
+      clang_version=`${clang-unwrapped}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+      mkdir -p $out/{bin,include/c++/v1,lib/{cmake,clang/$clang_version/{include,lib}},libexec,share}
+
+      for path in ${llvm} ${clang-unwrapped} ${lld} ${libc} ${libunwind} ${libcxxabi} ${libcxx} ${compiler-rt}; do
+        cp -as $path/* $out
+        chmod +w $out/{*,include/c++/v1,lib/{clang/$clang_version/include,cmake}}
+        rm -f $out/lib/libc++.so
+      done
+
+      ln -s $out/lib/* $out/lib/clang/$clang_version/lib
+      ln -sf $out/include/* $out/lib/clang/$clang_version/include
+
+      runHook postInstall
+    '';
+
+    passthru.isClang = true;
+  });
+
+  extraPackages = [
+    llvm
+    lld
+    libc
+    libunwind
+    libcxxabi
+    compiler-rt
+  ];
+
+  nixSupport.cc-cflags = [
+    "-resource-dir=$out/resource-root"
+    "-fuse-ld=lld"
+    "-rtlib=compiler-rt"
+    "-unwindlib=libunwind"
+    "-Wno-unused-command-line-argument"
+  ];
+
+  extraBuildCommands = ''
+    clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+    mkdir -p $out/resource-root
+    ln -s ${cc}/lib/clang/$clang_version/{include,lib} $out/resource-root
+
+    # Not sure why, but hardening seems to make things break
+    echo "" > $out/nix-support/add-hardening.sh
+
+    # 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 ;;"
+  '';
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/flang.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/flang.nix
new file mode 100644
index 000000000000..421663dcb1b7
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/flang.nix
@@ -0,0 +1,31 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, clang-unwrapped
+, mlir
+, graphviz
+, python3Packages
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  targetName = "flang";
+  targetDir = targetName;
+
+  extraNativeBuildInputs = [
+    graphviz
+    python3Packages.sphinx-markdown-tables
+  ];
+
+  extraBuildInputs = [ mlir ];
+
+  extraCMakeFlags = [
+    "-DCLANG_DIR=${clang-unwrapped}/lib/cmake/clang"
+    "-DMLIR_TABLEGEN_EXE=${mlir}/bin/mlir-tblgen"
+    "-DCLANG_TABLEGEN_EXE=${clang-unwrapped}/bin/clang-tblgen"
+    "-DFLANG_INCLUDE_TESTS=OFF" # `The dependency target "Bye" of target ...`
+  ];
+
+  # `flang/lib/Semantics/check-omp-structure.cpp:1905:1: error: no member named 'v' in 'Fortran::parser::OmpClause::OmpxDynCgroupMem'`
+  isBroken = true;
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix
new file mode 100644
index 000000000000..1fd72ee67188
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/libclc.nix
@@ -0,0 +1,36 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, clang
+, spirv-llvm-translator
+}:
+
+let
+  spirv = (spirv-llvm-translator.override { inherit llvm; });
+in callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No documentation to build
+  buildMan = false; # No man pages to build
+  targetName = "libclc";
+  targetDir = targetName;
+  extraBuildInputs = [ spirv ];
+
+  # `spirv-mesa3d` isn't compiling with LLVM 15.0.0, it does with LLVM 14.0.0
+  # Try removing the `spirv-mesa3d` and `clspv` patches next update
+  # `clspv` tests fail, unresolved calls
+  extraPostPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace "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 )" \
+        "find_program( LLVM_SPIRV llvm-spirv PATHS \"${spirv}/bin\" NO_DEFAULT_PATH )" \
+      --replace "  spirv-mesa3d-" "" \
+      --replace "  spirv64-mesa3d-" "" \
+      --replace "NOT \''${t} MATCHES" \
+        "NOT \''${ARCH} STREQUAL \"clspv\" AND NOT \''${ARCH} STREQUAL \"clspv64\" AND NOT \''${t} MATCHES"
+  '';
+
+  checkTargets = [ ];
+  isBroken = true; # ROCm 5.7.0 doesn't have IR/AttributeMask.h yet...?
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/lldb.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/lldb.nix
new file mode 100644
index 000000000000..9b7d25e06d9d
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/lldb.nix
@@ -0,0 +1,39 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, clang
+, xz
+, swig
+, lua5_3
+, graphviz
+, gtest
+, python3Packages
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildTests = false; # FIXME: Bad pathing for clang executable in tests, using relative path most likely
+  targetName = "lldb";
+  targetDir = targetName;
+  extraNativeBuildInputs = [ python3Packages.sphinx-automodapi ];
+
+  extraBuildInputs = [
+    xz
+    swig
+    lua5_3
+    graphviz
+    gtest
+  ];
+
+  extraCMakeFlags = [
+    "-DLLDB_EXTERNAL_CLANG_RESOURCE_DIR=${clang}/resource-root/lib/clang/$clang_version"
+    "-DLLDB_INCLUDE_TESTS=ON"
+    "-DLLDB_INCLUDE_UNITTESTS=ON"
+  ];
+
+  extraPostPatch = ''
+    export clang_version=`clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix
new file mode 100644
index 000000000000..6de685ea2771
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix
@@ -0,0 +1,57 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+, clr
+, vulkan-headers
+, vulkan-loader
+, glslang
+, shaderc
+, lit
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No decent way to hack this to work
+  buildMan = false; # No man pages to build
+  targetName = "mlir";
+  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 ];
+  extraNativeBuildInputs = [ clr ];
+
+  extraBuildInputs = [
+    vulkan-headers
+    vulkan-loader
+    glslang
+    shaderc
+  ];
+
+  extraCMakeFlags = [
+    "-DMLIR_INCLUDE_DOCS=ON"
+    "-DMLIR_INCLUDE_TESTS=ON"
+    "-DMLIR_ENABLE_ROCM_RUNNER=ON"
+    "-DMLIR_ENABLE_SPIRV_CPU_RUNNER=ON"
+    "-DMLIR_ENABLE_VULKAN_RUNNER=ON"
+    "-DROCM_TEST_CHIPSET=gfx000" # CPU runner
+  ];
+
+  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"
+
+    # Mainly `No such file or directory`
+    cat ${./1001-mlir-failing-tests.list} | xargs -d \\n rm
+  '';
+
+  extraPostInstall = ''
+    mkdir -p $out/bin
+    mv bin/mlir-tblgen $out/bin
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+  requiredSystemFeatures = [ "big-parallel" ];
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/openmp.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/openmp.nix
new file mode 100644
index 000000000000..5fd7b6fd9aa3
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/openmp.nix
@@ -0,0 +1,54 @@
+{ lib
+, stdenv
+, callPackage
+, rocmUpdateScript
+, llvm
+, clang
+, clang-unwrapped
+, rocm-device-libs
+, rocm-runtime
+, rocm-thunk
+, perl
+, elfutils
+, libdrm
+, numactl
+, lit
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  targetName = "openmp";
+  targetDir = targetName;
+  extraNativeBuildInputs = [ perl ];
+
+  extraBuildInputs = [
+    rocm-device-libs
+    rocm-runtime
+    rocm-thunk
+    elfutils
+    libdrm
+    numactl
+  ];
+
+  extraCMakeFlags = [
+    "-DCMAKE_MODULE_PATH=/build/source/llvm/cmake/modules" # For docs
+    "-DCLANG_TOOL=${clang}/bin/clang"
+    "-DCLANG_OFFLOAD_BUNDLER_TOOL=${clang-unwrapped}/bin/clang-offload-bundler"
+    "-DPACKAGER_TOOL=${clang-unwrapped}/bin/clang-offload-packager"
+    "-DOPENMP_LLVM_TOOLS_DIR=${llvm}/bin"
+    "-DOPENMP_LLVM_LIT_EXECUTABLE=${lit}/bin/.lit-wrapped"
+    "-DDEVICELIBS_ROOT=${rocm-device-libs.src}"
+  ];
+
+  extraPostPatch = ''
+    # We can't build this target at the moment
+    substituteInPlace libomptarget/DeviceRTL/CMakeLists.txt \
+      --replace "gfx1010" ""
+
+    # No idea what's going on here...
+    cat ${./1000-openmp-failing-tests.list} | xargs -d \\n rm
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+  extraLicenses = [ lib.licenses.mit ];
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix
new file mode 100644
index 000000000000..e001f33dfd43
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/polly.nix
@@ -0,0 +1,18 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  targetName = "polly";
+  targetDir = targetName;
+
+  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"
+  '';
+
+  checkTargets = [ "check-${targetName}" ];
+}
diff --git a/pkgs/development/rocm-modules/6/llvm/stage-3/pstl.nix b/pkgs/development/rocm-modules/6/llvm/stage-3/pstl.nix
new file mode 100644
index 000000000000..dc7d7cd6ccbf
--- /dev/null
+++ b/pkgs/development/rocm-modules/6/llvm/stage-3/pstl.nix
@@ -0,0 +1,15 @@
+{ stdenv
+, callPackage
+, rocmUpdateScript
+}:
+
+callPackage ../base.nix rec {
+  inherit stdenv rocmUpdateScript;
+  buildDocs = false; # No documentation to build
+  buildMan = false; # No man pages to build
+  buildTests = false; # Too many errors
+  targetName = "pstl";
+  targetDir = "runtimes";
+  targetRuntimes = [ targetName ];
+  checkTargets = [ "check-${targetName}" ];
+}