diff --git a/pkgs/by-name/in/intel-llvm/package.nix b/pkgs/by-name/in/intel-llvm/package.nix index 04fba865125a..ff0f492f2e29 100644 --- a/pkgs/by-name/in/intel-llvm/package.nix +++ b/pkgs/by-name/in/intel-llvm/package.nix @@ -111,7 +111,20 @@ let mkdir "$rsrc" echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags ln -s "${lib.getLib self.unwrapped}/lib/clang/${self.llvmMajorVersion}/include" "$rsrc" - ''; + '' + + (lib.concatStrings ( + lib.mapAttrsToList (k: v: '' + echo "export ${k}=${v}" >> $out/nix-support/setup-hook + '') self.unwrapped.unified-runtime.setupVars + )) + + + (lib.optionalString (self.unwrapped.unified-runtime.setupVars ? CUDA_PATH) '' + # SYCL CUDA runtime libs (e.g. libonemath_blas_cublas.so) carry DT_NEEDED: libcuda.so.1. + # GNU ld resolves transitive DT_NEEDED via -rpath-link, not -L; point it at the stubs. + echo "-rpath-link,${self.unwrapped.unified-runtime.setupVars.CUDA_PATH}/lib/stubs" >> $out/nix-support/cc-ldflags + # The SYCL CUDA backend discovers libdevice by finding ptxas in PATH. + echo "export PATH=${self.unwrapped.unified-runtime.setupVars.CUDA_PATH}/bin''${PATH:+:$PATH}" >> $out/nix-support/setup-hook + ''); extraPackages = # We need to explicitly link to the dev package to get headers like sycl.hpp diff --git a/pkgs/by-name/in/intel-llvm/unified-runtime.nix b/pkgs/by-name/in/intel-llvm/unified-runtime.nix index 78d673ca8094..1bd3cf296469 100644 --- a/pkgs/by-name/in/intel-llvm/unified-runtime.nix +++ b/pkgs/by-name/in/intel-llvm/unified-runtime.nix @@ -18,6 +18,7 @@ pkg-config, lit, filecheck, + buildPackages, rocmPackages ? { }, rocmGpuTargets ? lib.optionalString (rocmPackages ? clr.gpuTargets) ( builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets @@ -41,10 +42,22 @@ let ]; }; + # Minimal rocm join required at runtime + # We pass this to clang in its wrapper later. + # This is a separate join from the above because we don't + # need to pull in hsakmt and comgr at runtime, only build time. + rocmPath = symlinkJoin { + name = "rocm-path"; + paths = with rocmPackages; [ + clr + rocm-device-libs + ]; + }; + cudatoolkit_joined = symlinkJoin { name = "cuda-merged"; - paths = with cudaPackages; [ + paths = with buildPackages.cudaPackages; [ cuda_cudart cuda_nvcc cuda_nvml_dev.include @@ -158,6 +171,10 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeFeature "CUDA_cupti_LIBRARY" "${cudatoolkit_joined}/lib/libcupti.so") ]; + passthru.setupVars = + lib.optionalAttrs rocmSupport { ROCM_PATH = rocmPath; } + // lib.optionalAttrs cudaSupport { CUDA_PATH = cudatoolkit_joined; }; + passthru.backends = lib.optionals levelZeroSupport [ "level_zero"