Skip to content

Commit 03858b2

Browse files
committed
Merge #15844: depends: Purge libtool archives
8541cbe depends: libX*: --disable-malloc0returnsnull in conf (Carl Dong) 0e75263 depends: libXext: Bump to 1.3.3 to fix _XEatDataWords (Carl Dong) 683b7d7 depends: Purge libtool archives (Carl Dong) 1420928 depends: Build secondary deps statically. (Carl Dong) Pull request description: ``` We use pkg-config where we can, which generally replaces libtool at a higher level and does not have the same downsides as libtool. These archives sit in our depends tree with no purpose and pollute the final bitcoin build with massive overlinking. ``` See [here](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives) for an explanation of the various problems libtool archives can cause. Unrelated in every way except in spirit: `-D__LIBTOOL_IS_A_FOOL__`!! ----- This PR is based on #16041, and therefore should be merged after #16041. ACKs for commit 8541cb: Tree-SHA512: 76030cf32361f0b1cfe14e3827a0cbec99994e7da00a56194ca40cf6cf7d87f78552f49d03d41ce9cf9b642992b90d993578ed1f0ad6bae15cd3f1c88dfaa4b0
2 parents 03e2786 + 8541cbe commit 03858b2

File tree

14 files changed

+104
-11
lines changed

14 files changed

+104
-11
lines changed

depends/packages.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The package "mylib" will be used here as an example
55

66
General tips:
77
- mylib_foo is written as $(package)_foo in order to make recipes more similar.
8+
- Secondary dependency packages relative to the bitcoin binaries/libraries (i.e.
9+
those not in `ALLOWED_LIBRARIES` in `contrib/devtools/symbol-check.py`) don't
10+
need to be shared and should be built statically whenever possible. See
11+
[below](#secondary-dependencies) for more details.
812

913
## Identifiers
1014
Each package is required to define at least these variables:
@@ -146,3 +150,34 @@ $($(package)_config_opts) will be appended.
146150
Most autotools projects can be properly staged using:
147151

148152
$(MAKE) DESTDIR=$($(package)_staging_dir) install
153+
154+
## Build outputs:
155+
156+
In general, the output of a depends package should not contain any libtool
157+
archives. Instead, the package should output `.pc` (`pkg-config`) files where
158+
possible.
159+
160+
From the [Gentoo Wiki entry](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives):
161+
162+
> Libtool pulls in all direct and indirect dependencies into the .la files it
163+
> creates. This leads to massive overlinking, which is toxic to the Gentoo
164+
> ecosystem, as it leads to a massive number of unnecessary rebuilds.
165+
166+
## Secondary dependencies:
167+
168+
Secondary dependency packages relative to the bitcoin binaries/libraries (i.e.
169+
those not in `ALLOWED_LIBRARIES` in `contrib/devtools/symbol-check.py`) don't
170+
need to be shared and should be built statically whenever possible. This
171+
improves general build reliability as illustrated by the following example:
172+
173+
When linking an executable against a shared library `libprimary` that has its
174+
own shared dependency `libsecondary`, we may need to specify the path to
175+
`libsecondary` on the link command using the `-rpath/-rpath-link` options, it is
176+
not sufficient to just say `libprimary`.
177+
178+
For us, it's much easier to just link a static `libsecondary` into a shared
179+
`libprimary`. Especially because in our case, we are linking against a dummy
180+
`libprimary` anyway that we'll throw away. We don't care if the end-user has a
181+
static or dynamic `libseconday`, that's not our concern. With a static
182+
`libseconday`, when we need to link `libprimary` into our executable, there's no
183+
dependency chain to worry about as `libprimary` has all the symbols.

depends/packages/dbus.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $(package)_sha256_hash=6049ddd5f3f3e2618f615f1faeda0a115104423a7996b7aa73e2f36e3
66
$(package)_dependencies=expat
77

88
define $(package)_set_vars
9-
$(package)_config_opts=--disable-tests --disable-doxygen-docs --disable-xml-docs --disable-static --without-x
9+
$(package)_config_opts=--disable-tests --disable-doxygen-docs --disable-xml-docs --disable-shared --without-x
1010
endef
1111

1212
define $(package)_config_cmds
@@ -21,3 +21,7 @@ define $(package)_stage_cmds
2121
$(MAKE) -C dbus DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-dbusincludeHEADERS install-nodist_dbusarchincludeHEADERS && \
2222
$(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA
2323
endef
24+
25+
define $(package)_postprocess_cmds
26+
rm lib/*.la
27+
endef

depends/packages/expat.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ $(package)_file_name=$(package)-$($(package)_version).tar.bz2
55
$(package)_sha256_hash=17b43c2716d521369f82fc2dc70f359860e90fa440bea65b3b85f0b246ea81f2
66

77
define $(package)_set_vars
8-
$(package)_config_opts=--disable-static --without-docbook
8+
$(package)_config_opts=--disable-shared --without-docbook
9+
$(package)_config_opts_linux=--with-pic
910
endef
1011

1112
define $(package)_config_cmds
@@ -19,3 +20,7 @@ endef
1920
define $(package)_stage_cmds
2021
$(MAKE) DESTDIR=$($(package)_staging_dir) install
2122
endef
23+
24+
define $(package)_postprocess_cmds
25+
rm lib/*.la
26+
endef

depends/packages/fontconfig.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ endef
2626
define $(package)_stage_cmds
2727
$(MAKE) DESTDIR=$($(package)_staging_dir) install
2828
endef
29+
30+
define $(package)_postprocess_cmds
31+
rm lib/*.la
32+
endef

depends/packages/freetype.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ endef
2020
define $(package)_stage_cmds
2121
$(MAKE) DESTDIR=$($(package)_staging_dir) install
2222
endef
23+
24+
define $(package)_postprocess_cmds
25+
rm lib/*.la
26+
endef

depends/packages/libX11.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ $(package)_sha256_hash=2aa027e837231d2eeea90f3a4afe19948a6eb4c8b2bec0241eba7dbc8
66
$(package)_dependencies=libxcb xtrans xextproto xproto
77

88
define $(package)_set_vars
9-
$(package)_config_opts=--disable-xkb --disable-static
10-
$(package)_config_opts_linux=--with-pic
9+
# See libXext for --disable-malloc0returnsnull rationale.
10+
$(package)_config_opts=--disable-xkb --disable-static --disable-malloc0returnsnull
11+
$(package)_config_opts_linux=--with-pic
1112
endef
1213

1314
define $(package)_preprocess_cmds
@@ -25,3 +26,7 @@ endef
2526
define $(package)_stage_cmds
2627
$(MAKE) DESTDIR=$($(package)_staging_dir) install
2728
endef
29+
30+
define $(package)_postprocess_cmds
31+
rm lib/*.la
32+
endef

depends/packages/libXau.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ endef
2525
define $(package)_stage_cmds
2626
$(MAKE) DESTDIR=$($(package)_staging_dir) install
2727
endef
28+
29+
define $(package)_postprocess_cmds
30+
rm lib/*.la
31+
endef

depends/packages/libXext.mk

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
package=libXext
2-
$(package)_version=1.3.2
2+
$(package)_version=1.3.3
33
$(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/
44
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
5-
$(package)_sha256_hash=f829075bc646cdc085fa25d98d5885d83b1759ceb355933127c257e8e50432e0
5+
$(package)_sha256_hash=b518d4d332231f313371fdefac59e3776f4f0823bcb23cf7c7305bfb57b16e35
66
$(package)_dependencies=xproto xextproto libX11 libXau
77

88
define $(package)_set_vars
9-
$(package)_config_opts=--disable-static
9+
# A number of steps in the autoconfig process implicitly assume that the build
10+
# system and the host system are the same. For example, library components
11+
# want to build and run test programs to determine the behavior of certain
12+
# host system elements. This is clearly impossible when crosscompiling. To
13+
# work around these issues, the --enable-malloc0returnsnull (or
14+
# --disable-malloc0returnsnull, depending on the host system) must be passed
15+
# to configure.
16+
# -- https://www.x.org/wiki/CrossCompilingXorg/
17+
#
18+
# Concretely, between the releases of libXext 1.3.2 and 1.3.3,
19+
# XORG_CHECK_MALLOC_ZERO from xorg-macros was changed to use the autoconf
20+
# cache, expecting cross-compilation environments to seed this cache as there
21+
# is no single correct value when cross compiling (think uclibc, musl, etc.).
22+
# You can see the actual change in commit 72fdc868b56fe2b7bdc9a69872651baeca72
23+
# in the freedesktop/xorg-macros repo.
24+
#
25+
# As a result of this change, if we don't seed the cache and we don't use
26+
# either --{en,dis}able-malloc0returnsnull, the AC_RUN_IFELSE block has no
27+
# optional action-if-cross-compiling argument and configure prints an error
28+
# message and exits as documented in the autoconf manual. Prior to this
29+
# commit, the AC_RUN_IFELSE block had an action-if-cross-compiling argument
30+
# which set the more pessimistic default value MALLOC_ZERO_RETURNS_NULL=yes.
31+
# This is why the flag was not required prior to libXext 1.3.3.
32+
$(package)_config_opts=--disable-static --disable-malloc0returnsnull
1033
endef
1134

1235
define $(package)_preprocess_cmds
@@ -24,3 +47,7 @@ endef
2447
define $(package)_stage_cmds
2548
$(MAKE) DESTDIR=$($(package)_staging_dir) install
2649
endef
50+
51+
define $(package)_postprocess_cmds
52+
rm lib/*.la
53+
endef

depends/packages/libevent.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ define $(package)_stage_cmds
2727
endef
2828

2929
define $(package)_postprocess_cmds
30+
rm lib/*.la
3031
endef

depends/packages/libxcb.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ define $(package)_stage_cmds
3232
endef
3333

3434
define $(package)_postprocess_cmds
35-
rm -rf share/man share/doc
35+
rm -rf share/man share/doc lib/*.la
3636
endef

0 commit comments

Comments
 (0)