nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, fetchFromGitHub
3, llvmPackages_15
4, lld_15
5, python3
6, cmake
7, boost
8, libxml2
9, libffi
10, makeWrapper
11, config
12, rocmPackages
13, rocmSupport ? config.rocmSupport
14}:
15let
16 inherit (llvmPackages_15) stdenv;
17in
18stdenv.mkDerivation rec {
19 pname = "OpenSYCL";
20 version = "0.9.4";
21
22 src = fetchFromGitHub {
23 owner = "OpenSYCL";
24 repo = "OpenSYCL";
25 rev = "v${version}";
26 sha256 = "sha256-5YkuUOAnvoAD5xDKxKMPq0B7+1pb6hVisPAhs0Za1ls=";
27 };
28
29 nativeBuildInputs = [
30 cmake
31 makeWrapper
32 ];
33
34 buildInputs = [
35 libxml2
36 libffi
37 boost
38 llvmPackages_15.openmp
39 llvmPackages_15.libclang.dev
40 llvmPackages_15.llvm
41 ] ++ lib.optionals rocmSupport [
42 rocmPackages.clr
43 rocmPackages.rocm-runtime
44 ];
45
46 # opensycl makes use of clangs internal headers. Its cmake does not successfully discover them automatically on nixos, so we supply the path manually
47 cmakeFlags = [
48 "-DCLANG_INCLUDE_PATH=${llvmPackages_15.libclang.dev}/include"
49 ];
50
51 postFixup = ''
52 wrapProgram $out/bin/syclcc-clang \
53 --prefix PATH : ${lib.makeBinPath [ python3 lld_15 ]} \
54 --add-flags "-L${llvmPackages_15.openmp}/lib" \
55 --add-flags "-I${llvmPackages_15.openmp.dev}/include" \
56 '' + lib.optionalString rocmSupport ''
57 --add-flags "--rocm-device-lib-path=${rocmPackages.rocm-device-libs}/amdgcn/bitcode"
58 '';
59
60 meta = with lib; {
61 homepage = "https://github.com/OpenSYCL/OpenSYCL";
62 description = "Multi-backend implementation of SYCL for CPUs and GPUs";
63 maintainers = with maintainers; [ yboettcher ];
64 license = licenses.bsd2;
65 };
66}