about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTristan Ross <tristan.ross@midstall.com>2024-03-28 11:28:13 -0700
committerTristan Ross <tristan.ross@midstall.com>2024-04-12 07:22:03 -0700
commit8c71431f1414fcddcbf6b41c4d8d76b4f01853fb (patch)
tree512c6500fc3f18b215d70667922aa6381ab01293
parent8a9bde698902d452fa06d0d0c737951316bccb84 (diff)
llvmPackages_{12,13,14,15,16,17,18,git}: use common openmp
-rw-r--r--pkgs/development/compilers/llvm/12/default.nix11
-rw-r--r--pkgs/development/compilers/llvm/12/openmp/default.nix48
-rw-r--r--pkgs/development/compilers/llvm/13/default.nix10
-rw-r--r--pkgs/development/compilers/llvm/13/openmp/default.nix53
-rw-r--r--pkgs/development/compilers/llvm/14/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/14/openmp/default.nix69
-rw-r--r--pkgs/development/compilers/llvm/15/default.nix7
-rw-r--r--pkgs/development/compilers/llvm/15/openmp/default.nix74
-rw-r--r--pkgs/development/compilers/llvm/16/default.nix7
-rw-r--r--pkgs/development/compilers/llvm/17/default.nix7
-rw-r--r--pkgs/development/compilers/llvm/17/openmp/default.nix74
-rw-r--r--pkgs/development/compilers/llvm/18/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/18/openmp/default.nix73
-rw-r--r--pkgs/development/compilers/llvm/common/openmp/default.nix (renamed from pkgs/development/compilers/llvm/16/openmp/default.nix)72
-rw-r--r--pkgs/development/compilers/llvm/git/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/git/openmp/default.nix73
16 files changed, 94 insertions, 502 deletions
diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix
index bd87dc5f34f03..d9b1b7bb83f50 100644
--- a/pkgs/development/compilers/llvm/12/default.nix
+++ b/pkgs/development/compilers/llvm/12/default.nix
@@ -1,5 +1,6 @@
 { lowPrio, newScope, pkgs, lib, stdenv, cmake
 , preLibcCrossHeaders
+, fetchpatch
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
@@ -264,7 +265,15 @@ let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      src = fetch "openmp" "14dh0r6h2xh747ffgnsl4z08h0ri04azi9vf79cbz7ma1r27kzk0";
+      patches = [
+        # Fix cross.
+        (fetchpatch {
+          url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch";
+          hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A=";
+        })
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/12/openmp/default.nix b/pkgs/development/compilers/llvm/12/openmp/default.nix
deleted file mode 100644
index 6040f3d1621a9..0000000000000
--- a/pkgs/development/compilers/llvm/12/openmp/default.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, fetch
-, fetchpatch
-, cmake
-, llvm
-, targetLlvm
-, perl
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = fetch pname "14dh0r6h2xh747ffgnsl4z08h0ri04azi9vf79cbz7ma1r27kzk0";
-
-  patches = [
-    # Fix cross.
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch";
-      hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A=";
-    })
-  ];
-
-  patchFlags = [ "-p2" ];
-
-  nativeBuildInputs = [ cmake perl ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix
index cd96231e62c35..bab1eab57e8b5 100644
--- a/pkgs/development/compilers/llvm/13/default.nix
+++ b/pkgs/development/compilers/llvm/13/default.nix
@@ -1,5 +1,6 @@
 { lowPrio, newScope, pkgs, lib, stdenv, cmake
 , preLibcCrossHeaders
+, fetchpatch
 , libxml2, python3, isl, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildLlvmTools # tools, but from the previous stage, for cross
 , targetLlvmLibraries # libraries, but from the next stage, for cross
@@ -304,7 +305,14 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        # Fix cross.
+        (fetchpatch {
+          url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch";
+          hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A=";
+        })
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/13/openmp/default.nix b/pkgs/development/compilers/llvm/13/openmp/default.nix
deleted file mode 100644
index 7b461df438f9a..0000000000000
--- a/pkgs/development/compilers/llvm/13/openmp/default.nix
+++ /dev/null
@@ -1,53 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, src
-, fetchpatch
-, cmake
-, llvm
-, targetLlvm
-, perl
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  inherit src;
-  sourceRoot = "${src.name}/${pname}";
-
-  patches = [
-    # Fix cross.
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch";
-      hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A=";
-    })
-  ];
-
-  patchFlags = [ "-p2" ];
-
-  nativeBuildInputs = [ cmake perl ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  cmakeFlags = [
-    "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL currently fails
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix
index 66f5c7385a150..c6048aabf75e3 100644
--- a/pkgs/development/compilers/llvm/14/default.nix
+++ b/pkgs/development/compilers/llvm/14/default.nix
@@ -302,7 +302,11 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        ./openmp/gnu-install-dirs.patch
+        ./openmp/run-lit-directly.patch
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix
deleted file mode 100644
index d1c6a46b4d693..0000000000000
--- a/pkgs/development/compilers/llvm/14/openmp/default.nix
+++ /dev/null
@@ -1,69 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, monorepoSrc
-, runCommand
-, cmake
-, llvm
-, targetLlvm
-, lit
-, clang-unwrapped
-, perl
-, pkg-config
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-  '';
-
-  sourceRoot = "${src.name}/${pname}";
-
-  patches = [
-    ./gnu-install-dirs.patch
-    ./run-lit-directly.patch
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ cmake perl pkg-config lit ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  # Unsup:Pass:XFail:Fail
-  # 26:267:16:8
-  doCheck = false;
-  checkTarget = "check-openmp";
-
-  preCheck = ''
-    patchShebangs ../tools/archer/tests/deflake.bash
-  '';
-
-  cmakeFlags = [
-    "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
-    "-DOPT_TOOL=${llvm}/bin/opt"
-    "-DLINK_TOOL=${llvm}/bin/llvm-link"
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix
index 0ccb9c449a8da..6af83d4db1854 100644
--- a/pkgs/development/compilers/llvm/15/default.nix
+++ b/pkgs/development/compilers/llvm/15/default.nix
@@ -320,7 +320,12 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        ./openmp/fix-find-tool.patch
+        ./openmp/gnu-install-dirs.patch
+        ./openmp/run-lit-directly.patch
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/15/openmp/default.nix b/pkgs/development/compilers/llvm/15/openmp/default.nix
deleted file mode 100644
index d51335436ad23..0000000000000
--- a/pkgs/development/compilers/llvm/15/openmp/default.nix
+++ /dev/null
@@ -1,74 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, monorepoSrc
-, runCommand
-, cmake
-, ninja
-, llvm
-, targetLlvm
-, lit
-, clang-unwrapped
-, perl
-, pkg-config
-, xcbuild
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-  '';
-
-  sourceRoot = "${src.name}/${pname}";
-
-  patches = [
-    ./fix-find-tool.patch
-    ./gnu-install-dirs.patch
-    ./run-lit-directly.patch
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
-
-  # Unsup:Pass:XFail:Fail
-  # 26:267:16:8
-  doCheck = false;
-  checkTarget = "check-openmp";
-
-  preCheck = ''
-    patchShebangs ../tools/archer/tests/deflake.bash
-  '';
-
-  cmakeFlags = [
-    "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
-    "-DOPT_TOOL=${llvm}/bin/opt"
-    "-DLINK_TOOL=${llvm}/bin/llvm-link"
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix
index 66185071f22b7..89801b595d16a 100644
--- a/pkgs/development/compilers/llvm/16/default.nix
+++ b/pkgs/development/compilers/llvm/16/default.nix
@@ -335,7 +335,12 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        ./openmp/fix-find-tool.patch
+        ./openmp/gnu-install-dirs.patch
+        ./openmp/run-lit-directly.patch
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix
index c8d9569253450..ab6bff359cf6a 100644
--- a/pkgs/development/compilers/llvm/17/default.nix
+++ b/pkgs/development/compilers/llvm/17/default.nix
@@ -320,7 +320,12 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        ./openmp/fix-find-tool.patch
+        ./openmp/gnu-install-dirs.patch
+        ./openmp/run-lit-directly.patch
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/17/openmp/default.nix b/pkgs/development/compilers/llvm/17/openmp/default.nix
deleted file mode 100644
index d51335436ad23..0000000000000
--- a/pkgs/development/compilers/llvm/17/openmp/default.nix
+++ /dev/null
@@ -1,74 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, monorepoSrc
-, runCommand
-, cmake
-, ninja
-, llvm
-, targetLlvm
-, lit
-, clang-unwrapped
-, perl
-, pkg-config
-, xcbuild
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-  '';
-
-  sourceRoot = "${src.name}/${pname}";
-
-  patches = [
-    ./fix-find-tool.patch
-    ./gnu-install-dirs.patch
-    ./run-lit-directly.patch
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
-
-  # Unsup:Pass:XFail:Fail
-  # 26:267:16:8
-  doCheck = false;
-  checkTarget = "check-openmp";
-
-  preCheck = ''
-    patchShebangs ../tools/archer/tests/deflake.bash
-  '';
-
-  cmakeFlags = [
-    "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
-    "-DOPT_TOOL=${llvm}/bin/opt"
-    "-DLINK_TOOL=${llvm}/bin/llvm-link"
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/18/default.nix b/pkgs/development/compilers/llvm/18/default.nix
index dd3000c042594..0677f0eea8be3 100644
--- a/pkgs/development/compilers/llvm/18/default.nix
+++ b/pkgs/development/compilers/llvm/18/default.nix
@@ -320,7 +320,11 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        ./openmp/fix-find-tool.patch
+        ./openmp/run-lit-directly.patch
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/18/openmp/default.nix b/pkgs/development/compilers/llvm/18/openmp/default.nix
deleted file mode 100644
index e1c3c2379af2a..0000000000000
--- a/pkgs/development/compilers/llvm/18/openmp/default.nix
+++ /dev/null
@@ -1,73 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, monorepoSrc
-, runCommand
-, cmake
-, ninja
-, llvm
-, targetLlvm
-, lit
-, clang-unwrapped
-, perl
-, pkg-config
-, xcbuild
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-  '';
-
-  sourceRoot = "${src.name}/${pname}";
-
-  patches = [
-    ./fix-find-tool.patch
-    ./run-lit-directly.patch
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
-
-  # Unsup:Pass:XFail:Fail
-  # 26:267:16:8
-  doCheck = false;
-  checkTarget = "check-openmp";
-
-  preCheck = ''
-    patchShebangs ../tools/archer/tests/deflake.bash
-  '';
-
-  cmakeFlags = [
-    "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
-    "-DOPT_TOOL=${llvm}/bin/opt"
-    "-DLINK_TOOL=${llvm}/bin/llvm-link"
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}
diff --git a/pkgs/development/compilers/llvm/16/openmp/default.nix b/pkgs/development/compilers/llvm/common/openmp/default.nix
index d51335436ad23..7d9d813f024c7 100644
--- a/pkgs/development/compilers/llvm/16/openmp/default.nix
+++ b/pkgs/development/compilers/llvm/common/openmp/default.nix
@@ -1,7 +1,10 @@
 { lib
 , stdenv
 , llvm_meta
-, monorepoSrc
+, release_version
+, patches ? []
+, monorepoSrc ? null
+, src ? null
 , runCommand
 , cmake
 , ninja
@@ -14,44 +17,47 @@
 , xcbuild
 , version
 }:
-
-stdenv.mkDerivation rec {
+let
   pname = "openmp";
-  inherit version;
+  src' =
+    if monorepoSrc != null then
+      runCommand "${pname}-src-${version}" {} ''
+        mkdir -p "$out"
+        cp -r ${monorepoSrc}/cmake "$out"
+        cp -r ${monorepoSrc}/${pname} "$out"
+      '' else src;
+in
+stdenv.mkDerivation (rec {
+  inherit pname version patches;
 
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-  '';
+  src = src';
 
-  sourceRoot = "${src.name}/${pname}";
+  sourceRoot =
+    if lib.versionOlder release_version "13" then null
+    else "${src.name}/${pname}";
 
-  patches = [
-    ./fix-find-tool.patch
-    ./gnu-install-dirs.patch
-    ./run-lit-directly.patch
-  ];
+  outputs = [ "out" ]
+    ++ lib.optionals (lib.versionAtLeast release_version "14") [ "dev" ];
 
-  outputs = [ "out" "dev" ];
+  patchFlags =
+    if lib.versionOlder release_version "14" then [ "-p2" ]
+    else null;
+
+  nativeBuildInputs = [
+    cmake
+  ] ++ lib.optionals (lib.versionAtLeast release_version "15") [
+    ninja
+  ] ++ [ perl ] ++ lib.optionals (lib.versionAtLeast release_version "14") [
+    pkg-config lit
+  ];
 
-  nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
   buildInputs = [
     (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
   ];
 
-  nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
-
-  # Unsup:Pass:XFail:Fail
-  # 26:267:16:8
-  doCheck = false;
-  checkTarget = "check-openmp";
-
-  preCheck = ''
-    patchShebangs ../tools/archer/tests/deflake.bash
-  '';
-
-  cmakeFlags = [
+  cmakeFlags = lib.optionals (lib.versions.major release_version == "13") [
+    "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL fails
+  ] ++ lib.optionals (lib.versionAtLeast release_version "14") [
     "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
     "-DOPT_TOOL=${llvm}/bin/opt"
     "-DLINK_TOOL=${llvm}/bin/llvm-link"
@@ -71,4 +77,10 @@ stdenv.mkDerivation rec {
     # License (a BSD-like license)":
     license = with lib.licenses; [ mit ncsa ];
   };
-}
+} // (lib.optionalAttrs (lib.versionAtLeast release_version "14") {
+  doCheck = false;
+  checkTarget = "check-openmp";
+  preCheck = ''
+    patchShebangs ../tools/archer/tests/deflake.bash
+  '';
+}))
diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix
index 80cff85372d06..14c2880eed95d 100644
--- a/pkgs/development/compilers/llvm/git/default.nix
+++ b/pkgs/development/compilers/llvm/git/default.nix
@@ -325,7 +325,11 @@ in let
       stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
     };
 
-    openmp = callPackage ./openmp {
+    openmp = callPackage ../common/openmp {
+      patches = [
+        ./openmp/fix-find-tool.patch
+        ./openmp/run-lit-directly.patch
+      ];
       inherit llvm_meta targetLlvm;
     };
   });
diff --git a/pkgs/development/compilers/llvm/git/openmp/default.nix b/pkgs/development/compilers/llvm/git/openmp/default.nix
deleted file mode 100644
index e1c3c2379af2a..0000000000000
--- a/pkgs/development/compilers/llvm/git/openmp/default.nix
+++ /dev/null
@@ -1,73 +0,0 @@
-{ lib
-, stdenv
-, llvm_meta
-, monorepoSrc
-, runCommand
-, cmake
-, ninja
-, llvm
-, targetLlvm
-, lit
-, clang-unwrapped
-, perl
-, pkg-config
-, xcbuild
-, version
-}:
-
-stdenv.mkDerivation rec {
-  pname = "openmp";
-  inherit version;
-
-  src = runCommand "${pname}-src-${version}" {} ''
-    mkdir -p "$out"
-    cp -r ${monorepoSrc}/cmake "$out"
-    cp -r ${monorepoSrc}/${pname} "$out"
-  '';
-
-  sourceRoot = "${src.name}/${pname}";
-
-  patches = [
-    ./fix-find-tool.patch
-    ./run-lit-directly.patch
-  ];
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
-  buildInputs = [
-    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
-  ];
-
-  nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
-
-  # Unsup:Pass:XFail:Fail
-  # 26:267:16:8
-  doCheck = false;
-  checkTarget = "check-openmp";
-
-  preCheck = ''
-    patchShebangs ../tools/archer/tests/deflake.bash
-  '';
-
-  cmakeFlags = [
-    "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
-    "-DOPT_TOOL=${llvm}/bin/opt"
-    "-DLINK_TOOL=${llvm}/bin/llvm-link"
-  ];
-
-  meta = llvm_meta // {
-    homepage = "https://openmp.llvm.org/";
-    description = "Support for the OpenMP language";
-    longDescription = ''
-      The OpenMP subproject of LLVM contains the components required to build an
-      executable OpenMP program that are outside the compiler itself.
-      Contains the code for the runtime library against which code compiled by
-      "clang -fopenmp" must be linked before it can run and the library that
-      supports offload to target devices.
-    '';
-    # "All of the code is dual licensed under the MIT license and the UIUC
-    # License (a BSD-like license)":
-    license = with lib.licenses; [ mit ncsa ];
-  };
-}