From f6da64f8dbd835774998ac336933d2a0147fa310 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 12 Dec 2023 02:28:36 +0100 Subject: llvmPackages_17.libclc: init --- pkgs/development/compilers/llvm/16/default.nix | 2 +- .../compilers/llvm/16/libclc/default.nix | 54 ---------------------- .../llvm/16/libclc/libclc-gnu-install-dirs.patch | 10 ---- pkgs/development/compilers/llvm/17/default.nix | 6 +++ pkgs/development/compilers/llvm/common/libclc.nix | 53 +++++++++++++++++++++ .../common/libclc/libclc-gnu-install-dirs.patch | 10 ++++ 6 files changed, 70 insertions(+), 65 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/16/libclc/default.nix delete mode 100644 pkgs/development/compilers/llvm/16/libclc/libclc-gnu-install-dirs.patch create mode 100644 pkgs/development/compilers/llvm/common/libclc.nix create mode 100644 pkgs/development/compilers/llvm/common/libclc/libclc-gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 5ecb89a3a264..580821cc0d2c 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -281,7 +281,7 @@ in let # Has to be in tools despite mostly being a library, # because we use a native helper executable from a # non-cross build in cross builds. - libclc = callPackage ./libclc { + libclc = callPackage ../common/libclc.nix { inherit buildLlvmTools; }; }); diff --git a/pkgs/development/compilers/llvm/16/libclc/default.nix b/pkgs/development/compilers/llvm/16/libclc/default.nix deleted file mode 100644 index 2ceca9aaf7fd..000000000000 --- a/pkgs/development/compilers/llvm/16/libclc/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ 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 ${buildLlvmTools.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; - }; -} diff --git a/pkgs/development/compilers/llvm/16/libclc/libclc-gnu-install-dirs.patch b/pkgs/development/compilers/llvm/16/libclc/libclc-gnu-install-dirs.patch deleted file mode 100644 index 1e5108a27c38..000000000000 --- a/pkgs/development/compilers/llvm/16/libclc/libclc-gnu-install-dirs.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/libclc.pc.in -+++ b/libclc.pc.in -@@ -1,5 +1,5 @@ --includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@ --libexecdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/clc -+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ -+libexecdir=@CMAKE_INSTALL_FULL_DATADIR@/clc - - Name: libclc - Description: Library requirements of the OpenCL C programming language diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix index 8109f27586cb..2c422da8f9f8 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -269,6 +269,12 @@ in let nixSupport.cc-cflags = [ "-fno-exceptions" ]; }); + # Has to be in tools despite mostly being a library, + # because we use a native helper executable from a + # non-cross build in cross builds. + libclc = callPackage ../common/libclc.nix { + inherit buildLlvmTools; + }; }); libraries = lib.makeExtensible (libraries: let diff --git a/pkgs/development/compilers/llvm/common/libclc.nix b/pkgs/development/compilers/llvm/common/libclc.nix new file mode 100644 index 000000000000..c91930963b20 --- /dev/null +++ b/pkgs/development/compilers/llvm/common/libclc.nix @@ -0,0 +1,53 @@ +{ 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/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.override { inherit (buildLlvmTools) llvm; }}/bin" NO_DEFAULT_PATH )' + '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + substituteInPlace CMakeLists.txt \ + --replace 'COMMAND prepare_builtins' 'COMMAND ${buildLlvmTools.libclc.dev}/bin/prepare_builtins' + ''; + + nativeBuildInputs = [ cmake ninja python3 ]; + buildInputs = [ llvm ]; + strictDeps = true; + + postInstall = '' + install -Dt $dev/bin prepare_builtins + ''; + + meta = with lib; { + homepage = "http://libclc.llvm.org/"; + description = "Implementation of the library requirements of the OpenCL C programming language"; + license = licenses.mit; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/compilers/llvm/common/libclc/libclc-gnu-install-dirs.patch b/pkgs/development/compilers/llvm/common/libclc/libclc-gnu-install-dirs.patch new file mode 100644 index 000000000000..1e5108a27c38 --- /dev/null +++ b/pkgs/development/compilers/llvm/common/libclc/libclc-gnu-install-dirs.patch @@ -0,0 +1,10 @@ +--- a/libclc.pc.in ++++ b/libclc.pc.in +@@ -1,5 +1,5 @@ +-includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@ +-libexecdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/clc ++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ ++libexecdir=@CMAKE_INSTALL_FULL_DATADIR@/clc + + Name: libclc + Description: Library requirements of the OpenCL C programming language -- cgit 1.4.1