nixpkgs/pkgs/development/compilers/llvm/16/libclc/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
2.3 KiB
Nix
Raw Normal View History

2023-10-28 11:24:04 +00:00
{ lib, stdenv, version, runCommand, monorepoSrc, llvm, buildPackages, buildLlvmTools, ninja, cmake, python3 }:
2015-03-28 20:54:27 +00:00
stdenv.mkDerivation rec {
pname = "libclc";
2023-10-28 11:24:04 +00:00
inherit version;
2015-03-28 20:54:27 +00:00
2023-10-28 11:24:04 +00:00
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
'';
sourceRoot = "${src.name}/${pname}";
2015-03-28 20:54:27 +00:00
2023-05-10 12:11:25 +00:00
outputs = [ "out" "dev" ];
2023-06-03 19:37:17 +00:00
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
2015-03-28 20:54:27 +00:00
postPatch = ''
substituteInPlace CMakeLists.txt \
2023-05-10 12:00:34 +00:00
--replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
2023-10-28 11:24:04 +00:00
'find_program( LLVM_CLANG clang PATHS "${buildLlvmTools.clang.cc}/bin" NO_DEFAULT_PATH )' \
2023-05-10 12:11:25 +00:00
--replace 'find_program( LLVM_AS llvm-as PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
2023-10-28 11:24:04 +00:00
'find_program( LLVM_AS llvm-as PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
2023-05-10 12:11:25 +00:00
--replace 'find_program( LLVM_LINK llvm-link PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
2023-10-28 11:24:04 +00:00
'find_program( LLVM_LINK llvm-link PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
2023-05-10 12:11:25 +00:00
--replace 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
2023-10-28 11:24:04 +00:00
'find_program( LLVM_OPT opt PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
2023-05-10 12:00:34 +00:00
--replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
2023-05-10 12:11:25 +00:00
'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 ${buildLlvmTools.libclc.dev}/bin/prepare_builtins'
2015-03-28 20:54:27 +00:00
'';
2023-05-10 12:11:25 +00:00
nativeBuildInputs = [ cmake ninja python3 ];
2023-10-28 11:24:04 +00:00
buildInputs = [ llvm ];
strictDeps = true;
2023-05-10 12:11:25 +00:00
postInstall = ''
install -Dt $dev/bin prepare_builtins
'';
meta = with lib; {
broken = stdenv.isDarwin;
homepage = "http://libclc.llvm.org/";
2015-05-13 13:32:32 +00:00
description = "Implementation of the library requirements of the OpenCL C programming language";
2015-03-28 20:54:27 +00:00
license = licenses.mit;
platforms = platforms.all;
};
}