intel-llvm: fix linking for consumers using strictDeps (#513506)

This commit is contained in:
Doron Behar
2026-04-27 15:19:55 +00:00
committed by GitHub
+30 -16
View File
@@ -24,6 +24,19 @@ let
# .override { .. }
# .overrideAttrs { .. }
# })
#
# Note that this package does not support cross-compilation at the moment.
#
# TODO: Support cross
# The easiest path for this will likely be to use standalone packaging,
# and use the existing LLVM derivation with overrides. Though that won't
# be very workable until upstream support for standalone improves,
# see https://github.com/intel/llvm/issues/21877 for that.
#
# Due to the multi-stage build, at several times during compilation
# the package runs binaries that were just compiled, and for cross these
# would need to be compiled for the host and not target platform,
# which is non-trivial to configure.
scope = lib.makeScope newScope (self: {
# == Parameters for overriding ==
@@ -89,22 +102,23 @@ let
;
};
wrapper =
(wrapCCWith {
cc = self.unwrapped;
# This is needed for tools like clang-scan-deps to find headers.
# The build commands here are the same as the vanilla LLVM derivation.
extraBuildCommands = ''
rsrc="$out/resource-root"
mkdir "$rsrc"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
ln -s "${lib.getLib self.unwrapped}/lib/clang/${self.llvmMajorVersion}/include" "$rsrc"
'';
}).overrideAttrs
(old: {
# OpenCL needs to be passed through
propagatedBuildInputs = old.propagatedBuildInputs ++ self.unwrapped.propagatedBuildInputs;
});
wrapper = wrapCCWith {
cc = self.unwrapped;
# This is needed for tools like clang-scan-deps to find headers.
# The build commands here are the same as the vanilla LLVM derivation.
extraBuildCommands = ''
rsrc="$out/resource-root"
mkdir "$rsrc"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
ln -s "${lib.getLib self.unwrapped}/lib/clang/${self.llvmMajorVersion}/include" "$rsrc"
'';
extraPackages =
# We need to explicitly link to the dev package to get headers like sycl.hpp
[ self.unwrapped.dev ] # TODO: This needs to be from targetPackages once the package gets cross support
# OpenCL and such need to be passed through
++ self.unwrapped.propagatedBuildInputs;
};
clang-tools-wrapper = callPackage ./clang-tools.nix {
inherit (self) unwrapped wrapper;