This commit is contained in:
TheK0tYaRa 2026-03-23 01:33:56 +02:00
parent 339ef75baf
commit 8f97a15738
2 changed files with 220 additions and 167 deletions

View file

@ -156,9 +156,7 @@ let
buildSccacheLauncher = mkSccacheLauncher {
name = "build-sccache";
};
mkBuildSccacheAttrs =
old:
{
mkBuildSccacheAttrs = old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ buildSccacheLauncher ];
preConfigure = (old.preConfigure or "") + ''
@ -271,14 +269,12 @@ let
sccacheDir ? "/var/cache/sccache/nix-builds/packages",
extraConfig ? "",
}:
final.overrideCC stdenv (
mkWrappedCcForSccache {
final.overrideCC stdenv (mkWrappedCcForSccache {
inherit (stdenv) cc;
extraConfig = mkSccacheExtraConfig {
inherit extraConfig sccacheDir;
};
}
);
});
in
{
sccache = modify prev.sccache (old: {
@ -291,7 +287,10 @@ in
'';
passthru = (old.passthru or { }) // {
links =
{ unwrappedCC, extraConfig ? "" }:
{
unwrappedCC,
extraConfig ? "",
}:
let
sccacheLauncher = mkSccacheLauncher {
name = "wrapped-sccache";
@ -308,7 +307,8 @@ in
isSccache = true;
dev = unwrappedCC.dev or null;
lib = unwrappedCC.lib or (final.lib.getLib unwrappedCC);
} // final.lib.optionalAttrs (unwrappedCC ? rsrc) {
}
// final.lib.optionalAttrs (unwrappedCC ? rsrc) {
inherit (unwrappedCC) rsrc;
};
dev = unwrappedCC.dev or null;
@ -362,7 +362,8 @@ in
};
});
sccacheWrapper =
final.lib.makeOverridable (
final.lib.makeOverridable
(
{
extraConfig ? "",
cc,
@ -370,25 +371,30 @@ in
mkWrappedCcForSccache {
inherit cc extraConfig;
}
) {
)
{
extraConfig = "";
inherit (final.stdenv) cc;
};
sccacheStdenv = final.lib.lowPrio (
final.lib.makeOverridable (
final.lib.makeOverridable
(
{
stdenv,
...
}@extraArgs:
final.overrideCC stdenv (
final.buildPackages.sccacheWrapper.override (
{ inherit (stdenv) cc; }
{
inherit (stdenv) cc;
}
// final.lib.optionalAttrs (builtins.hasAttr "extraConfig" extraArgs) {
extraConfig = extraArgs.extraConfig;
}
)
)
) {
)
{
inherit (final) stdenv;
}
);
@ -459,27 +465,23 @@ in
buildSccacheAttrs = mkBuildSccacheAttrs old;
oldClangBasePath = "clang_base_path=\"${old.llvmCcAndBintools}\"";
newClangBasePath = "clang_base_path=\"${realElectronClangBasePath}\"";
baseGnFlags = builtins.replaceStrings
[ oldClangBasePath ]
[ newClangBasePath ]
(old.gnFlags or "");
electronGnFlags =
"${baseGnFlags} cc_wrapper=\"${buildSccacheLauncher}/bin/build-sccache\"";
baseGnFlags = builtins.replaceStrings [ oldClangBasePath ] [ newClangBasePath ] (old.gnFlags or "");
electronGnFlags = "${baseGnFlags} cc_wrapper=\"${buildSccacheLauncher}/bin/build-sccache\"";
in
buildSccacheAttrs
// {
gnFlags = electronGnFlags;
configurePhase = builtins.replaceStrings
[ old.gnFlags or "" ]
[ electronGnFlags ]
(old.configurePhase or "");
configurePhase = builtins.replaceStrings [ old.gnFlags or "" ] [ electronGnFlags ] (
old.configurePhase or ""
);
patches = builtins.filter (
patch: builtins.baseNameOf (toString patch) != "39-angle-patchdir.patch"
) (old.patches or [ ]);
postPatch = ''
substituteInPlace electron/patches/config.json \
--replace-fail '"repo": "src/third_party/angle/src"' '"repo": "src/third_party/angle"'
'' + (old.postPatch or "");
''
+ (old.postPatch or "");
postFixup = (old.postFixup or "") + ''
for angleLibName in \
@ -504,9 +506,12 @@ in
prev.electron_39.override {
electron-unwrapped = electronUnwrapped;
};
oneapi-ccl = modify (prev.oneapi-ccl.override {
oneapi-ccl =
modify
(prev.oneapi-ccl.override {
intel-sycl = final."intel-sycl";
}) (
})
(
old:
let
version = "2021.17.2";
@ -537,21 +542,21 @@ in
ln -s ${levelZero}/include/level_zero deps/level_zero/include
sed -i '/^#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)$/,/^#endif$/c\
#cmakedefine CCL_ENABLE_SYCL\
#cmakedefine CCL_ENABLE_ZE' include/oneapi/ccl/config.h.in
#cmakedefine CCL_ENABLE_SYCL\
#cmakedefine CCL_ENABLE_ZE' include/oneapi/ccl/config.h.in
sed -i 's/^#define ICPX_VERSION 0$/#define ICPX_VERSION 140000/' src/common/utils/sycl_utils.hpp
sed -i '/^inline sycl::event get_last_event(const sycl::queue &q) {$/, /^inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::event> &deps) {$/c\
inline sycl::event get_last_event(const sycl::queue &q) {\
inline sycl::event get_last_event(const sycl::queue &q) {\
auto last_event_opt = q.ext_oneapi_get_last_event();\
if (last_event_opt.has_value()) {\
return last_event_opt.value();\
}\
return sycl::event{};\
}\
\
inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::event> \&deps) {' src/coll/algorithms/utils/sycl_coll_base.hpp
}\
\
inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::event> \&deps) {' src/coll/algorithms/utils/sycl_coll_base.hpp
find src -type f \( -name '*.hpp' -o -name '*.cpp' \) \
-exec sed -i 's/reqd_sub_group_size(sg_size)/reqd_sub_group_size(32)/g' {} +
@ -586,17 +591,14 @@ inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::
};
}
);
oneapi-math-sycl-blas = modify prev.oneapi-math-sycl-blas (
old: mkCmakeSccacheAttrs old
);
oneapi-math = modify prev.oneapi-math (
old: mkCmakeSccacheAttrs old
);
oneapi-math-sycl-blas = modify prev.oneapi-math-sycl-blas (old: mkCmakeSccacheAttrs old);
oneapi-math = modify prev.oneapi-math (old: mkCmakeSccacheAttrs old);
oneapi-dpl =
let
version = "2022.11.1";
in
modify prev.oneapi-dpl (old:
modify prev.oneapi-dpl (
old:
(versionBumpAttrs old.version version {
inherit version;
@ -725,12 +727,62 @@ inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::
old:
let
cmakeSccacheAttrs = mkCmakeSccacheAttrs old;
#
# Build against the drm/tip 7.0.0-rc4 kernel headers for xe driver ABI compatibility
kernelSrc = builtins.fetchGit {
url = "https://gitlab.freedesktop.org/drm/tip.git";
rev = "61409ba11a36fa5aff4ce0f0086a6026a43c5bce";
shallow = true;
};
kernelHeaders = final.runCommand "xe-kernel-headers" { } ''
mkdir -p $out/include/drm
cp -v ${kernelSrc}/include/drm/xe_drm.h $out/include/drm/ 2>/dev/null || true
cp -v ${kernelSrc}/include/uapi/drm/xe_drm.h $out/include/drm/ 2>/dev/null || true
# Also copy other drm headers the compute runtime might need
for f in ${kernelSrc}/include/drm/*.h ${kernelSrc}/include/uapi/drm/*.h; do
[ -f "$f" ] && cp -v "$f" $out/include/drm/ 2>/dev/null || true
done
'';
in
cmakeSccacheAttrs
// {
cmakeFlags = (cmakeSccacheAttrs.cmakeFlags or [ ]) ++ [
(prev.lib.cmakeBool "NEO_ENABLE_XE" true)
];
buildInputs = (old.buildInputs or [ ]) ++ [ kernelHeaders ];
postPatch = (old.postPatch or "") + ''
# Copy xe_drm.h from the drm/tip kernel into all compute-runtime header locations
if [ -f "${kernelHeaders}/include/drm/xe_drm.h" ]; then
for dest in \
third_party/uapi/drm-next/xe \
third_party/uapi/drm-uapi-helper/xe \
third_party/uapi-eudebug/drm \
; do
if [ -d "$dest" ]; then
cp -v "${kernelHeaders}/include/drm/xe_drm.h" "$dest/"
fi
done
fi
# Patch GMM resource creation failures to be non-fatal.
# intel-gmmlib can't create resource info for BMG on kernel 7.0 xe driver
# in certain initialization paths. Patch the abort and add null guards.
# 1. resource_info.cpp: return nullptr instead of aborting
sed -i 's/UNRECOVERABLE_IF(resourceInfo->peekHandle() == 0);/if(resourceInfo->peekHandle() == 0) { delete resourceInfo; return nullptr; }/' \
shared/source/gmm_helper/resource_info.cpp
# 2. gmm.cpp: change UNRECOVERABLE_IF to graceful return first (line 104)
sed -i 's/UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);/if (this->gmmResourceInfo == nullptr) { return; }/' \
shared/source/gmm_helper/gmm.cpp
# 3. gmm.cpp: add null checks after GmmResourceInfo::create calls that lack them
# Lines 76 and 85 (line 103 already handled by step 2 after the UNRECOVERABLE_IF replacement)
sed -i '76a\ if (this->gmmResourceInfo == nullptr) { return; }' \
shared/source/gmm_helper/gmm.cpp
sed -i '87a\ if (this->gmmResourceInfo == nullptr) { return; }' \
shared/source/gmm_helper/gmm.cpp
'';
}
);
}

View file

@ -101,6 +101,7 @@
intel-ocl
vpl-gpu-rt
intel-compute-runtime
intel-compute-runtime.drivers
### intel-hw
oneapi-ccl
oneapi-dpl