intel-llvm: support rocm/cuda builds without needing manual --rocm-path/etc. (#514089)

This commit is contained in:
Sandro
2026-06-27 06:04:04 +00:00
committed by GitHub
2 changed files with 32 additions and 2 deletions
+14 -1
View File
@@ -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
+18 -1
View File
@@ -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"