Apply CMake sccache helper to oneapi-math-sycl-blas
This commit is contained in:
parent
93fa0158eb
commit
c1916d3fb8
2 changed files with 48 additions and 5 deletions
|
|
@ -26,9 +26,24 @@ let
|
|||
toolchain,
|
||||
}:
|
||||
final.runCommand name { } ''
|
||||
resolve_orig_cc_root() {
|
||||
local current_root="$1"
|
||||
local next_root
|
||||
|
||||
while [ -r "$current_root/nix-support/orig-cc" ]; do
|
||||
next_root="$(tr -d '\n' < "$current_root/nix-support/orig-cc")"
|
||||
if [ -z "$next_root" ] || [ "$next_root" = "$current_root" ]; then
|
||||
break
|
||||
fi
|
||||
current_root="$next_root"
|
||||
done
|
||||
|
||||
printf '%s\n' "$current_root"
|
||||
}
|
||||
|
||||
wrapped_clang="$(readlink -f ${toolchain}/bin/clang)"
|
||||
wrapped_root="$(dirname "$(dirname "$wrapped_clang")")"
|
||||
orig_cc_root="$(tr -d '\n' < "$wrapped_root/nix-support/orig-cc")"
|
||||
orig_cc_root="$(resolve_orig_cc_root "$wrapped_root")"
|
||||
|
||||
if [ -z "$orig_cc_root" ] || [ ! -d "$orig_cc_root/bin" ]; then
|
||||
echo "mkRealCompilerBasePath: invalid orig-cc root: $orig_cc_root" >&2
|
||||
|
|
@ -71,6 +86,7 @@ let
|
|||
sccacheCacheSize ? "100G",
|
||||
noDaemon ? false,
|
||||
passthroughWrappedCompiler ? false,
|
||||
extraSetup ? "",
|
||||
}:
|
||||
let
|
||||
sccacheConfig = final.writeText "${name}-config" ''
|
||||
|
|
@ -91,12 +107,18 @@ let
|
|||
}
|
||||
|
||||
is_cmake_probe_invocation() {
|
||||
local arg
|
||||
local arg response_file
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
*CMakeFiles/*CompilerId*|*CMakeFiles/CMakeTmp/*|*CMakeScratch/*)
|
||||
return 0
|
||||
;;
|
||||
@*)
|
||||
response_file="''${arg#@}"
|
||||
if [ -f "$response_file" ] && grep -Eq 'CMakeFiles/.+CompilerId|CMakeFiles/CMakeTmp|CMakeScratch' "$response_file"; then
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
@ -112,6 +134,7 @@ let
|
|||
${final.lib.optionalString (!noDaemon && sccacheServerUds != null) ''
|
||||
export SCCACHE_SERVER_UDS=${final.lib.escapeShellArg sccacheServerUds}
|
||||
''}
|
||||
${extraSetup}
|
||||
if [ "$#" -eq 0 ] || [ "''${1#-}" != "$1" ]; then
|
||||
exec ${final.sccache}/bin/sccache "$@"
|
||||
fi
|
||||
|
|
@ -180,9 +203,9 @@ let
|
|||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ sccacheLauncher ];
|
||||
|
||||
preConfigure = (old.preConfigure or "") + ''
|
||||
|
||||
mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
||||
chmod 0777 ${final.lib.escapeShellArg sandboxSccacheDir} || true
|
||||
export SCCACHE_WRAPPED_COMPILER_PASSTHROUGH=1
|
||||
export SCCACHE_SERVER_UDS="$TMPDIR/sccache/server.sock"
|
||||
export SCCACHE_IDLE_TIMEOUT=0
|
||||
unset SCCACHE_NO_DAEMON
|
||||
|
|
@ -198,6 +221,10 @@ let
|
|||
fi
|
||||
'';
|
||||
|
||||
postConfigure = (old.postConfigure or "") + ''
|
||||
unset SCCACHE_WRAPPED_COMPILER_PASSTHROUGH
|
||||
'';
|
||||
|
||||
postBuild = (old.postBuild or "") + ''
|
||||
|
||||
${sccacheLauncher}/bin/cmake-sccache --show-stats --stats-format text || true
|
||||
|
|
@ -268,6 +295,13 @@ in
|
|||
passthru = (old.passthru or { }) // {
|
||||
links =
|
||||
{ unwrappedCC, extraConfig ? "" }:
|
||||
let
|
||||
sccacheLauncher = mkSccacheLauncher {
|
||||
name = "wrapped-sccache";
|
||||
noDaemon = true;
|
||||
extraSetup = extraConfig;
|
||||
};
|
||||
in
|
||||
final.stdenv.mkDerivation {
|
||||
pname = "sccache-links";
|
||||
inherit (old) version;
|
||||
|
|
@ -296,12 +330,12 @@ in
|
|||
in
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/nix-support
|
||||
|
||||
wrap() {
|
||||
local cname="${targetPrefix}$1"
|
||||
if [ -x "${unwrappedCC}/bin/$cname" ]; then
|
||||
makeWrapper ${final.sccache}/bin/sccache $out/bin/$cname \
|
||||
--run ${final.lib.escapeShellArg extraConfig} \
|
||||
makeWrapper ${sccacheLauncher}/bin/wrapped-sccache $out/bin/$cname \
|
||||
--add-flags ${unwrappedCC}/bin/$cname
|
||||
fi
|
||||
}
|
||||
|
|
@ -321,6 +355,8 @@ in
|
|||
for file in $(ls ${unwrappedCC} | grep -vw bin); do
|
||||
ln -s ${unwrappedCC}/$file $out/$file
|
||||
done
|
||||
|
||||
printf '%s\n' "${unwrappedCC}" > $out/nix-support/orig-cc
|
||||
'';
|
||||
meta = final.lib.optionalAttrs (unwrappedCC.meta ? mainProgram) {
|
||||
inherit (unwrappedCC.meta) mainProgram;
|
||||
|
|
@ -553,6 +589,9 @@ 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-dpl =
|
||||
let
|
||||
version = "2022.11.1";
|
||||
|
|
|
|||
4
todo.md
4
todo.md
|
|
@ -28,6 +28,10 @@
|
|||
## Next Checks
|
||||
|
||||
- `electron-real-clang-base` should stay store-pure: synthesize its output tree from symlinks only and never `cp`/`rm` against copied toolchain store content.
|
||||
- `mkCmakeSccacheAttrs` should not force raw compilers into CMake; the `sccache.links` wrappers should bypass CMake probe invocations while keeping the normal wrapper-selected compiler environment.
|
||||
- The probe bypass must inspect `@responseFile` arguments as well, because the cc-wrapper often hides `CMakeFiles/CompilerId` paths inside response files before the inner `wrapped-sccache` sees them.
|
||||
- For CMake packages, the practical fallback is to export `SCCACHE_WRAPPED_COMPILER_PASSTHROUGH=1` for the whole `configurePhase` and unset it in `postConfigure`; caching matters in `buildPhase`, not in compiler-ID probes.
|
||||
- Apply the shared CMake helper to stalled subpackages too, not just top-level wrappers. `oneapi-math-sycl-blas` is one such case.
|
||||
- Build the patched `sccache` package.
|
||||
- Run a minimal hello-world derivation with the new `sccacheStdenv` and confirm repeated compiles produce cache hits.
|
||||
- If that works, switch current consumers to the ccache-style path and remove obsolete wrapper-patching logic.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue