Merge bitcoin/bitcoin#36209: guix: cache GUI depends separately

1fe87c2505 guix: cache GUI depends separately (will)

Pull request description:

  Alternative to #35929

  The GUI and non-GUI Guix profiles produce different depends build IDs. However, depends deletes the existing per-package cache directory when storing a new build. Sharing a cache root therefore causes each profile to evict the other's packages, forcing rebuilds on subsequent runs.

  This PR keeps these packages in separate `GUIX/BUILD` and `GUIX/GUI` directories under the cache root. This also keeps them separate from ordinary developer builds when BASE_CACHE is being used there.

  #35929 replaces `GUIX_ENVIRONMENT` in package ID generation with a hash of selected Guix inputs. Its current implementation covers the manifests, patches, pinned Guix revision and additional flags, but that list needs to stay aligned with how we construct the environment and may therefore be brittle to future changes.

  In this version I prefer keeping the resolved environment in the cache key and simply keeping the caches separate.

  #### Tradeoffs vs #35929

  This PR means building and storing some dependencies twice, which I consider a reasonable cost for simpler cache tracking/invalidation. This is likely going to be the case for Linux anyway i.e after a change like #36193 or #25573.

ACKs for top commit:
  achow101:
    ACK 1fe87c2505
  hebasto:
    ACK 1fe87c2505, tested on Ubuntu 26.04 by doing several consecutive Guix builds interleaved with branch switches and observing the cache behavior.
  sedited:
    ACK 1fe87c2505

Tree-SHA512: 33d8926fd8cc81338dd2d2c389a0ae9388256da5b1fdebabf05308f057535d1240d6e8bc0fc30a11a80cd3677c39067b0a5c3cc87272d162d8dbe727d8e1cc7c
This commit is contained in:
merge-script
2026-09-11 10:19:02 +02:00
7 changed files with 18 additions and 5 deletions

View File

@@ -151,8 +151,8 @@ If you perform a lot of builds and have a bunch of worktrees, you may find it
more efficient to keep the depends tree's download cache, build cache, and SDKs more efficient to keep the depends tree's download cache, build cache, and SDKs
outside of the worktrees to avoid duplicate downloads and unnecessary builds. To outside of the worktrees to avoid duplicate downloads and unnecessary builds. To
help with this situation, the `guix-build` script honours the `SOURCES_PATH`, help with this situation, the `guix-build` script honours the `SOURCES_PATH`,
`BASE_CACHE`, and `SDK_PATH` environment variables and will pass them on to the `BASE_CACHE`, and `SDK_PATH` environment variables so that you can do something
depends tree so that you can do something like: like:
```sh ```sh
env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build
@@ -249,9 +249,10 @@ details.
* _**BASE_CACHE**_ * _**BASE_CACHE**_
Set the depends tree cache for built packages. This is passed through to the Set the root directory for cached built packages. Non-GUI and GUI builds use
depends tree. Setting this to the same directory across multiple builds of the the `GUIX/BUILD` and `GUIX/GUI` subdirectories, respectively, so their caches do
depends tree can eliminate unnecessary building of packages. not evict each other's packages. Setting this to the same directory across
multiple Guix builds can eliminate unnecessary building of packages.
The path that this environment variable points to **must be a directory**, and The path that this environment variable points to **must be a directory**, and
**NOT a symlink to a directory**. **NOT a symlink to a directory**.

View File

@@ -11,6 +11,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
# setup gcc toolchain # setup gcc toolchain
gcc_toolchain gcc_toolchain
BASE_CACHE="${BASE_CACHE:-$PWD/depends/built}/GUIX/BUILD"
# Build the depends tree # Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \ make -C depends --jobs="$JOBS" HOST="$HOST" \
${V:+V=1} \ ${V:+V=1} \

View File

@@ -11,6 +11,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
# setup gcc toolchain # setup gcc toolchain
gcc_toolchain gcc_toolchain
BASE_CACHE="${BASE_CACHE:-$PWD/depends/built}/GUIX/GUI"
# Build the depends tree # Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \ make -C depends --jobs="$JOBS" HOST="$HOST" \
${V:+V=1} \ ${V:+V=1} \

View File

@@ -11,6 +11,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
# Setup toolchain # Setup toolchain
llvm_toolchain llvm_toolchain
BASE_CACHE="${BASE_CACHE:-$PWD/depends/built}/GUIX/BUILD"
# Build the depends tree # Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \ make -C depends --jobs="$JOBS" HOST="$HOST" \
${V:+V=1} \ ${V:+V=1} \

View File

@@ -11,6 +11,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
# Setup toolchain # Setup toolchain
llvm_toolchain llvm_toolchain
BASE_CACHE="${BASE_CACHE:-$PWD/depends/built}/GUIX/GUI"
# Build the depends tree # Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \ make -C depends --jobs="$JOBS" HOST="$HOST" \
${V:+V=1} \ ${V:+V=1} \

View File

@@ -11,6 +11,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
# setup mingw-w64 toolchain # setup mingw-w64 toolchain
mingw_w64_toolchain mingw_w64_toolchain
BASE_CACHE="${BASE_CACHE:-$PWD/depends/built}/GUIX/BUILD"
# Build the depends tree # Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \ make -C depends --jobs="$JOBS" HOST="$HOST" \
${V:+V=1} \ ${V:+V=1} \

View File

@@ -11,6 +11,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
# setup mingw-w64 toolchain # setup mingw-w64 toolchain
mingw_w64_toolchain mingw_w64_toolchain
BASE_CACHE="${BASE_CACHE:-$PWD/depends/built}/GUIX/GUI"
# Build the depends tree # Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \ make -C depends --jobs="$JOBS" HOST="$HOST" \
${V:+V=1} \ ${V:+V=1} \