Fixes: #32428
This PR adds a dependency provider to depends builds.
Currently the depends toolchain appears to rely on certain assumptions [citation needed] to find packages correctly. It does largely do this correctly, however NixOS sets some environment variables which interfere with this and cause builds from depends to fail, due to attempting to link system packages.
We can reproduce this interferrence by running a NixOS container and loading system packages using a flake:
0docker run --pull=always -it nixos/nix
1
2# In the container:
3git clone --depth=1 https://github.com/bitcoin/bitcoin && cd bitcoin
4
5# Install system packages for a non-depends build from https://github.com/bitcoin-dev-tools/bix
6nix develop github:bitcoin-dev-tools/bix --extra-experimental-features flakes --extra-experimental-features nix-command --no-write-lock-file
7
8# Attempt depends build
9make -C depends -j$(nproc)
10cmake -B build --toolchain /bitcoin/depends/<host-platform-triplet>/toolchain.cmake
11
12# Find possibly-interferring env vars:
13env | grep -E 'CMAKE|NIX'
A dependency provider allows the overriding of cmake
’s find_package()
therefore giving total control over where dependencies come from in a build.
This achieves two things:
- Provides stronger guarantees about where dependencies come from during a (depends) build; not permitting environment flags to override these locations [citation needed].
- Fixes issues like a non-standard
CMAKE_PREFIX_PATH
breaking builds (i.e. 32428)
This provider must be specified along with the toolchain, with an invocation of the type:
0make -C depends
1cmake -B build --toolchain depends/x86_64-pc-linux-gnu/toolchain.cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=depends/x86_64-pc-linux-gnu/dependency_provider.cmake
2cmake --build build