Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1# Bootstrappable Bitcoin Core Builds3This directory contains the files necessary to perform bootstrappable Bitcoin4Core builds.6[Bootstrappability][b17e] furthers our binary security guarantees by allowing us7to _audit and reproduce_ our toolchain instead of blindly _trusting_ binary8downloads.10We achieve bootstrappability by using Guix as a functional package manager.12# Requirements14Conservatively, you will need:16- 16GB of free disk space on the partition that /gnu/store will reside in17- 8GB of free disk space **per platform triple** you're planning on building18(see the `HOSTS` [environment variable description][env-vars-list])20# Installation and Setup22If you don't have Guix installed and set up, please follow the instructions in23[INSTALL.md](./INSTALL.md)25# Usage27If you haven't considered your security model yet, please read [the relevant28section](#choosing-your-security-model) before proceeding to perform a build.30## Making the Xcode SDK available for macOS cross-compilation32In order to perform a build for macOS (which is included in the default set of33platform triples to build), you'll need to extract the macOS SDK tarball using34tools found in the [`macdeploy` directory](../macdeploy/README.md#sdk-extraction).36You can then either point to the SDK using the `SDK_PATH` environment variable:38```sh39# Extract the SDK tarball to /path/to/parent/dir/of/extracted/SDK/Xcode-<foo>-<bar>-extracted-SDK-with-libcxx-headers40tar -C /path/to/parent/dir/of/extracted/SDK -xaf /path/to/Xcode-<foo>-<bar>-extracted-SDK-with-libcxx-headers.tar42# Indicate where to locate the SDK tarball43export SDK_PATH=/path/to/parent/dir/of/extracted/SDK44```46or extract it into `depends/SDKs`:48```sh49mkdir -p depends/SDKs50tar -C depends/SDKs -xaf /path/to/SDK/tarball51```53## Building55*The author highly recommends at least reading over the [common usage patterns56and examples](#common-guix-build-invocation-patterns-and-examples) section below57before starting a build. For a full list of customization options, see the58[recognized environment variables][env-vars-list] section.*60To build Bitcoin Core reproducibly with all default options, invoke the61following from the top of a clean repository:63```sh64./contrib/guix/guix-build65```67## Codesigning build outputs69The `guix-codesign` command attaches codesignatures (produced by codesigners) to70existing non-codesigned outputs. Please see the [release process71documentation](/doc/release-process.md#codesigning) for more context.73It respects many of the same environment variable flags as `guix-build`, with 274crucial differences:761. Since only Windows and macOS build outputs require codesigning, the `HOSTS`77environment variable will have a sane default value of `x86_64-w64-mingw3278x86_64-apple-darwin arm64-apple-darwin` instead of all the platforms.792. The `guix-codesign` command ***requires*** a `DETACHED_SIGS_REPO` flag.80* _**DETACHED_SIGS_REPO**_82Set the directory where detached codesignatures can be found for the current83Bitcoin Core version being built.85_REQUIRED environment variable_87An invocation with all default options would look like:89```90env DETACHED_SIGS_REPO=<path/to/bitcoin-detached-sigs> ./contrib/guix/guix-codesign91```93## Cleaning intermediate work directories95By default, `guix-build` leaves all intermediate files or "work directories"96(e.g. `depends/work`, `guix-build-*/distsrc-*`) intact at the end of a build so97that they are available to the user (to aid in debugging, etc.). However, these98directories usually take up a large amount of disk space. Therefore, a99`guix-clean` convenience script is provided which cleans the current `git`100worktree to save disk space:102```103./contrib/guix/guix-clean104```106## Gathering shasums of build outputs108After a successful build, the shasums of the build outputs are gathered109into files named `SHA256SUMS`. These files are located in each of the110architecture-specific output directories.112To gather all shasums and output them together to console, for e.g.113inclusion in a Guix pull request comment, run:115``` sh116source contrib/shell/git-utils.bash && uname -m && find guix-build-$(git_head_version)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum117```119## Attesting to build outputs121Much like how Gitian build outputs are attested to in a `gitian.sigs`122repository, Guix build outputs are attested to in the [`guix.sigs`123repository](https://github.com/bitcoin-core/guix.sigs).125After you've cloned the `guix.sigs` repository, to attest to the current126worktree's commit/tag:128```129env GUIX_SIGS_REPO=<path/to/guix.sigs> SIGNER=<gpg-key-name> ./contrib/guix/guix-attest130```132See `./contrib/guix/guix-attest --help` for more information on the various ways133`guix-attest` can be invoked.135## Verifying build output attestations137After at least one other signer has uploaded their signatures to the `guix.sigs`138repository:140```141git -C <path/to/guix.sigs> pull142env GUIX_SIGS_REPO=<path/to/guix.sigs> ./contrib/guix/guix-verify143```146## Common `guix-build` invocation patterns and examples148### Keeping caches and SDKs outside of the worktree150If you perform a lot of builds and have a bunch of worktrees, you may find it151more efficient to keep the depends tree's download cache, build cache, and SDKs152outside of the worktrees to avoid duplicate downloads and unnecessary builds. To153help with this situation, the `guix-build` script honours the `SOURCES_PATH`,154`BASE_CACHE`, and `SDK_PATH` environment variables so that you can do something155like:157```sh158env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build159```161Note that the paths that these environment variables point to **must be162directories**, and **NOT symlinks to directories**.164See the [recognized environment variables][env-vars-list] section for more165details.167### Building a subset of platform triples169Sometimes you only want to build a subset of the supported platform triples, in170which case you can override the default list by setting the space-separated171`HOSTS` environment variable:173```sh174env HOSTS='x86_64-w64-mingw32 x86_64-apple-darwin' ./contrib/guix/guix-build175```177See the [recognized environment variables][env-vars-list] section for more178details.180### Controlling the number of threads used by `guix` build commands182Depending on your system's RAM capacity, you may want to decrease the number of183threads used to decrease RAM usage or vice versa.185By default, the scripts under `./contrib/guix` will invoke all `guix` build186commands with `--cores="$JOBS"`. Note that `$JOBS` defaults to `$(nproc)` if not187specified. However, astute manual readers will also notice that `guix` build188commands also accept a `--max-jobs=` flag (which defaults to 1 if unspecified).190Here is the difference between `--cores=` and `--max-jobs=`:192> Note: When I say "derivation," think "package"194`--cores=`196- controls the number of CPU cores to build each derivation. This is the value197passed to `make`'s `--jobs=` flag.199`--max-jobs=`201- controls how many derivations can be built in parallel202- defaults to 1204Therefore, the default is for `guix` build commands to build one derivation at a205time, utilizing `$JOBS` threads.207Specifying the `$JOBS` environment variable will only modify `--cores=`, but you208can also modify the value for `--max-jobs=` by specifying209`$ADDITIONAL_GUIX_COMMON_FLAGS`. For example, if you have a LOT of memory, you210may want to set:212```sh213export ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8'214```216Which allows for a maximum of 8 derivations to be built at the same time, each217utilizing `$JOBS` threads.219Or, if you'd like to avoid spurious build failures caused by issues with220parallelism within a single package, but would still like to build multiple221packages when the dependency graph allows for it, you may want to try:223```sh224export JOBS=1 ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8'225```227See the [recognized environment variables][env-vars-list] section for more228details.230## Recognized environment variables232* _**HOSTS**_234Override the space-separated list of platform triples for which to perform a235bootstrappable build.237_(defaults to "x86\_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu238riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu239x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin")_241* _**SOURCES_PATH**_243Set the depends tree download cache for sources. This is passed through to the244depends tree. Setting this to the same directory across multiple builds of the245depends tree can eliminate unnecessary redownloading of package sources.247The path that this environment variable points to **must be a directory**, and248**NOT a symlink to a directory**.250* _**BASE_CACHE**_
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.