nixpkgs/pkgs/development/compilers/spirv-llvm-translator/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.0 KiB
Nix
Raw Normal View History

{ lib, stdenv
2019-07-27 11:48:07 +00:00
, fetchFromGitHub
, cmake
2021-05-08 23:08:50 +00:00
, pkg-config
2019-07-27 11:48:07 +00:00
, lit
, llvm
, spirv-headers
, spirv-tools
2019-07-27 11:48:07 +00:00
}:
let
llvmMajor = lib.versions.major llvm.version;
branch =
if llvmMajor == "15" then rec {
version = "15.0.0";
rev = "v${version}";
hash = "sha256-111yL6Wh8hykoGz1QmT1F7lfGDEmG4U3iqmqrJxizOg=";
} else if llvmMajor == "14" then rec{
version = "14.0.0";
rev = "v${version}";
hash = "sha256-BhNAApgZ/w/92XjpoDY6ZEIhSTwgJ4D3/EfNvPmNM2o=";
} else if llvmMajor == "11" then {
version = "unstable-2022-05-04";
rev = "a31ffaeef77e23d500b3ea3d35e0c42ff5648ad9"; # 266 commits ahead of v11.0.0
hash = "sha256-rkYMFVfS3xG8ozs7zhiSBjIxvxEetetctE+fLS3hXoU=";
} else throw "Incompatible LLVM version.";
in
stdenv.mkDerivation {
2019-07-27 11:48:07 +00:00
pname = "SPIRV-LLVM-Translator";
inherit (branch) version;
2019-07-27 11:48:07 +00:00
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-LLVM-Translator";
inherit (branch) rev hash;
2019-07-27 11:48:07 +00:00
};
nativeBuildInputs = [ pkg-config cmake llvm.dev spirv-tools ];
2019-07-27 11:48:07 +00:00
buildInputs = [ spirv-headers llvm ];
2019-07-27 11:48:07 +00:00
checkInputs = [ lit ];
cmakeFlags = [
"-DLLVM_INCLUDE_TESTS=ON"
"-DLLVM_DIR=${llvm.dev}"
"-DBUILD_SHARED_LIBS=YES"
"-DLLVM_SPIRV_BUILD_EXTERNAL=YES"
# RPATH of binary /nix/store/.../bin/llvm-spirv contains a forbidden reference to /build/
"-DCMAKE_SKIP_BUILD_RPATH=ON"
] ++ lib.optionals (llvmMajor != "11") [ "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${spirv-headers.src}" ];
2019-07-27 11:48:07 +00:00
# FIXME: CMake tries to run "/llvm-lit" which of course doesn't exist
doCheck = false;
makeFlags = [ "all" "llvm-spirv" ];
postInstall = ''
install -D tools/llvm-spirv/llvm-spirv $out/bin/llvm-spirv
'';
meta = with lib; {
homepage = "https://github.com/KhronosGroup/SPIRV-LLVM-Translator";
2019-07-27 11:48:07 +00:00
description = "A tool and a library for bi-directional translation between SPIR-V and LLVM IR";
license = licenses.ncsa;
platforms = platforms.unix;
2019-07-27 11:48:07 +00:00
maintainers = with maintainers; [ gloaming ];
};
}