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