a35e3235891d35daa167116cc70340140e883f06 guix: Appease travis. (Carl Dong) 0b66d22da5f53640e22f05adf880782c613e6d0f guix: Use gcc-9 for mingw-w64 instead of 8 (Carl Dong) ba0b99bdd613ba7f17c6247ece3001e1b44759a3 guix: Don't set MINGW_HAS_SECURE_API CFLAG in depends (Carl Dong) 93439a71eda49fb69f1e82966a23a946733aa6fa guix: Bump to upstream commit with mingw-w64 changes (Carl Dong) 35a96792dda9e78165b1598aeac7b2ab759e7be5 guix: Check mingw symbols, improve SSP fix docs (Carl Dong) 449d8fe25bbe25daacfc67aa89ca32b0a3254c5a guix: Expand on INT trap message (Carl Dong) 3f1f03c67a8e9edf487f08d272adb18b0a3942c8 guix: Spelling fixes (Carl Dong) ff821dd2a1c600488d11e7d9a20e9179ecc9144b guix: Reinstate make-ssp-fixed-gcc (Carl Dong) 360a9e0ad50a36ec79a1a160dbed3966689fd41c guix: Bump time-machine for mingw-w64 patches (Carl Dong) 93e41b7e3b54c17fd1b4c61ee95fc0dc2827e954 guix: Use gcc-8 for mingw-w64 instead of 7 (Carl Dong) ef4f7e4c45c60a69406134122f091c77c6ef740f guix: Set the well-known timezone env var (Carl Dong) acf4b3b3b5accf60a19441a0298ef27001b78e72 guix: Make x86_64-w64-mingw32 builds reproducible (Carl Dong) c4cce00eac691625b78b92f7dba0b7f57def19e5 guix: Remove dead links from README. (Carl Dong) df953a4c9a6143f45864757b706c88b6fa70545a guix: Appease shellcheck. (Carl Dong) 91897c95e191d293eb27d8af15cbeafc5b8f3895 guix: Improve guix-build.sh documentation (Carl Dong) 570d769c6c59b9f6d1a2b95b2ed60432cb33b3ba guix: Build support for Windows (Carl Dong) Pull request description: ~~Based on: https://github.com/bitcoin/bitcoin/pull/16519~~ Based on: #17933 (Time Machines are... shall we say... superior 😁) This PR allows us to perform Guix builds for the `x86_64-w64-mingw32` target. We do this _without_ splitting up the build script like we do in Gitian by using this newfangled alien technology called `case` statements. (This is WIP and might be changed to `if` statements soon) ACKs for top commit: fanquake: ACK a35e3235891d35daa167116cc70340140e883f06 2/3 Tree-SHA512: c471951c23eb2cda919a71285d8b8f2580cb20f09d5db17b53e13dbd8813e01b3e7a83ea848e4913fd0f2bc12c6c133c5f76b54e65c0d89fed4dfd2e0be19875
7.9 KiB
Bootstrappable Bitcoin Core Builds
This directory contains the files necessary to perform bootstrappable Bitcoin Core builds.
Bootstrappability furthers our binary security guarantees by allowing us to audit and reproduce our toolchain instead of blindly trusting binary downloads.
We achieve bootstrappability by using Guix as a functional package manager.
Requirements
Conservatively, a x86_64 machine with:
- 2 or more logical cores
- 4GB of free disk space on the partition that /gnu/store will reside in
- 24GB of free disk space on the partition that the Bitcoin Core git repository resides in
Note: these requirements are slightly less onerous than those of Gitian builds
Setup
Installing Guix
If you're just testing this out, you can use the Dockerfile for convenience. It automatically speeds up your builds by using substitutes. If you don't want this behaviour, refer to the next section.
Otherwise, follow the Guix installation guide.
Note: For those who like to keep their filesystems clean, Guix is designed to be very standalone and will not conflict with your system's package manager/existing setup. It only touches
/var/guix
,/gnu
, and~/.config/guix
.
Choosing your security model
Guix allows us to achieve better binary security by using our CPU time to build everything from scratch. However, it doesn't sacrifice user choice in pursuit of this: users can decide whether or not to bootstrap and to use substitutes.
After installation, you may want to consider adding substitute servers to speed up your build if that fits your security model (say, if you're just testing that this works). This is skippable if you're using the Dockerfile.
If you prefer not to use any substitutes, make sure to set
ADDITIONAL_GUIX_ENVIRONMENT_FLAGS
like the following snippet. The first build
will take a while, but the resulting packages will be cached for future builds.
export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--no-substitutes'
Likewise, to perform a bootstrapped build (takes even longer):
export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--bootstrap --no-substitutes'
Using a version of Guix with guix time-machine
capabilities
Note: This entire section can be skipped if you are already using a version of Guix that has the
guix time-machine
command.
Once Guix is installed, if it doesn't have the guix time-machine
command, pull
the latest guix
.
guix pull --max-jobs=4 # change number of jobs accordingly
Make sure that you are using your current profile. (You are prompted to do this
at the end of the guix pull
)
export PATH="${HOME}/.config/guix/current/bin${PATH:+:}$PATH"
Usage
As a Development Environment
For a Bitcoin Core depends development environment, simply invoke
guix environment --manifest=contrib/guix/manifest.scm
And you'll land back in your shell with all the build dependencies required for
a depends
build injected into your environment.
As a Tool for Deterministic Builds
From the top of a clean Bitcoin Core repository:
./contrib/guix/guix-build.sh
After the build finishes successfully (check the status code please), compare hashes:
find output/ -type f -print0 | sort -z | xargs -r0 sha256sum
Recognized environment variables
-
HOSTS
Override the space-separated list of platform triples for which to perform a bootstrappable build. (defaults to "x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu")
Windows and OS X platform triplet support are WIP.
-
SOURCES_PATH
Set the depends tree download cache for sources. This is passed through to the depends tree. Setting this to the same directory across multiple builds of the depends tree can eliminate unnecessary redownloading of package sources.
-
MAX_JOBS
Override the maximum number of jobs to run simultaneously, you might want to do so on a memory-limited machine. This may be passed to
make
as inmake --jobs="$MAX_JOBS"
orxargs
as inxargs -P"$MAX_JOBS"
. (defaults to the value ofnproc
outside the container) -
SOURCE_DATE_EPOCH
Override the reference UNIX timestamp used for bit-for-bit reproducibility, the variable name conforms to standard. (defaults to the output of
$(git log --format=%at -1)
) -
V
If non-empty, will pass
V=1
to allmake
invocations, makingmake
output verbose. -
ADDITIONAL_GUIX_ENVIRONMENT_FLAGS
Additional flags to be passed to
guix environment
. For a fully-bootstrapped build, set this to--bootstrap --no-substitutes
(refer to the security model section for more details). Note that a fully-bootstrapped build will take quite a long time on the first run.
Tips and Tricks
Speeding up builds with substitute servers
This whole section is automatically done in the convenience Dockerfiles
For those who are used to life in the fast (and trustful) lane, you can use substitute servers to enable binary downloads of packages.
For those who only want to use substitutes from the official Guix build farm and have authorized the build farm's signing key during Guix's installation, you don't need to do anything.
Authorize the signing keys
For the official Guix build farm at https://ci.guix.gnu.org, run as root:
guix archive --authorize < ~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub
For dongcarl's substitute server at https://guix.carldong.io, run as root:
wget -qO- 'https://guix.carldong.io/signing-key.pub' | guix archive --authorize
Use the substitute servers
The official Guix build farm at https://ci.guix.gnu.org is automatically used
unless the --no-substitutes
flag is supplied.
This can be overridden for all guix
invocations by passing the
--substitute-urls
option to your invocation of guix-daemon
. This can also be
overridden on a call-by-call basis by passing the same --substitute-urls
option to client tools such at guix environment
.
To use dongcarl's substitute server for Bitcoin Core builds after having authorized his signing key:
export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--substitute-urls="https://guix.carldong.io https://ci.guix.gnu.org"'
FAQ
How can I trust the binary installation?
As mentioned at the bottom of this manual page:
The binary installation tarballs can be (re)produced and verified simply by running the following command in the Guix source tree:
make guix-binary.x86_64-linux.tar.xz
When will Guix be packaged in debian?
Vagrant Cascadian has been making good progress on this here. We have all the pieces needed to put up an APT repository and will likely put one up soon.