* [Buildroot] [PATCH] uboot: fix build with old U-Boot versions
@ 2016-07-02 9:25 Thomas Petazzoni
2016-07-03 16:30 ` Carlos Santos
2016-07-05 10:15 ` Thomas Petazzoni
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2016-07-02 9:25 UTC (permalink / raw)
To: buildroot
Since commit 0dca644e443c8f28bfe5aa1c98201dc3b49e1165 ("boot/uboot: fix
missing host-openssl for i.MX28 target"), we pass HOSTCFLAGS/HOSTLDFLAGS
in the environment of U-Boot when building. This is needed to allow
U-Boot to find the OpenSSL headers/libraries when they are
needed. Unfortunately, this breaks the build with old U-Boot versions as
the U-Boot Makefiles were not designed to have HOSTCFLAGS/HOSTLDFLAGS
passed in, which causes some important CFLAGS from the U-Boot build
system to be ignored.
To address this, we only pass HOSTCFLAGS/HOSTLDFLAGS when OpenSSL
support is needed. We make the assumption that the OpenSSL requirement
only exists in sufficiently recent U-Boot versions, for which passing
HOSTCFLAGS/HOSTLDFLAGS work fine.
Reported-by: Carlos Santos <casantos@datacom.ind.br>
Cc: Carlos Santos <casantos@datacom.ind.br>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
boot/uboot/uboot.mk | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index a2274ee..50d7045 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -64,15 +64,18 @@ UBOOT_BIN = u-boot.sb
UBOOT_MAKE_TARGET = $(UBOOT_BIN)
# mxsimage needs OpenSSL
UBOOT_DEPENDENCIES += host-elftosb host-openssl
+UBOOT_NEEDS_OPENSSL = y
else ifeq ($(BR2_TARGET_UBOOT_FORMAT_SD),y)
# BootStream (.sb) is generated by U-Boot, we convert it to SD format
UBOOT_BIN = u-boot.sd
UBOOT_MAKE_TARGET = u-boot.sb
UBOOT_DEPENDENCIES += host-elftosb host-openssl
+UBOOT_NEEDS_OPENSSL = y
else ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND),y)
UBOOT_BIN = u-boot.nand
UBOOT_MAKE_TARGET = u-boot.sb
UBOOT_DEPENDENCIES += host-elftosb host-openssl
+UBOOT_NEEDS_OPENSSL = y
else ifeq ($(BR2_TARGET_UBOOT_FORMAT_CUSTOM),y)
UBOOT_BIN = $(call qstrip,$(BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME))
else
@@ -92,9 +95,18 @@ endif
UBOOT_MAKE_OPTS += \
CROSS_COMPILE="$(TARGET_CROSS)" \
- ARCH=$(UBOOT_ARCH) \
+ ARCH=$(UBOOT_ARCH)
+
+# Passing HOST_CFLAGS and HOST_LDFLAGS is only needed when we have
+# host-openssl as a dependency. We could pass them unconditionally,
+# but this causes build issues with old U-Boot versions. We assume
+# that old U-Boot versions didn't had support for generating images
+# that required OpenSSL.
+ifeq ($(UBOOT_NEEDS_OPENSSL),y)
+UBOOT_MAKE_OPTS += \
HOSTCFLAGS="$(HOST_CFLAGS)" \
HOSTLDFLAGS="$(HOST_LDFLAGS)"
+endif
ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
UBOOT_DEPENDENCIES += host-dtc
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH] uboot: fix build with old U-Boot versions
2016-07-02 9:25 [Buildroot] [PATCH] uboot: fix build with old U-Boot versions Thomas Petazzoni
@ 2016-07-03 16:30 ` Carlos Santos
2016-07-05 10:15 ` Thomas Petazzoni
1 sibling, 0 replies; 3+ messages in thread
From: Carlos Santos @ 2016-07-03 16:30 UTC (permalink / raw)
To: buildroot
> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: buildroot at uclibc.org
> Cc: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>, "Carlos Santos" <casantos@datacom.ind.br>
> Sent: Saturday, July 2, 2016 6:25:43 AM
> Subject: [PATCH] uboot: fix build with old U-Boot versions
> Since commit 0dca644e443c8f28bfe5aa1c98201dc3b49e1165 ("boot/uboot: fix
> missing host-openssl for i.MX28 target"), we pass HOSTCFLAGS/HOSTLDFLAGS
> in the environment of U-Boot when building. This is needed to allow
> U-Boot to find the OpenSSL headers/libraries when they are
> needed. Unfortunately, this breaks the build with old U-Boot versions as
> the U-Boot Makefiles were not designed to have HOSTCFLAGS/HOSTLDFLAGS
> passed in, which causes some important CFLAGS from the U-Boot build
> system to be ignored.
>
> To address this, we only pass HOSTCFLAGS/HOSTLDFLAGS when OpenSSL
> support is needed. We make the assumption that the OpenSSL requirement
> only exists in sufficiently recent U-Boot versions, for which passing
> HOSTCFLAGS/HOSTLDFLAGS work fine.
>
> Reported-by: Carlos Santos <casantos@datacom.ind.br>
> Cc: Carlos Santos <casantos@datacom.ind.br>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> boot/uboot/uboot.mk | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
> index a2274ee..50d7045 100644
> --- a/boot/uboot/uboot.mk
> +++ b/boot/uboot/uboot.mk
> @@ -64,15 +64,18 @@ UBOOT_BIN = u-boot.sb
> UBOOT_MAKE_TARGET = $(UBOOT_BIN)
> # mxsimage needs OpenSSL
> UBOOT_DEPENDENCIES += host-elftosb host-openssl
> +UBOOT_NEEDS_OPENSSL = y
What about "UBOOT_NEEDS_HOST_OPENSSL", instead?
> else ifeq ($(BR2_TARGET_UBOOT_FORMAT_SD),y)
> # BootStream (.sb) is generated by U-Boot, we convert it to SD format
> UBOOT_BIN = u-boot.sd
> UBOOT_MAKE_TARGET = u-boot.sb
> UBOOT_DEPENDENCIES += host-elftosb host-openssl
> +UBOOT_NEEDS_OPENSSL = y
> else ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND),y)
> UBOOT_BIN = u-boot.nand
> UBOOT_MAKE_TARGET = u-boot.sb
> UBOOT_DEPENDENCIES += host-elftosb host-openssl
> +UBOOT_NEEDS_OPENSSL = y
> else ifeq ($(BR2_TARGET_UBOOT_FORMAT_CUSTOM),y)
> UBOOT_BIN = $(call qstrip,$(BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME))
> else
> @@ -92,9 +95,18 @@ endif
>
> UBOOT_MAKE_OPTS += \
> CROSS_COMPILE="$(TARGET_CROSS)" \
> - ARCH=$(UBOOT_ARCH) \
> + ARCH=$(UBOOT_ARCH)
I'd still pass HOSTCC="$(HOSTCC)" here, too, to prevent future problems. It is detected as just "gcc" by U-Boot 2012.10 and as "cc" by U-Boot 2015.01.
> +
> +# Passing HOST_CFLAGS and HOST_LDFLAGS is only needed when we have
> +# host-openssl as a dependency. We could pass them unconditionally,
> +# but this causes build issues with old U-Boot versions. We assume
> +# that old U-Boot versions didn't had support for generating images
> +# that required OpenSSL.
> +ifeq ($(UBOOT_NEEDS_OPENSSL),y)
> +UBOOT_MAKE_OPTS += \
> HOSTCFLAGS="$(HOST_CFLAGS)" \
> HOSTLDFLAGS="$(HOST_LDFLAGS)"
> +endif
>
> ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
> UBOOT_DEPENDENCIES += host-dtc
> --
> 2.7.4
Carlos Santos (Casantos)
DATACOM, P&D
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH] uboot: fix build with old U-Boot versions
2016-07-02 9:25 [Buildroot] [PATCH] uboot: fix build with old U-Boot versions Thomas Petazzoni
2016-07-03 16:30 ` Carlos Santos
@ 2016-07-05 10:15 ` Thomas Petazzoni
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2016-07-05 10:15 UTC (permalink / raw)
To: buildroot
Hello,
On Sat, 2 Jul 2016 11:25:43 +0200, Thomas Petazzoni wrote:
> Since commit 0dca644e443c8f28bfe5aa1c98201dc3b49e1165 ("boot/uboot: fix
> missing host-openssl for i.MX28 target"), we pass HOSTCFLAGS/HOSTLDFLAGS
> in the environment of U-Boot when building. This is needed to allow
> U-Boot to find the OpenSSL headers/libraries when they are
> needed. Unfortunately, this breaks the build with old U-Boot versions as
> the U-Boot Makefiles were not designed to have HOSTCFLAGS/HOSTLDFLAGS
> passed in, which causes some important CFLAGS from the U-Boot build
> system to be ignored.
>
> To address this, we only pass HOSTCFLAGS/HOSTLDFLAGS when OpenSSL
> support is needed. We make the assumption that the OpenSSL requirement
> only exists in sufficiently recent U-Boot versions, for which passing
> HOSTCFLAGS/HOSTLDFLAGS work fine.
>
> Reported-by: Carlos Santos <casantos@datacom.ind.br>
> Cc: Carlos Santos <casantos@datacom.ind.br>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
I applied a different version, where I use Arnout's suggestion of
simply passing HOST_CFLAGS in the HOSTCC variable.
See:
https://git.buildroot.org/buildroot/commit/?id=1c2eb2684f54cc182783419f1a0f489f5d5ca808
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-05 10:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-02 9:25 [Buildroot] [PATCH] uboot: fix build with old U-Boot versions Thomas Petazzoni
2016-07-03 16:30 ` Carlos Santos
2016-07-05 10:15 ` Thomas Petazzoni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.