summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm/16/libclc/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-11-21 16:12:21 +0100
committerAlyssa Ross <hi@alyssa.is>2023-11-21 16:12:48 +0100
commit048a4cd441a59cbf89defb18bb45c9f0b4429b35 (patch)
treef8f5850ff05521ab82d65745894714a8796cbfb6 /pkgs/development/compilers/llvm/16/libclc/default.nix
parent030c5028b07afcedce7c5956015c629486cc79d9 (diff)
parent4c2d05dd6435d449a3651a6dd314d9411b5f8146 (diff)
downloadnixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar
nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.gz
nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.bz2
nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.lz
nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.xz
nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.tar.zst
nixpkgs-048a4cd441a59cbf89defb18bb45c9f0b4429b35.zip
Rebase onto e4ad989506ec7d71f7302cc3067abd82730a4beb HEAD rootfs
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Diffstat (limited to 'pkgs/development/compilers/llvm/16/libclc/default.nix')
-rw-r--r--pkgs/development/compilers/llvm/16/libclc/default.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/pkgs/development/compilers/llvm/16/libclc/default.nix b/pkgs/development/compilers/llvm/16/libclc/default.nix
new file mode 100644
index 00000000000..6fa0751f906
--- /dev/null
+++ b/pkgs/development/compilers/llvm/16/libclc/default.nix
@@ -0,0 +1,54 @@
+{ lib, stdenv, version, runCommand, monorepoSrc, llvm, buildPackages, buildLlvmTools, ninja, cmake, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "libclc";
+  inherit version;
+
+  src = runCommand "${pname}-src-${version}" {} ''
+    mkdir -p "$out"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/${pname} "$out"
+  '';
+
+  sourceRoot = "${src.name}/${pname}";
+
+  outputs = [ "out" "dev" ];
+
+  patches = [
+    ./libclc-gnu-install-dirs.patch
+  ];
+
+  # cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
+  postPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
+                'find_program( LLVM_CLANG clang PATHS "${buildLlvmTools.clang.cc}/bin" NO_DEFAULT_PATH )' \
+      --replace 'find_program( LLVM_AS llvm-as PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
+                'find_program( LLVM_AS llvm-as PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
+      --replace 'find_program( LLVM_LINK llvm-link PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
+                'find_program( LLVM_LINK llvm-link PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
+      --replace 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
+                'find_program( LLVM_OPT opt PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
+      --replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
+                'find_program( LLVM_SPIRV llvm-spirv PATHS "${buildPackages.spirv-llvm-translator}/bin" NO_DEFAULT_PATH )'
+  '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
+    substituteInPlace CMakeLists.txt \
+      --replace 'COMMAND prepare_builtins' 'COMMAND ${buildPackages.libclc.dev}/bin/prepare_builtins'
+  '';
+
+  nativeBuildInputs = [ cmake ninja python3 ];
+  buildInputs = [ llvm ];
+  strictDeps = true;
+
+  postInstall = ''
+    install -Dt $dev/bin prepare_builtins
+  '';
+
+  meta = with lib; {
+    broken = stdenv.isDarwin;
+    homepage = "http://libclc.llvm.org/";
+    description = "Implementation of the library requirements of the OpenCL C programming language";
+    license = licenses.mit;
+    platforms = platforms.all;
+  };
+}