diff --git a/depends/packages.md b/depends/packages.md index 7d2bd4670..d71902725 100644 --- a/depends/packages.md +++ b/depends/packages.md @@ -1,148 +1,183 @@ Each recipe consists of 3 main parts: defining identifiers, setting build variables, and defining build commands. The package "mylib" will be used here as an example General tips: - mylib_foo is written as $(package)_foo in order to make recipes more similar. +- Secondary dependency packages relative to the bitcoin binaries/libraries (i.e. + those not in `ALLOWED_LIBRARIES` in `contrib/devtools/symbol-check.py`) don't + need to be shared and should be built statically whenever possible. See + [below](#secondary-dependencies) for more details. ## Identifiers Each package is required to define at least these variables: $(package)_version: Version of the upstream library or program. If there is no version, a placeholder such as 1.0 can be used. $(package)_download_path: Location of the upstream source, without the file-name. Usually http, https or ftp. Secure transmission options like https should be preferred if available. $(package)_file_name: The upstream source filename available at the download path. $(package)_sha256_hash: The sha256 hash of the upstream file These variables are optional: $(package)_build_subdir: cd to this dir before running configure/build/stage commands. $(package)_download_file: The file-name of the upstream source if it differs from how it should be stored locally. This can be used to avoid storing file-names with strange characters. $(package)_dependencies: Names of any other packages that this one depends on. $(package)_patches: Filenames of any patches needed to build the package $(package)_extra_sources: Any extra files that will be fetched via $(package)_fetch_cmds. These are specified so that they can be fetched and verified via 'make download'. ## Build Variables: After defining the main identifiers, build variables may be added or customized before running the build commands. They should be added to a function called $(package)_set_vars. For example: define $(package)_set_vars ... endef Most variables can be prefixed with the host, architecture, or both, to make the modifications specific to that case. For example: Universal: $(package)_cc=gcc Linux only: $(package)_linux_cc=gcc x86_64 only: $(package)_x86_64_cc = gcc x86_64 linux only: $(package)_x86_64_linux_cc = gcc These variables may be set to override or append their default values. $(package)_cc $(package)_cxx $(package)_objc $(package)_objcxx $(package)_ar $(package)_ranlib $(package)_libtool $(package)_nm $(package)_cflags $(package)_cxxflags $(package)_ldflags $(package)_cppflags $(package)_config_env $(package)_build_env $(package)_stage_env $(package)_build_opts $(package)_config_opts The *_env variables are used to add environment variables to the respective commands. Many variables respect a debug/release suffix as well, in order to use them for only the appropriate build config. For example: $(package)_cflags_release = -O3 $(package)_cflags_i686_debug = -g $(package)_config_opts_release = --disable-debug These will be used in addition to the options that do not specify debug/release. All builds are considered to be release unless DEBUG=1 is set by the user. Other variables may be defined as needed. ## Build commands: For each build, a unique build dir and staging dir are created. For example, `work/build/mylib/1.0-1adac830f6e` and `work/staging/mylib/1.0-1adac830f6e`. The following build commands are available for each recipe: $(package)_fetch_cmds: Runs from: build dir Fetch the source file. If undefined, it will be fetched and verified against its hash. $(package)_extract_cmds: Runs from: build dir Verify the source file against its hash and extract it. If undefined, the source is assumed to be a tarball. $(package)_preprocess_cmds: Runs from: build dir/$(package)_build_subdir Preprocess the source as necessary. If undefined, does nothing. $(package)_config_cmds: Runs from: build dir/$(package)_build_subdir Configure the source. If undefined, does nothing. $(package)_build_cmds: Runs from: build dir/$(package)_build_subdir Build the source. If undefined, does nothing. $(package)_stage_cmds: Runs from: build dir/$(package)_build_subdir Stage the build results. If undefined, does nothing. The following variables are available for each recipe: $(1)_staging_dir: package's destination sysroot path $(1)_staging_prefix_dir: prefix path inside of the package's staging dir $(1)_extract_dir: path to the package's extracted sources $(1)_build_dir: path where configure/build/stage commands will be run $(1)_patch_dir: path where the package's patches (if any) are found Notes on build commands: For packages built with autotools, $($(package)_autoconf) can be used in the configure step to (usually) correctly configure automatically. Any $($(package)_config_opts) will be appended. Most autotools projects can be properly staged using: $(MAKE) DESTDIR=$($(package)_staging_dir) install + +## Build outputs: + +In general, the output of a depends package should not contain any libtool +archives. Instead, the package should output `.pc` (`pkg-config`) files where +possible. + +From the [Gentoo Wiki entry](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives): + +> Libtool pulls in all direct and indirect dependencies into the .la files it +> creates. This leads to massive overlinking, which is toxic to the Gentoo +> ecosystem, as it leads to a massive number of unnecessary rebuilds. + +## Secondary dependencies: + +Secondary dependency packages relative to the bitcoin binaries/libraries (i.e. +those not in `ALLOWED_LIBRARIES` in `contrib/devtools/symbol-check.py`) don't +need to be shared and should be built statically whenever possible. This +improves general build reliability as illustrated by the following example: + +When linking an executable against a shared library `libprimary` that has its +own shared dependency `libsecondary`, we may need to specify the path to +`libsecondary` on the link command using the `-rpath/-rpath-link` options, it is +not sufficient to just say `libprimary`. + +For us, it's much easier to just link a static `libsecondary` into a shared +`libprimary`. Especially because in our case, we are linking against a dummy +`libprimary` anyway that we'll throw away. We don't care if the end-user has a +static or dynamic `libsecondary`, that's not our concern. With a static +`libsecondary`, when we need to link `libprimary` into our executable, there's +no dependency chain to worry about as `libprimary` has all the symbols. diff --git a/depends/packages/dbus.mk b/depends/packages/dbus.mk index b6dfda4e7..06e820337 100644 --- a/depends/packages/dbus.mk +++ b/depends/packages/dbus.mk @@ -1,23 +1,27 @@ package=dbus $(package)_version=1.10.18 $(package)_download_path=https://dbus.freedesktop.org/releases/dbus $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=6049ddd5f3f3e2618f615f1faeda0a115104423a7996b7aa73e2f36e38cc514a $(package)_dependencies=expat define $(package)_set_vars - $(package)_config_opts=--disable-tests --disable-doxygen-docs --disable-xml-docs --disable-static --without-x + $(package)_config_opts=--disable-tests --disable-doxygen-docs --disable-xml-docs --disable-shared --without-x endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) -C dbus libdbus-1.la endef define $(package)_stage_cmds $(MAKE) -C dbus DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-dbusincludeHEADERS install-nodist_dbusarchincludeHEADERS && \ $(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/expat.mk b/depends/packages/expat.mk index 9e7ad7137..d3dcc5b05 100644 --- a/depends/packages/expat.mk +++ b/depends/packages/expat.mk @@ -1,21 +1,26 @@ package=expat $(package)_version=2.2.6 $(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_6/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=17b43c2716d521369f82fc2dc70f359860e90fa440bea65b3b85f0b246ea81f2 define $(package)_set_vars -$(package)_config_opts=--disable-static --without-docbook + $(package)_config_opts=--disable-shared --without-docbook + $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/fontconfig.mk b/depends/packages/fontconfig.mk index 57fd6de63..6b21e00d4 100644 --- a/depends/packages/fontconfig.mk +++ b/depends/packages/fontconfig.mk @@ -1,22 +1,26 @@ package=fontconfig $(package)_version=2.12.6 $(package)_download_path=https://www.freedesktop.org/software/fontconfig/release/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017 $(package)_dependencies=freetype expat define $(package)_set_vars $(package)_config_opts=--disable-docs --disable-static endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/freetype.mk b/depends/packages/freetype.mk index 3c812e103..d9c5e4661 100644 --- a/depends/packages/freetype.mk +++ b/depends/packages/freetype.mk @@ -1,22 +1,26 @@ package=freetype $(package)_version=2.7.1 $(package)_download_path=https://download.savannah.gnu.org/releases/$(package) $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=3a3bb2c4e15ffb433f2032f50a5b5a92558206822e22bfe8cbe339af4aa82f88 define $(package)_set_vars $(package)_config_opts=--without-zlib --without-png --without-harfbuzz --without-bzip2 --disable-static $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/libX11.mk b/depends/packages/libX11.mk index b6fb6fb56..f3f1a9824 100644 --- a/depends/packages/libX11.mk +++ b/depends/packages/libX11.mk @@ -1,23 +1,28 @@ package=libX11 $(package)_version=1.6.2 $(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=2aa027e837231d2eeea90f3a4afe19948a6eb4c8b2bec0241eba7dbc8106bd16 $(package)_dependencies=libxcb xtrans xextproto xproto define $(package)_set_vars -$(package)_config_opts=--disable-xkb --disable-static -$(package)_config_opts_linux=--with-pic + # See libXext for --disable-malloc0returnsnull rationale. + $(package)_config_opts=--disable-xkb --disable-static --disable-malloc0returnsnull + $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/libXau.mk b/depends/packages/libXau.mk index ba9810613..7cfd05d8b 100644 --- a/depends/packages/libXau.mk +++ b/depends/packages/libXau.mk @@ -1,23 +1,27 @@ package=libXau $(package)_version=1.0.8 $(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=fdd477320aeb5cdd67272838722d6b7d544887dfe7de46e1e7cc0c27c2bea4f2 $(package)_dependencies=xproto define $(package)_set_vars $(package)_config_opts=--disable-shared $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/libXext.mk b/depends/packages/libXext.mk index 1185fbe8c..b9b1825cc 100644 --- a/depends/packages/libXext.mk +++ b/depends/packages/libXext.mk @@ -1,22 +1,49 @@ package=libXext -$(package)_version=1.3.2 +$(package)_version=1.3.3 $(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 -$(package)_sha256_hash=f829075bc646cdc085fa25d98d5885d83b1759ceb355933127c257e8e50432e0 +$(package)_sha256_hash=b518d4d332231f313371fdefac59e3776f4f0823bcb23cf7c7305bfb57b16e35 $(package)_dependencies=xproto xextproto libX11 libXau define $(package)_set_vars - $(package)_config_opts=--disable-static + # A number of steps in the autoconfig process implicitly assume that the build + # system and the host system are the same. For example, library components + # want to build and run test programs to determine the behavior of certain + # host system elements. This is clearly impossible when crosscompiling. To + # work around these issues, the --enable-malloc0returnsnull (or + # --disable-malloc0returnsnull, depending on the host system) must be passed + # to configure. + # -- https://www.x.org/wiki/CrossCompilingXorg/ + # + # Concretely, between the releases of libXext 1.3.2 and 1.3.3, + # XORG_CHECK_MALLOC_ZERO from xorg-macros was changed to use the autoconf + # cache, expecting cross-compilation environments to seed this cache as there + # is no single correct value when cross compiling (think uclibc, musl, etc.). + # You can see the actual change in commit 72fdc868b56fe2b7bdc9a69872651baeca72 + # in the freedesktop/xorg-macros repo. + # + # As a result of this change, if we don't seed the cache and we don't use + # either --{en,dis}able-malloc0returnsnull, the AC_RUN_IFELSE block has no + # optional action-if-cross-compiling argument and configure prints an error + # message and exits as documented in the autoconf manual. Prior to this + # commit, the AC_RUN_IFELSE block had an action-if-cross-compiling argument + # which set the more pessimistic default value MALLOC_ZERO_RETURNS_NULL=yes. + # This is why the flag was not required prior to libXext 1.3.3. + $(package)_config_opts=--disable-static --disable-malloc0returnsnull endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/libevent.mk b/depends/packages/libevent.mk index 76683d860..669271f9d 100644 --- a/depends/packages/libevent.mk +++ b/depends/packages/libevent.mk @@ -1,30 +1,31 @@ package=libevent $(package)_version=2.1.8-stable $(package)_download_path=https://github.com/libevent/libevent/archive/ $(package)_file_name=release-$($(package)_version).tar.gz $(package)_sha256_hash=316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d define $(package)_preprocess_cmds ./autogen.sh endef define $(package)_set_vars $(package)_config_opts=--disable-shared --disable-openssl --disable-libevent-regress --disable-samples $(package)_config_opts_release=--disable-debug-mode $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef define $(package)_postprocess_cmds + rm lib/*.la endef diff --git a/depends/packages/libxcb.mk b/depends/packages/libxcb.mk index b6fa55514..f4cb676e9 100644 --- a/depends/packages/libxcb.mk +++ b/depends/packages/libxcb.mk @@ -1,35 +1,35 @@ package=libxcb $(package)_version=1.10 $(package)_download_path=https://xcb.freedesktop.org/dist $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=98d9ab05b636dd088603b64229dd1ab2d2cc02ab807892e107d674f9c3f2d5b5 $(package)_dependencies=xcb_proto libXau xproto define $(package)_set_vars $(package)_config_opts=--disable-static endef define $(package)_preprocess_cmds sed "s/pthread-stubs//" -i configure endef # Don't install xcb headers to the default path in order to work around a qt # build issue: https://bugreports.qt.io/browse/QTBUG-34748 # When using qt's internal libxcb, it may end up finding the real headers in # depends staging. Use a non-default path to avoid that. define $(package)_config_cmds $($(package)_autoconf) --includedir=$(host_prefix)/include/xcb-shared endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef define $(package)_postprocess_cmds - rm -rf share/man share/doc + rm -rf share/man share/doc lib/*.la endef diff --git a/depends/packages/protobuf.mk b/depends/packages/protobuf.mk index 294d7a43d..a36d51f6b 100644 --- a/depends/packages/protobuf.mk +++ b/depends/packages/protobuf.mk @@ -1,29 +1,29 @@ package=protobuf $(package)_version=$(native_$(package)_version) $(package)_download_path=$(native_$(package)_download_path) $(package)_file_name=$(native_$(package)_file_name) $(package)_sha256_hash=$(native_$(package)_sha256_hash) $(package)_dependencies=native_$(package) $(package)_cxxflags=-std=c++11 define $(package)_set_vars $(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) -C src libprotobuf.la endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) -C src install-libLTLIBRARIES install-nobase_includeHEADERS &&\ $(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA endef define $(package)_postprocess_cmds - rm lib/libprotoc.a + rm lib/libprotoc.a lib/*.la endef diff --git a/depends/packages/qrencode.mk b/depends/packages/qrencode.mk index e8f927ef7..c9c89971f 100644 --- a/depends/packages/qrencode.mk +++ b/depends/packages/qrencode.mk @@ -1,22 +1,26 @@ package=qrencode $(package)_version=3.4.4 $(package)_download_path=https://fukuchi.org/works/qrencode/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=efe5188b1ddbcbf98763b819b146be6a90481aac30cfc8d858ab78a19cde1fa5 define $(package)_set_vars $(package)_config_opts=--disable-shared -without-tools --disable-sdltest $(package)_config_opts_linux=--with-pic endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/depends/packages/xtrans.mk b/depends/packages/xtrans.mk index 0990b4a85..6f3be6dd2 100644 --- a/depends/packages/xtrans.mk +++ b/depends/packages/xtrans.mk @@ -1,22 +1,22 @@ package=xtrans $(package)_version=1.3.4 $(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/ $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=054d4ee3efd52508c753e9f7bc655ef185a29bd2850dd9e2fc2ccc33544f583a $(package)_dependencies= define $(package)_set_vars -$(package)_config_opts_linux=--with-pic --disable-static +$(package)_config_opts_linux=--with-pic --disable-shared endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 6b907afed..c89130721 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -1,34 +1,34 @@ package=zeromq $(package)_version=4.3.1 $(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb $(package)_patches=0001-fix-build-with-older-mingw64.patch 0002-disable-pthread_set_name_np.patch define $(package)_set_vars $(package)_config_opts=--without-docs --disable-shared --without-libsodium --disable-curve --disable-curve-keygen --disable-perf $(package)_config_opts_linux=--with-pic $(package)_cxxflags=-std=c++11 endef define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/0001-fix-build-with-older-mingw64.patch && \ patch -p1 < $($(package)_patch_dir)/0002-disable-pthread_set_name_np.patch endef define $(package)_config_cmds $($(package)_autoconf) endef define $(package)_build_cmds $(MAKE) -j$(JOBS) src/libzmq.la endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-includeHEADERS install-pkgconfigDATA endef define $(package)_postprocess_cmds sed -i.old "s/ -lstdc++//" lib/pkgconfig/libzmq.pc && \ - rm -rf bin share + rm -rf bin share lib/*.la endef