libclc: fix cross

This commit is contained in:
Alyssa Ross 2023-05-10 12:11:25 +00:00 committed by Yureka
parent 99a83b4964
commit ab036e45ac
2 changed files with 21 additions and 13 deletions

View File

@ -1,9 +1,4 @@
{ lib, stdenv, fetchFromGitHub, ninja, cmake, python3, llvmPackages, spirv-llvm-translator }:
let
llvm = llvmPackages.llvm;
clang-unwrapped = llvmPackages.clang-unwrapped;
in
{ lib, stdenv, fetchFromGitHub, buildPackages, ninja, cmake, python3, llvm_14 }:
stdenv.mkDerivation rec {
pname = "libclc";
@ -17,22 +12,37 @@ stdenv.mkDerivation rec {
};
sourceRoot = "source/libclc";
outputs = [ "out" "dev" ];
# 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 "${clang-unwrapped}/bin" 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 "${spirv-llvm-translator}/bin" 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 spirv-llvm-translator ];
buildInputs = [ llvm clang-unwrapped ];
nativeBuildInputs = [ cmake ninja python3 ];
buildInputs = [ llvm_14 ];
strictDeps = true;
cmakeFlags = [
"-DCMAKE_INSTALL_INCLUDEDIR=include"
];
postInstall = ''
install -Dt $dev/bin prepare_builtins
'';
meta = with lib; {
broken = stdenv.isDarwin;
homepage = "http://libclc.llvm.org/";

View File

@ -21501,9 +21501,7 @@ with pkgs;
libcint = callPackage ../development/libraries/libcint { };
libclc = callPackage ../development/libraries/libclc {
llvmPackages = llvmPackages_14;
};
libclc = callPackage ../development/libraries/libclc { };
libcli = callPackage ../development/libraries/libcli { };