Skip to contentSkip to conversation

package/uboot-tools: fix build with host-openssl

PATCH Superseded Fabrice Fontaine 2 participants 2 messages Apr 28, 2019 – Apr 29, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/uboot-tools: fix build with host-openssl

If host-openssl is built before uboot-tools, build fails because uboot-tools links with openssl headers from host which depends on pthread.h

To fix this issue, don't pass pass HOST_CFLAGS to UBOOT_TOOLS_MAKE_OPTS

As HOST_CFLAGS was added to remove -std=gnu11 in commit 03a808a0999ac031a1e93000d9a3c50ffbcb64a4, add a dependency to gcc >= 4.7 to uboot-tools and mender (its reverse dependency)

Fixes:
- http://autobuild.buildroot.org/results/915b509e814bda16be54a24276b9c740c51e5770

---
 package/mender/Config.in           | 5 +++--
 package/uboot-tools/Config.in      | 4 ++++
 package/uboot-tools/uboot-tools.mk | 1 -
 3 files changed, 7 insertions(+), 3 deletions(-)
package/mender/Config.in +3 -2
index 5ab2304e49..f8896692f7 100644
@@ -3,6 +3,7 @@ config BR2_PACKAGE_MENDER
 	depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
 	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # uboot-tools
 	select BR2_PACKAGE_UBOOT_TOOLS # runtime
 	select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV # runtime
 	help
@@ -13,7 +14,7 @@ config BR2_PACKAGE_MENDER
 
 	  https://github.com/mendersoftware/mender
 
-comment "mender needs a toolchain w/ threads"
+comment "mender needs a toolchain w/ threads, gcc >= 4.7"
 	depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
-	depends on !BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7
package/uboot-tools/Config.in +4 -0
index 681f87b45f..4e6a5104ea 100644
@@ -1,5 +1,6 @@
 config BR2_PACKAGE_UBOOT_TOOLS
 	bool "u-boot tools"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # C++11
 	help
 	  Companion tools for Das U-Boot bootloader.
 
@@ -94,3 +95,6 @@ config BR2_PACKAGE_UBOOT_TOOLS_DUMPIMAGE
 	  extraction of data from U-Boot images.
 
 endif
+
+comment "uboot-tools needs a toolchain w/ gcc >= 4.7"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7
package/uboot-tools/uboot-tools.mk +0 -1
index 61c70b7e7f..c27b2d364b 100644
@@ -19,7 +19,6 @@ endef
 UBOOT_TOOLS_MAKE_OPTS = CROSS_COMPILE="$(TARGET_CROSS)" \
 	CFLAGS="$(TARGET_CFLAGS)" \
 	LDFLAGS="$(TARGET_LDFLAGS)" \
-	HOSTCFLAGS="$(HOST_CFLAGS)" \
 	STRIP=$(TARGET_STRIP)
 
 ifeq ($(BR2_PACKAGE_UBOOT_TOOLS_FIT_SUPPORT),y)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/uboot-tools: fix build with host-openssl

Quoted 5 lines · Fabrice Fontaine

If host-openssl is built before uboot-tools, build fails because uboot-tools links with openssl headers from host which depends on pthread.h

To fix this issue, don't pass pass HOST_CFLAGS to UBOOT_TOOLS_MAKE_OPTS

At first sight, this makes no sense, because the error is in HOSTCC so pthread
should be available.

However, with CROSS_BUILD_TOOLS=y, tools/Makefile sets HOSTCC=$(CC). It forgets
to override HOSTCFLAGS, though, so we're building the tools with target compiler but host CFLAGS.

Quoted 3 lines

As HOST_CFLAGS was added to remove -std=gnu11 in commit 03a808a0999ac031a1e93000d9a3c50ffbcb64a4, add a dependency to gcc >= 4.7 to uboot-tools and mender (its reverse dependency)

This is not really acceptable for me. We should make it as easy as possible for
people to upgrade Buildroot while keeping an old toolchain. And uboot-tools is definitely an essential package.

The more obvious thing to do would be to set HOSTCFLAGS=$(TARGET_CFLAGS) since
we're really abusing HOSTCC to do target compilation (that's basically what CROSS_BUILD_TOOLS=y does). However, that comes in the way of fixdep, which really is a host tool so can't be built with TARGET_CFLAGS (not immediately obvious, but a toolchain that sets TARGET_ABI will probably trigger a build failure there).

So we'd have to build fixdep explicitly in a separate call to make.

Alternatively (probably better), we patch tools/Makefile to also override
HOSTCFLAGS when CROSS_BUILD_TOOLS=y. That sounds like something upstreamable.

For now, it's marked as Changes Requested.

Regards,
Arnout

Quoted 64 lines

Fixes:
- http://autobuild.buildroot.org/results/915b509e814bda16be54a24276b9c740c51e5770

---
 package/mender/Config.in           | 5 +++--
 package/uboot-tools/Config.in      | 4 ++++
 package/uboot-tools/uboot-tools.mk | 1 -
 3 files changed, 7 insertions(+), 3 deletions(-)
package/mender/Config.in +3 -2
index 5ab2304e49..f8896692f7 100644
@@ -3,6 +3,7 @@ config BR2_PACKAGE_MENDER
 	depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
 	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # uboot-tools
 	select BR2_PACKAGE_UBOOT_TOOLS # runtime
 	select BR2_PACKAGE_UBOOT_TOOLS_FWPRINTENV # runtime
 	help
@@ -13,7 +14,7 @@ config BR2_PACKAGE_MENDER
 
 	  https://github.com/mendersoftware/mender
 
-comment "mender needs a toolchain w/ threads"
+comment "mender needs a toolchain w/ threads, gcc >= 4.7"
 	depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
-	depends on !BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7
package/uboot-tools/Config.in +4 -0
index 681f87b45f..4e6a5104ea 100644
@@ -1,5 +1,6 @@
 config BR2_PACKAGE_UBOOT_TOOLS
 	bool "u-boot tools"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # C++11
 	help
 	  Companion tools for Das U-Boot bootloader.
 
@@ -94,3 +95,6 @@ config BR2_PACKAGE_UBOOT_TOOLS_DUMPIMAGE
 	  extraction of data from U-Boot images.
 
 endif
+
+comment "uboot-tools needs a toolchain w/ gcc >= 4.7"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7
package/uboot-tools/uboot-tools.mk +0 -1
index 61c70b7e7f..c27b2d364b 100644
@@ -19,7 +19,6 @@ endef
 UBOOT_TOOLS_MAKE_OPTS = CROSS_COMPILE="$(TARGET_CROSS)" \
 	CFLAGS="$(TARGET_CFLAGS)" \
 	LDFLAGS="$(TARGET_LDFLAGS)" \
-	HOSTCFLAGS="$(HOST_CFLAGS)" \
 	STRIP=$(TARGET_STRIP)
 
 ifeq ($(BR2_PACKAGE_UBOOT_TOOLS_FIT_SUPPORT),y)