2023-07-15 17:15:38 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, buildPackages, ninja, cmake, python3, llvm_14 }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libclc";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "16.0.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-07-21 07:28:18 +00:00
|
|
|
owner = "llvm";
|
|
|
|
repo = "llvm-project";
|
|
|
|
rev = "llvmorg-${version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-paWwnoU3XMqreRgh9JbT1tDMTwq/ZL0ss3SJTteEGL0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-08-04 22:07:22 +00:00
|
|
|
sourceRoot = "${src.name}/libclc";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./libclc-gnu-install-dirs.patch
|
|
|
|
];
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
# cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
2021-07-21 07:28:18 +00:00
|
|
|
substituteInPlace CMakeLists.txt \
|
2023-07-15 17:15:38 +00:00
|
|
|
--replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
|
|
'find_program( LLVM_CLANG clang PATHS "${buildPackages.clang_14.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 "${buildPackages.llvm_14}/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 "${buildPackages.llvm_14}/bin" NO_DEFAULT_PATH )' \
|
|
|
|
--replace 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
|
|
'find_program( LLVM_OPT opt PATHS "${buildPackages.llvm_14}/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'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
nativeBuildInputs = [ cmake ninja python3 ];
|
|
|
|
buildInputs = [ llvm_14 ];
|
2021-07-21 07:28:18 +00:00
|
|
|
strictDeps = true;
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
install -Dt $dev/bin prepare_builtins
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-06-16 17:23:12 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://libclc.llvm.org/";
|
|
|
|
description = "Implementation of the library requirements of the OpenCL C programming language";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|