Add wrapper stub

This commit is contained in:
2026-03-13 13:00:56 +01:00
parent 8be739c839
commit 16e30c22b3

View File

@@ -3,6 +3,7 @@
lib,
ninja,
autoAddDriverRunpath,
wrapCC,
cmake,
emhash,
fetchFromGitHub,
@@ -23,6 +24,8 @@
}:
let
llvmMajorVersion = "21";
version = "6.2.1";
src = fetchFromGitHub {
owner = "intel";
@@ -188,6 +191,43 @@ stdenv.mkDerivation {
(lib.cmakeBool "LIBCLC_NATIVECPU_HOST_TARGET" false)
];
postPatch =
let
# See the postPatch phase for details on why this is used
ccWrapperStub = wrapCC (
stdenv.mkDerivation {
name = "ccWrapperStub";
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin
cat > $out/bin/clang-${llvmMajorVersion} <<'EOF'
#!/bin/sh
exec "$NIX_BUILD_TOP/source/build/bin/clang-${llvmMajorVersion}" "$@"
EOF
chmod +x $out/bin/clang-${llvmMajorVersion}
cp $out/bin/clang-${llvmMajorVersion} $out/bin/clang
cp $out/bin/clang-${llvmMajorVersion} $out/bin/clang++
'';
passthru.isClang = true;
}
);
in
''
# Parts of libdevice are built using the freshly-built compiler.
# As it tries to link to system libraries, we need to wrap it with the
# usual nix cc-wrapper.
# Since the compiler to be wrapped is not available at this point,
# we use a stub that points to where it will be later on
# in `$NIX_BUILD_TOP/source/build/bin/clang-${llvmMajorVersion}`
substituteInPlace libdevice/cmake/modules/SYCLLibdevice.cmake \
--replace-fail "\''${clang_exe}" "${ccWrapperStub}/bin/clang++"
'';
passthru = {
inherit llvmMajorVersion;
};
meta = {
homepage = "https://github.com/intel/llvm";
description = "Intel staging area for llvm.org contribution";