1 { lib, stdenv, fetchFromGitHub, ninja, cmake, python3, llvmPackages, spirv-llvm-translator }:
4 llvm = llvmPackages.llvm;
5 clang-unwrapped = llvmPackages.clang-unwrapped;
8 stdenv.mkDerivation rec {
12 src = fetchFromGitHub {
14 repo = "llvm-project";
15 rev = "llvmorg-${version}";
16 sha256 = "08s5w2db9imb2yaqsvxs6pg21csi1cf6wa35rf8x6q07mam7j8qv";
18 sourceRoot = "source/libclc";
20 # cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
22 substituteInPlace CMakeLists.txt \
23 --replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_BINDIR} NO_DEFAULT_PATH )' \
24 'find_program( LLVM_CLANG clang PATHS "${clang-unwrapped}/bin" NO_DEFAULT_PATH )' \
25 --replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_BINDIR} NO_DEFAULT_PATH )' \
26 'find_program( LLVM_SPIRV llvm-spirv PATHS "${spirv-llvm-translator}/bin" NO_DEFAULT_PATH )'
29 nativeBuildInputs = [ cmake ninja python3 spirv-llvm-translator ];
30 buildInputs = [ llvm clang-unwrapped ];
33 "-DCMAKE_INSTALL_INCLUDEDIR=include"
37 broken = stdenv.isDarwin;
38 homepage = "http://libclc.llvm.org/";
39 description = "Implementation of the library requirements of the OpenCL C programming language";
40 license = licenses.mit;
41 platforms = platforms.all;