Skip to contentSkip to conversation

package/binutils: zlib is mandatory

PATCH In review Fabrice Fontaine 3 participants 3 messages Nov 10, 2021 – Nov 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/binutils: zlib is mandatory

As found out by Yann [1], if zlib is not provided by the system, binutils will use a bundled version. So use --with-system-zlib which is available since version 2.21 and
https://github.com/bminor/binutils-gdb/commit/700d40ca16eb3ba1ecc1e602cb3eec175bdf70f0

This will fix the following build failure with oprofile:

checking for bfd_openr in -lbfd... no
checking for compress in -lz... no
configure: error: libz library not found; required by libbfd

As found out by Arnout [1], this fails infrequently because static is already pretty rare, but in addition zlib is almost always selected by some other package.

Fixes:
- http://autobuild.buildroot.org/results/0e1d16dfbb455a08db80ac5d35613908c3b4163f

[1] https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

---
 package/binutils/Config.in   | 1 +
 package/binutils/binutils.mk | 7 ++-----
 2 files changed, 3 insertions(+), 5 deletions(-)
package/binutils/Config.in +1 -0
index e17a8ec65a..5e1a769998 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_BINUTILS
 	bool "binutils"
 	depends on !BR2_nios2
 	depends on BR2_USE_WCHAR
+	select BR2_PACKAGE_ZLIB
 	help
 	  Install binutils on the target
 
package/binutils/binutils.mk +2 -5
index bfad25422d..13f61be035 100644
@@ -25,7 +25,7 @@ BINUTILS_SITE ?= $(BR2_GNU_MIRROR)/binutils
 BINUTILS_SOURCE ?= binutils-$(BINUTILS_VERSION).tar.xz
 BINUTILS_EXTRA_CONFIG_OPTIONS = $(call qstrip,$(BR2_BINUTILS_EXTRA_CONFIG_OPTIONS))
 BINUTILS_INSTALL_STAGING = YES
-BINUTILS_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES)
+BINUTILS_DEPENDENCIES = zlib $(TARGET_NLS_DEPENDENCIES)
 BINUTILS_MAKE_OPTS = LIBS=$(TARGET_NLS_LIBS)
 BINUTILS_LICENSE = GPL-3.0+, libiberty LGPL-2.1+
 BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB
@@ -51,6 +51,7 @@ BINUTILS_CONF_OPTS = \
 	--target=$(GNU_TARGET_NAME) \
 	--enable-install-libiberty \
 	--enable-build-warnings=no \
+	--with-system-zlib \
 	$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 	$(BINUTILS_EXTRA_CONFIG_OPTIONS)
 
@@ -74,10 +75,6 @@ ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy)
 BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"
 endif
 
-ifeq ($(BR2_PACKAGE_ZLIB),y)
-BINUTILS_DEPENDENCIES += zlib
-endif
-
 # "host" binutils should actually be "cross"
 # We just keep the convention of "host utility" for now
 HOST_BINUTILS_CONF_OPTS = \
Signature · 6 lines
2.33.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Fabrice, All,

On 2021-11-10 18:46 +0100, Fabrice Fontaine spake thusly:

Quoted 2 lines

As found out by Yann [1], if zlib is not provided by the system, binutils will use a bundled version.

This is not exactly true: indeed, even when zlib is provided by the system, binutils *will* use its bundled copy, *unless* explicitly told not to.

Quoted 5 lines

So use --with-system-zlib which is
available since version 2.21 and
https://github.com/bminor/binutils-gdb/commit/700d40ca16eb3ba1ecc1e602cb3eec175bdf70f0

This will fix the following build failure with oprofile:

... in a static configuration without zlib enabled.

I've extended the commit log with those two refinements, and applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 70 lines

checking for bfd_openr in -lbfd... no
checking for compress in -lz... no
configure: error: libz library not found; required by libbfd

As found out by Arnout [1], this fails infrequently because static is already pretty rare, but in addition zlib is almost always selected by some other package.

Fixes:
- http://autobuild.buildroot.org/results/0e1d16dfbb455a08db80ac5d35613908c3b4163f

[1] https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

---
 package/binutils/Config.in   | 1 +
 package/binutils/binutils.mk | 7 ++-----
 2 files changed, 3 insertions(+), 5 deletions(-)
package/binutils/Config.in +1 -0
index e17a8ec65a..5e1a769998 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_BINUTILS
 	bool "binutils"
 	depends on !BR2_nios2
 	depends on BR2_USE_WCHAR
+	select BR2_PACKAGE_ZLIB
 	help
 	  Install binutils on the target
 
package/binutils/binutils.mk +2 -5
index bfad25422d..13f61be035 100644
@@ -25,7 +25,7 @@ BINUTILS_SITE ?= $(BR2_GNU_MIRROR)/binutils
 BINUTILS_SOURCE ?= binutils-$(BINUTILS_VERSION).tar.xz
 BINUTILS_EXTRA_CONFIG_OPTIONS = $(call qstrip,$(BR2_BINUTILS_EXTRA_CONFIG_OPTIONS))
 BINUTILS_INSTALL_STAGING = YES
-BINUTILS_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES)
+BINUTILS_DEPENDENCIES = zlib $(TARGET_NLS_DEPENDENCIES)
 BINUTILS_MAKE_OPTS = LIBS=$(TARGET_NLS_LIBS)
 BINUTILS_LICENSE = GPL-3.0+, libiberty LGPL-2.1+
 BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB
@@ -51,6 +51,7 @@ BINUTILS_CONF_OPTS = \
 	--target=$(GNU_TARGET_NAME) \
 	--enable-install-libiberty \
 	--enable-build-warnings=no \
+	--with-system-zlib \
 	$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 	$(BINUTILS_EXTRA_CONFIG_OPTIONS)
 
@@ -74,10 +75,6 @@ ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy)
 BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"
 endif
 
-ifeq ($(BR2_PACKAGE_ZLIB),y)
-BINUTILS_DEPENDENCIES += zlib
-endif
-
 # "host" binutils should actually be "cross"
 # We just keep the convention of "host utility" for now
 HOST_BINUTILS_CONF_OPTS = \
Signature · 6 lines
2.33.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Fabrice Fontaine
Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabrice" == Fabrice Fontaine <[email protected]> writes:

As found out by Yann [1], if zlib is not provided by the system, binutils will use a bundled version. So use --with-system-zlib which is available since version 2.21 and
https://github.com/bminor/binutils-gdb/commit/700d40ca16eb3ba1ecc1e602cb3eec175bdf70f0

This will fix the following build failure with oprofile:

checking for bfd_openr in -lbfd... no
checking for compress in -lz... no
configure: error: libz library not found; required by libbfd

As found out by Arnout [1], this fails infrequently because static is already pretty rare, but in addition zlib is almost always selected by some other package.

Quoted 6 lines

Fixes:
- http://autobuild.buildroot.org/results/0e1d16dfbb455a08db80ac5d35613908c3b4163f

[1] https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Committed to 2021.02.x and 2021.08.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot