bitcoin/depends
fanquake 69f35d20a6
Merge bitcoin/bitcoin#22811: build: Fix depends build system when working with subtargets
978852aad8 build: Fix depends build system when working with subtargets (Hennadii Stepanov)

Pull request description:

  On master (f3e0ace8ec), the depends build system does _not_ guarantee that dependencies packages are available for `$(package)_built` target because these dependencies being prepared in `$(host_prefix)` at `$(package)_configured` target can be wiped out during building other package.

  Please consider:
  ```
  $ cd depends
  $ make clean
  $ make fontconfig_configured
  $ make
  ...
    CC       fcdir.lo
  In file included from fcftint.h:26,
                   from fcdir.c:26:
  ../fontconfig/fcfreetype.h:27:10: fatal error: ft2build.h: No such file or directory
     27 | #include <ft2build.h>
        |          ^~~~~~~~~~~~
  compilation terminated.
  make[4]: *** [Makefile:642: fcdir.lo] Error 1
  make[4]: *** Waiting for unfinished jobs....
  make[4]: Leaving directory '/home/hebasto/GitHub/bitcoin/depends/work/build/x86_64-pc-linux-gnu/fontconfig/2.12.6-7daa5620c94/src'
  make[3]: *** [Makefile:503: all] Error 2
  make[3]: Leaving directory '/home/hebasto/GitHub/bitcoin/depends/work/build/x86_64-pc-linux-gnu/fontconfig/2.12.6-7daa5620c94/src'
  make[2]: *** [Makefile:581: all-recursive] Error 1
  make[2]: Leaving directory '/home/hebasto/GitHub/bitcoin/depends/work/build/x86_64-pc-linux-gnu/fontconfig/2.12.6-7daa5620c94'
  make[1]: *** [Makefile:465: all] Error 2
  make[1]: Leaving directory '/home/hebasto/GitHub/bitcoin/depends/work/build/x86_64-pc-linux-gnu/fontconfig/2.12.6-7daa5620c94'
  make: *** [funcs.mk:288: /home/hebasto/GitHub/bitcoin/depends/work/build/x86_64-pc-linux-gnu/fontconfig/2.12.6-7daa5620c94/./.stamp_built] Error 2
  ```

  The following commands:
  ```
  $ cd depends
  $ make clean
  $ make qt_configured
  $ make
  ```
  also fail.

  The similar issue was reported earlier: #21381.

  This PR guarantees that dependencies packages are available for `$(package)_built` target.

  Guix builds:
  ```
  accef9ffccfe280fec1114c0440092ed5d792e9c53d95abc7fe65435aa136656  guix-build-978852aad8e2/output/aarch64-linux-gnu/SHA256SUMS.part
  a75f1250975525a21d2e213e23f1f0dab516d2b28d0c7d747de292fe5c906013  guix-build-978852aad8e2/output/aarch64-linux-gnu/bitcoin-978852aad8e2-aarch64-linux-gnu-debug.tar.gz
  d20787af2e7a14a3b7b1d21e0d8784aa6ebad1e916f02aebfa25afe9229ba43c  guix-build-978852aad8e2/output/aarch64-linux-gnu/bitcoin-978852aad8e2-aarch64-linux-gnu.tar.gz
  11c94a39c084763858c6de31b221868e52554f5500c0dc5589def429bb6b54c8  guix-build-978852aad8e2/output/arm-linux-gnueabihf/SHA256SUMS.part
  3935b0e14d78800977dc813a3824215797096b6fb29c84b5996f48338908a65f  guix-build-978852aad8e2/output/arm-linux-gnueabihf/bitcoin-978852aad8e2-arm-linux-gnueabihf-debug.tar.gz
  c828c3f87a453db443a385a266331661f623f8f4684d88eb006290c83bfa8150  guix-build-978852aad8e2/output/arm-linux-gnueabihf/bitcoin-978852aad8e2-arm-linux-gnueabihf.tar.gz
  b6ff14e1cc36e568fc726b50300f77498560322b3582738eb70e7144784f7e63  guix-build-978852aad8e2/output/arm64-apple-darwin/SHA256SUMS.part
  2a3e6ba5843eaf9562e9dcfdb4595024a71738079cea00e391558feca4d5bde1  guix-build-978852aad8e2/output/arm64-apple-darwin/bitcoin-978852aad8e2-arm64-apple-darwin-unsigned.dmg
  ffd2ad39e8b9f95dd714513ba1e1c77666b0f3cc4b67be4ab763ebd431fe9276  guix-build-978852aad8e2/output/arm64-apple-darwin/bitcoin-978852aad8e2-arm64-apple-darwin-unsigned.tar.gz
  5c9f8acd1777effc1e860b64143ba9d06ba5e3d0330e7341529eeae5cc6b3c5e  guix-build-978852aad8e2/output/arm64-apple-darwin/bitcoin-978852aad8e2-arm64-apple-darwin.tar.gz
  e34c693ecef6159c57fdedabff9dc3d69ec20387966083b828532c58e1e6e30b  guix-build-978852aad8e2/output/dist-archive/bitcoin-978852aad8e2.tar.gz
  8de4681114d96425bf9b0ccc47d49f696293ead514faa3fa83ddcccfdca2eeb2  guix-build-978852aad8e2/output/powerpc64-linux-gnu/SHA256SUMS.part
  d780330a105931eb4c66a536c332eb09e4b6d8c288832bb5a74b931c4600c0b3  guix-build-978852aad8e2/output/powerpc64-linux-gnu/bitcoin-978852aad8e2-powerpc64-linux-gnu-debug.tar.gz
  af036a6d714ef362a2facfe4e5c63deaa9dfa391d20542ead9ffb4a43b2b7ca2  guix-build-978852aad8e2/output/powerpc64-linux-gnu/bitcoin-978852aad8e2-powerpc64-linux-gnu.tar.gz
  dc6b4365632e7de386ead512b1cdcdd3c985623f63cff8b62974bd9ed8c05d5d  guix-build-978852aad8e2/output/powerpc64le-linux-gnu/SHA256SUMS.part
  5543a6dec58515186b71139a4a5c603d85638672f205e7c9fabb281c98018461  guix-build-978852aad8e2/output/powerpc64le-linux-gnu/bitcoin-978852aad8e2-powerpc64le-linux-gnu-debug.tar.gz
  dd791be2e61ce6cbd3e14c165ce2f8c2d22881992e0df72bd338423d092cc467  guix-build-978852aad8e2/output/powerpc64le-linux-gnu/bitcoin-978852aad8e2-powerpc64le-linux-gnu.tar.gz
  2b740db8e5b9c435be3e7b186c3b4a40885302243326ec990e24fe4ba4f777da  guix-build-978852aad8e2/output/riscv64-linux-gnu/SHA256SUMS.part
  de899c89874d4f34afeca179a6c7c8f49b0a975983ab2b31afd9f2d365674578  guix-build-978852aad8e2/output/riscv64-linux-gnu/bitcoin-978852aad8e2-riscv64-linux-gnu-debug.tar.gz
  9052b1db22c56692d99a61c3783b36c6f76537d9aec14f17d87a155beac82532  guix-build-978852aad8e2/output/riscv64-linux-gnu/bitcoin-978852aad8e2-riscv64-linux-gnu.tar.gz
  5e79ddf57a94c5978ad819896786107f735d5742bbd042c2c64ae2d0681ce53a  guix-build-978852aad8e2/output/x86_64-apple-darwin/SHA256SUMS.part
  96443ad839f87c723db1c0a96d8ead0afc69e9d96ad45b5814344866da2dae73  guix-build-978852aad8e2/output/x86_64-apple-darwin/bitcoin-978852aad8e2-x86_64-apple-darwin-unsigned.dmg
  14b0a3081772e81a463398a2702aca039d2f276e301dee9f5a0ccffbb09e2749  guix-build-978852aad8e2/output/x86_64-apple-darwin/bitcoin-978852aad8e2-x86_64-apple-darwin-unsigned.tar.gz
  6bfb8252524202028308267f5e96bc30f284052f5feaa58ed3697dde27a3130f  guix-build-978852aad8e2/output/x86_64-apple-darwin/bitcoin-978852aad8e2-x86_64-apple-darwin.tar.gz
  5f8ea6297e246b08ffd806913897cc863feeec6522fcfb4456a59c5f154e0c2d  guix-build-978852aad8e2/output/x86_64-linux-gnu/SHA256SUMS.part
  40d1bcf491660d54fe20b2db24828ebf61be848eefdc38fba09ed43f6bdba4b1  guix-build-978852aad8e2/output/x86_64-linux-gnu/bitcoin-978852aad8e2-x86_64-linux-gnu-debug.tar.gz
  3200e67a4dea115e8e341b4d71d84dc5e8bd2ae35e550cde6aef88d120c65eae  guix-build-978852aad8e2/output/x86_64-linux-gnu/bitcoin-978852aad8e2-x86_64-linux-gnu.tar.gz
  0b0bf7effc493ecc68398f23fc81647f64fdee115e8ccd7ae91e7881804ec328  guix-build-978852aad8e2/output/x86_64-w64-mingw32/SHA256SUMS.part
  e2064c9ddeb4af18468f37ba8cf70004062c31e1387b4cc0fe4b445fae518e8d  guix-build-978852aad8e2/output/x86_64-w64-mingw32/bitcoin-978852aad8e2-win64-debug.zip
  be347a901b896e0a1dc2f0f5a7f84614075805cccf1f2af8ec8df678d086fdbc  guix-build-978852aad8e2/output/x86_64-w64-mingw32/bitcoin-978852aad8e2-win64-setup-unsigned.exe
  bab8700e9e266970e8c7cad494902058ad12d1f2a6462e0039daa637b1a0ce0d  guix-build-978852aad8e2/output/x86_64-w64-mingw32/bitcoin-978852aad8e2-win64-unsigned.tar.gz
  c8e55e64b248fd7c9056fe811a1eba992bbb92e44857204e3024416d9ba6307d  guix-build-978852aad8e2/output/x86_64-w64-mingw32/bitcoin-978852aad8e2-win64.zip
  ```

ACKs for top commit:
  TheCharlatan:
    tACK 978852aad8

Tree-SHA512: c195484274433039e327d44b1949afa296e09e7470a2b138b7a8476c8bf9c1302bc21284cd5436f09aa97824aae9f362b7932ff2937b78f79df0b43e50f3dfaa
2023-01-28 15:45:53 +00:00
..
builders build: Let the depends build system define a path to dsymutil tool 2022-04-21 10:08:46 +02:00
hosts build: Add objcopy host tool 2022-08-13 14:08:12 +01:00
packages Merge bitcoin/bitcoin#26945: depends: systemtap 4.8 2023-01-26 13:37:48 +00:00
patches depends: systemtap: remove variadic params that trigger compiler warnings 2023-01-23 18:12:26 +00:00
.gitignore depends: Support for S390X targets 2019-12-05 12:12:46 -05:00
config.guess depends: latest config.guess (2021-05-24) 2021-05-26 13:28:47 +08:00
config.site.in build: Do not export PKG_CONFIG_{PATH|LIBDIR} variables 2022-07-27 10:07:34 +01:00
config.sub depends: latest config.sub (2021-04-30) 2021-05-26 13:30:18 +08:00
description.md doc: Fix whitespace errs in .md files, bitcoin.conf, Info.plist.in, and find_bdb48.m4 2019-09-17 03:21:22 -04:00
funcs.mk build: Fix depends build system when working with subtargets 2022-12-09 13:36:46 +00:00
gen_id build: add *_STANDARD vars to depends gen_id 2022-06-17 14:44:49 +01:00
Makefile build: allow NO_LIBEVENT=1 in depends 2023-01-14 12:31:22 +00:00
packages.md doc: Fix typos in packages.md 2021-11-28 18:13:52 +02:00
README.md doc: add new NO_* options from #26833 2023-01-18 16:59:01 +00:00

Usage

To build dependencies for the current arch+OS:

make

To build for another arch/OS:

make HOST=host-platform-triplet

For example:

make HOST=x86_64-w64-mingw32 -j4

Bitcoin Core's configure script by default will ignore the depends output. In order for it to pick up libraries, tools, and settings from the depends build, you must set the CONFIG_SITE environment variable to point to a config.site settings file. In the above example, a file named depends/x86_64-w64-mingw32/share/config.site will be created. To use it during compilation:

CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure

The default install prefix when using config.site is --prefix=depends/<host-platform-triplet>, so depends build outputs will be installed in that location.

Common host-platform-triplets for cross compilation are:

  • i686-pc-linux-gnu for Linux 32 bit
  • x86_64-pc-linux-gnu for x86 Linux
  • x86_64-w64-mingw32 for Win64
  • x86_64-apple-darwin for macOS
  • arm64-apple-darwin for ARM macOS
  • arm-linux-gnueabihf for Linux ARM 32 bit
  • aarch64-linux-gnu for Linux ARM 64 bit
  • powerpc64-linux-gnu for Linux POWER 64-bit (big endian)
  • powerpc64le-linux-gnu for Linux POWER 64-bit (little endian)
  • riscv32-linux-gnu for Linux RISC-V 32 bit
  • riscv64-linux-gnu for Linux RISC-V 64 bit
  • s390x-linux-gnu for Linux S390X
  • armv7a-linux-android for Android ARM 32 bit
  • aarch64-linux-android for Android ARM 64 bit
  • x86_64-linux-android for Android x86 64 bit

The paths are automatically configured and no other options are needed unless targeting Android.

Install the required dependencies: Ubuntu & Debian

For macOS cross compilation

sudo apt-get install curl bsdmainutils cmake libz-dev python3-setuptools libtinfo5 xorriso

Note: You must obtain the macOS SDK before proceeding with a cross-compile. Under the depends directory, create a subdirectory named SDKs. Then, place the extracted SDK under this new directory. For more information, see SDK Extraction.

For Win64 cross compilation

For linux (including i386, ARM) cross compilation

Common linux dependencies:

sudo apt-get install make automake cmake curl g++-multilib libtool binutils bsdmainutils pkg-config python3 patch bison

For linux ARM cross compilation:

sudo apt-get install g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf

For linux AARCH64 cross compilation:

sudo apt-get install g++-aarch64-linux-gnu binutils-aarch64-linux-gnu

For linux POWER 64-bit cross compilation (there are no packages for 32-bit):

sudo apt-get install g++-powerpc64-linux-gnu binutils-powerpc64-linux-gnu g++-powerpc64le-linux-gnu binutils-powerpc64le-linux-gnu

For linux RISC-V 64-bit cross compilation (there are no packages for 32-bit):

sudo apt-get install g++-riscv64-linux-gnu binutils-riscv64-linux-gnu

For linux S390X cross compilation:

sudo apt-get install g++-s390x-linux-gnu binutils-s390x-linux-gnu

Install the required dependencies: OpenBSD

pkg_add bash gtar

Dependency Options

The following can be set when running make: make FOO=bar

  • SOURCES_PATH: Downloaded sources will be placed here
  • BASE_CACHE: Built packages will be placed here
  • SDK_PATH: Path where SDKs can be found (used by macOS)
  • FALLBACK_DOWNLOAD_PATH: If a source file can't be fetched, try here before giving up
  • C_STANDARD: Set the C standard version used. Defaults to c11.
  • CXX_STANDARD: Set the C++ standard version used. Defaults to c++17.
  • NO_BOOST: Don't download/build/cache Boost
  • NO_LIBEVENT: Don't download/build/cache Libevent
  • NO_QT: Don't download/build/cache Qt and its dependencies
  • NO_QR: Don't download/build/cache packages needed for enabling qrencode
  • NO_ZMQ: Don't download/build/cache packages needed for enabling ZeroMQ
  • NO_WALLET: Don't download/build/cache libs needed to enable the wallet
  • NO_BDB: Don't download/build/cache BerkeleyDB
  • NO_SQLITE: Don't download/build/cache SQLite
  • NO_UPNP: Don't download/build/cache packages needed for enabling UPnP
  • NO_NATPMP: Don't download/build/cache packages needed for enabling NAT-PMP
  • ALLOW_HOST_PACKAGES: Packages that are missed in dependencies (due to NO_* option or build script logic) are searched for among the host system packages using pkg-config. It allows building with packages of other (newer) versions
  • MULTIPROCESS: Build libmultiprocess (experimental, requires CMake)
  • DEBUG: Disable some optimizations and enable more runtime checking
  • HOST_ID_SALT: Optional salt to use when generating host package ids
  • BUILD_ID_SALT: Optional salt to use when generating build package ids
  • FORCE_USE_SYSTEM_CLANG: (EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the system's $PATH rather than the default prebuilt release of Clang from llvm.org. Clang 8 or later is required
  • LOG: Use file-based logging for individual packages. During a package build its log file resides in the depends directory, and the log file is printed out automatically in case of build error. After successful build log files are moved along with package archives
  • LTO: Use LTO when building packages.

If some packages are not built, for example make NO_WALLET=1, the appropriate options will be passed to bitcoin's configure. In this case, --disable-wallet.

Additional targets

download: run 'make download' to fetch all sources without building them
download-osx: run 'make download-osx' to fetch all sources needed for macOS builds
download-win: run 'make download-win' to fetch all sources needed for win builds
download-linux: run 'make download-linux' to fetch all sources needed for linux builds

Other documentation