Skip to content

Commit 04a5b82

Browse files
authored
intel-llvm: init at unstable-2025-11-14 (#470035)
2 parents cea2892 + 77f6a79 commit 04a5b82

9 files changed

Lines changed: 1536 additions & 3 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
buildcpath() {
4+
local path after
5+
while (( $# )); do
6+
case $1 in
7+
-isystem|-cxx-isystem)
8+
shift
9+
path=$path${path:+':'}$1
10+
;;
11+
-idirafter)
12+
shift
13+
after=$after${after:+':'}$1
14+
;;
15+
esac
16+
shift
17+
done
18+
echo $path${after:+':'}$after
19+
}
20+
21+
export CPATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
22+
$(<@clang@/nix-support/libc-cflags)):@clang@/resource-root/include
23+
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
24+
$(<@clang@/nix-support/libcxx-cxxflags) \
25+
$(<@clang@/nix-support/libc-cflags)):@clang@/resource-root/include
26+
27+
exec -a "$0" @unwrapped@/bin/$(basename $0) "$@"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Wrapper for clang tools (clang-scan-deps, clang-check, etc.) that sets
2+
# CPATH and CPLUS_INCLUDE_PATH so they can find C/C++ standard library headers.
3+
#
4+
# This is needed because tools like clang-scan-deps are invoked directly by
5+
# build systems (e.g., CMake's C++20 module scanning) without going through
6+
# the cc-wrapper, so they don't get the flags that tell them where headers are.
7+
{
8+
lib,
9+
stdenv,
10+
unwrapped,
11+
wrapper,
12+
}:
13+
stdenv.mkDerivation {
14+
pname = "intel-llvm-clang-tools";
15+
version = unwrapped.version;
16+
17+
dontUnpack = true;
18+
19+
# These are used in substituteAll for the wrapper script
20+
inherit unwrapped;
21+
clang = wrapper;
22+
23+
installPhase = ''
24+
runHook preInstall
25+
26+
mkdir -p $out/bin
27+
28+
substituteAll ${./clang-tools-wrapper} $out/bin/.clang-tool-wrapper
29+
chmod +x $out/bin/.clang-tool-wrapper
30+
31+
for tool in clang-scan-deps clang-check clang-extdef-mapping clang-refactor clang-tidy; do
32+
if [[ -e $unwrapped/bin/$tool ]]; then
33+
ln -s $out/bin/.clang-tool-wrapper $out/bin/$tool
34+
fi
35+
done
36+
37+
runHook postInstall
38+
'';
39+
40+
meta = unwrapped.meta // {
41+
description = "Wrapped Intel LLVM clang tools with proper include paths";
42+
};
43+
}

pkgs/by-name/in/intel-llvm/gnu-install-dirs.patch

Lines changed: 746 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
callPackage,
3+
newScope,
4+
wrapCCWith,
5+
symlinkJoin,
6+
overrideCC,
7+
lib,
8+
fetchFromGitHub,
9+
}:
10+
let
11+
# This derivation uses makeScope to help with overriding.
12+
#
13+
# To override the source and other basics:
14+
# pkgs.intel-llvm.overrideScope (final: prev: {
15+
# version = ..;
16+
# src = ..;
17+
# # If setting src, you'll probably also want to set this.
18+
# commitDate = ..;
19+
# })
20+
#
21+
# To override something inside unified-runtime:
22+
# pkgs.intel-llvm.overrideScope (final: prev: {
23+
# make-unified-runtime = args: (prev.make-unified-runtime args)
24+
# .override { .. }
25+
# .overrideAttrs { .. }
26+
# })
27+
scope = lib.makeScope newScope (self: {
28+
# == Parameters for overriding ==
29+
30+
llvmMajorVersion = "22";
31+
32+
version = "unstable-2025-11-14";
33+
34+
src = fetchFromGitHub {
35+
owner = "intel";
36+
repo = "llvm";
37+
# Latest commit which doesn't require dependency versions newer than
38+
# what's available in nixpkgs as of 2026-01-13.
39+
# Commits after require newer level-zero and pre-release unified memory framework.
40+
rev = "ab3dc98de0fd1ada9df12b138de1e1f8b715cc27";
41+
hash = "sha256-oHk8kQVNsyC9vrOsDqVoFLYl2yMMaTgpQnAW9iHZLfE=";
42+
};
43+
44+
# If you override src, you'll probably also want to override this,
45+
# as some packages check for this date to decide what features the compiler supports
46+
commitDate = "20251114";
47+
48+
vc-intrinsics-src = fetchFromGitHub {
49+
owner = "intel";
50+
repo = "vc-intrinsics";
51+
# See llvm/lib/SYCLLowerIR/CMakeLists.txt:17
52+
rev = "60cea7590bd022d95f5cf336ee765033bd114d69";
53+
sha256 = "sha256-1K16UEa6DHoP2ukSx58OXJdtDWyUyHkq5Gd2DUj1644=";
54+
};
55+
56+
# ===============================
57+
58+
make-unified-runtime =
59+
{
60+
levelZeroSupport,
61+
cudaSupport,
62+
rocmSupport,
63+
rocmGpuTargets,
64+
nativeCpuSupport,
65+
}:
66+
callPackage ./unified-runtime.nix {
67+
intel-llvm-src = self.src;
68+
inherit
69+
levelZeroSupport
70+
cudaSupport
71+
rocmSupport
72+
rocmGpuTargets
73+
nativeCpuSupport
74+
;
75+
# This could theoretically be disabled if you for some reason
76+
# didn't want to build the backend, however OpenCL will get
77+
# pulled in as a dependency either way so there is little point.
78+
openclSupport = true;
79+
};
80+
81+
unwrapped = callPackage ./unwrapped.nix {
82+
inherit (self)
83+
llvmMajorVersion
84+
src
85+
version
86+
commitDate
87+
vc-intrinsics-src
88+
make-unified-runtime
89+
;
90+
};
91+
92+
wrapper =
93+
(wrapCCWith {
94+
cc = self.unwrapped;
95+
# This is needed for tools like clang-scan-deps to find headers.
96+
# The build commands here are the same as the vanilla LLVM derivation.
97+
extraBuildCommands = ''
98+
rsrc="$out/resource-root"
99+
mkdir "$rsrc"
100+
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
101+
ln -s "${lib.getLib self.unwrapped}/lib/clang/${self.llvmMajorVersion}/include" "$rsrc"
102+
'';
103+
}).overrideAttrs
104+
(old: {
105+
# OpenCL needs to be passed through
106+
propagatedBuildInputs = old.propagatedBuildInputs ++ self.unwrapped.propagatedBuildInputs;
107+
});
108+
109+
clang-tools-wrapper = callPackage ./clang-tools.nix {
110+
inherit (self) unwrapped wrapper;
111+
};
112+
113+
# We merge everything into one by default to avoid issues with path-lookup.
114+
# intel-llvm provides the SYCL library, so unlike regular LLVM libraries,
115+
# its libraries are equally important as the compiler itself.
116+
# Splitting is nonetheless important, as otherwise the binaries go over the Hydra limit.
117+
merged = symlinkJoin {
118+
inherit (self.unwrapped) pname version meta;
119+
120+
strictDeps = true;
121+
__structuredAttrs = true;
122+
123+
paths = with self; [
124+
# Order is important, we want files from the wrappers to take precedence
125+
wrapper
126+
clang-tools-wrapper
127+
128+
unwrapped.out
129+
unwrapped.dev
130+
unwrapped.lib
131+
];
132+
133+
passthru = self.unwrapped.passthru // {
134+
inherit (self) stdenv;
135+
unwrapped = self.unwrapped;
136+
tests = callPackage ./tests.nix { inherit (self) stdenv; };
137+
138+
overrideScope = newF: (self.overrideScope newF).merged;
139+
};
140+
};
141+
stdenv = overrideCC self.unwrapped.baseLlvm.stdenv self.merged;
142+
});
143+
in
144+
scope.merged
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/sycl-jit/jit-compiler/utils/generate.py b/sycl-jit/jit-compiler/utils/generate.py
2+
index 449723b8fa26..ecba44efe071 100644
3+
--- a/sycl-jit/jit-compiler/utils/generate.py
4+
+++ b/sycl-jit/jit-compiler/utils/generate.py
5+
@@ -49,6 +49,12 @@ const resource_file ToolchainFiles[] = {"""
6+
def process_dir(dir):
7+
for root, _, files in os.walk(dir):
8+
for file in files:
9+
+ # Skip CMake files, because they contain absolute install paths, causing cyclic dependencies.
10+
+ # They aren't ever used as it seems, so excluding them won't break anything.
11+
+ if file in ['CMakeLists.txt', 'cmake_install.cmake'] or file.endswith('.cmake'):
12+
+ print(f"[nix-compat patch] Skipping embedding of sycl-jit CMake file: {os.path.join(root, file)}")
13+
+ continue
14+
+
15+
file_path = os.path.join(root, file)
16+
process_file(file_path)
17+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
stdenv,
3+
writeTextFile,
4+
}:
5+
{
6+
sycl-compile = stdenv.mkDerivation {
7+
name = "intel-llvm-test-sycl-compile";
8+
9+
src = writeTextFile {
10+
name = "test.cpp";
11+
text = ''
12+
#include <sycl/sycl.hpp>
13+
#include <iostream>
14+
15+
int main() {
16+
sycl::queue q;
17+
std::cout << "SYCL queue created successfully" << std::endl;
18+
return 0;
19+
}
20+
'';
21+
};
22+
23+
dontUnpack = true;
24+
25+
buildPhase = ''
26+
echo "Checking if a basic SYCL program can compile..."
27+
clang++ -fsycl $src -o test
28+
'';
29+
30+
installPhase = ''
31+
mkdir -p $out/bin
32+
cp test $out/bin/sycl-test
33+
'';
34+
35+
meta = {
36+
description = "Test that intel-llvm can compile a basic SYCL program";
37+
};
38+
};
39+
}

0 commit comments

Comments
 (0)