diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm/common')
3 files changed, 66 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/common/libclc.nix b/nixpkgs/pkgs/development/compilers/llvm/common/libclc.nix new file mode 100644 index 000000000000..c91930963b20 --- /dev/null +++ b/nixpkgs/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/nixpkgs/pkgs/development/compilers/llvm/common/libclc/libclc-gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/common/libclc/libclc-gnu-install-dirs.patch new file mode 100644 index 000000000000..1e5108a27c38 --- /dev/null +++ b/nixpkgs/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 diff --git a/nixpkgs/pkgs/development/compilers/llvm/common/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/common/lldb.nix index 1f5d4a1e3385..2444c1795a78 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/common/lldb.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/common/lldb.nix @@ -23,6 +23,7 @@ , monorepoSrc ? null , patches ? [ ] , enableManpages ? false +, ... }: let @@ -108,6 +109,8 @@ stdenv.mkDerivation (rec { "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" ] ++ lib.optionals (!stdenv.isDarwin) [ "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ] ++ lib.optionals (lib.versionAtLeast release_version "17") [ + "-DCLANG_RESOURCE_DIR=../../../../${libclang.lib}" ] ++ lib.optionals enableManpages ([ "-DLLVM_ENABLE_SPHINX=ON" "-DSPHINX_OUTPUT_MAN=ON" |