Skip to contentSkip to conversation

boot/uboot: fix uboot build

PATCH New Kory Maincent 3 participants 6 messages Feb 4, 2021 – Jun 29, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot/uboot: fix uboot build

The make all command run the tools/makefile on the process. This makefile use "pkg-config" command to support static link. The issue is the use of pkg-config configured for crosscompiling to build binaries tools for host architecture.
To fix it, I copied the behavior of QtWebengine by using a pkg-config executable preconfigured for host.

---
 boot/uboot/host-pkg-config.in |  6 ++++++
 boot/uboot/uboot.mk           | 10 +++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 boot/uboot/host-pkg-config.in
boot/uboot/host-pkg-config.in new file +6 -0
new file mode 100644
index 0000000000..86a980648b
@@ -0,0 +1,6 @@
+#!/bin/sh
+PKG_CONFIG_SYSROOT_DIR="/" \
+PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
+PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
+PKG_CONFIG_LIBDIR="@HOST_DIR@/lib/pkgconfig:@HOST_DIR@/share/pkgconfig" \
+exec @HOST_DIR@/bin/pkgconf "$@"
boot/uboot/uboot.mk +9 -1
index 2478a2a1e9..0bcc1ac9a9 100644
@@ -302,11 +302,19 @@ endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
 
 UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
 
+define UBOOT_CREATE_HOST_PKG_CONFIG
+	mkdir -p $(@D)/host-bin
+	sed s%@HOST_DIR@%$(HOST_DIR)%g $(UBOOT_PKGDIR)/host-pkg-config.in > $(@D)/host-bin/pkg-config
+	chmod +x $(@D)/host-bin/pkg-config
+endef
+UBOOT_PRE_CONFIGURE_HOOKS = UBOOT_CREATE_HOST_PKG_CONFIG
+UBOOT_ENV = PATH=$(@D)/host-bin:$(BR_PATH)
+
 define UBOOT_BUILD_CMDS
 	$(if $(UBOOT_CUSTOM_DTS_PATH),
 		cp -f $(UBOOT_CUSTOM_DTS_PATH) $(@D)/arch/$(UBOOT_ARCH)/dts/
 	)
-	$(TARGET_CONFIGURE_OPTS) \
+	$(TARGET_CONFIGURE_OPTS) $(UBOOT_ENV) \
 		$(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
 		$(UBOOT_MAKE_TARGET)
 	$(if $(BR2_TARGET_UBOOT_FORMAT_SD),
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 boot/uboot: fix uboot build

Hello Kory,

Quoted 8 lines · On Thu, 4 Feb 2021 18:04:46 +0100 Kory Maincent <[email protected]>…

The make all command run the tools/makefile on the process. This makefile use "pkg-config" command to support static link. The issue is the use of pkg-config configured for crosscompiling to build binaries tools for host architecture.
To fix it, I copied the behavior of QtWebengine by using a pkg-config executable preconfigured for host.

Thanks for the patch. It would require a better commit title though, as "fix uboot build" is very vague.

Quoted 24 lines
boot/uboot/host-pkg-config.in new file +6 -0
new file mode 100644
index 0000000000..86a980648b
@@ -0,0 +1,6 @@
+#!/bin/sh
+PKG_CONFIG_SYSROOT_DIR="/" \
+PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
+PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
+PKG_CONFIG_LIBDIR="@HOST_DIR@/lib/pkgconfig:@HOST_DIR@/share/pkgconfig" \
+exec @HOST_DIR@/bin/pkgconf "$@"
boot/uboot/uboot.mk +4 -0
index 2478a2a1e9..0bcc1ac9a9 100644
@@ -302,11 +302,19 @@ endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
 
 UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
 
+define UBOOT_CREATE_HOST_PKG_CONFIG
+	mkdir -p $(@D)/host-bin
+	sed s%@HOST_DIR@%$(HOST_DIR)%g $(UBOOT_PKGDIR)/host-pkg-config.in > $(@D)/host-bin/pkg-config
+	chmod +x $(@D)/host-bin/pkg-config

boot/uboot/uboot.mk endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY · line 317

Quoted 10 lines
boot/uboot/uboot.mk +5 -1
+endef
+UBOOT_PRE_CONFIGURE_HOOKS = UBOOT_CREATE_HOST_PKG_CONFIG
+UBOOT_ENV = PATH=$(@D)/host-bin:$(BR_PATH)
+
 define UBOOT_BUILD_CMDS
 	$(if $(UBOOT_CUSTOM_DTS_PATH),
 		cp -f $(UBOOT_CUSTOM_DTS_PATH) $(@D)/arch/$(UBOOT_ARCH)/dts/
 	)
-	$(TARGET_CONFIGURE_OPTS) \
+	$(TARGET_CONFIGURE_OPTS) $(UBOOT_ENV) \

After discussing with Yann E. Morin on IRC, could you try this change instead:

	$(TARGET_CONFIGURE_OPTS) \
	        PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
        	PKG_CONFIG_SYSROOT_DIR="/" \
	        PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
	        PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
	        PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"

The reasoning is that U-Boot anyway only uses pkg-config for host tools, so we could just as well pass those environment variables when building U-Boot.

Could you try this out?

Also, do you have a Buildroot .config to reproduce the issue? Perhaps it would be nice to have a test case in our runtime test infrastructure.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 boot/uboot: fix uboot build

Hello Thomas,

Quoted 12 lines · On Tue, 16 Mar 2021 23:08:52 +0100 Thomas Petazzoni…

Hello Kory,

Quoted 7 lines · On Thu, 4 Feb 2021 18:04:46 +0100 Kory Maincent <[email protected]>…

The make all command run the tools/makefile on the process. This makefile use "pkg-config" command to support static link. The issue is the use of pkg-config configured for crosscompiling to build binaries tools for host architecture.
To fix it, I copied the behavior of QtWebengine by using a pkg-config executable preconfigured for host.

Quoted 4 lines
Quoted 1 line

Thanks for the patch. It would require a better commit title though, as "fix uboot build" is very vague.

Ok I will change it for v2.

Quoted 10 lines

After discussing with Yann E. Morin on IRC, could you try this change instead:

	$(TARGET_CONFIGURE_OPTS) \
	        PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
        	PKG_CONFIG_SYSROOT_DIR="/" \
	        PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
	        PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
	        PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"
Quoted 5 lines

The reasoning is that U-Boot anyway only uses pkg-config for host tools, so we could just as well pass those environment variables when building U-Boot.

Could you try this out?

This change works well, the build of U-boot ends properly.

Quoted 3 lines

Also, do you have a Buildroot .config to reproduce the issue? Perhaps it would be nice to have a test case in our runtime test infrastructure.

You can find the defconfig that break the U-boot build in attachment.

Regards,

K?ry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new_defconfig
Type: application/octet-stream
Size: 215 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210325/569035d6/attachment.obj>

#3 lore raw

PATCH 1/1 boot/uboot: fix uboot build

Quoted 10 lines · On Thu, 25 Mar 2021 17:34:59 +0100 K?ry Maincent <[email protected]>…
Quoted 10 lines

After discussing with Yann E. Morin on IRC, could you try this change instead:

	$(TARGET_CONFIGURE_OPTS) \
	        PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
        	PKG_CONFIG_SYSROOT_DIR="/" \
	        PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
	        PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
	        PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"
Quoted 7 lines
Quoted 5 lines

The reasoning is that U-Boot anyway only uses pkg-config for host tools, so we could just as well pass those environment variables when building U-Boot.

Could you try this out?

This change works well, the build of U-boot ends properly.

Excellent, thanks!

Quoted 1 line

You can find the defconfig that break the U-boot build in attachment.

Perhaps it would be good to capture this defconfig as a test in support/testing/, so we can make sure this doesn't regress?

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 boot/uboot: fix uboot build

In reply to Köry Maincent

K?ry, All,

On 2021-03-25 17:34 +0100, K?ry Maincent spake thusly:

Quoted 26 lines
Quoted 9 lines · On Tue, 16 Mar 2021 23:08:52 +0100 Thomas Petazzoni…
Quoted 7 lines · On Thu, 4 Feb 2021 18:04:46 +0100 Kory Maincent <[email protected]>…

The make all command run the tools/makefile on the process. This makefile use "pkg-config" command to support static link. The issue is the use of pkg-config configured for crosscompiling to build binaries tools for host architecture.
To fix it, I copied the behavior of QtWebengine by using a pkg-config executable preconfigured for host.

Quoted 3 lines
Quoted 1 line

Thanks for the patch. It would require a better commit title though, as "fix uboot build" is very vague.

Ok I will change it for v2.

Quoted 10 lines

After discussing with Yann E. Morin on IRC, could you try this change instead:

	$(TARGET_CONFIGURE_OPTS) \
	        PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
        	PKG_CONFIG_SYSROOT_DIR="/" \
	        PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
	        PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
	        PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"
Quoted 7 lines
Quoted 5 lines

The reasoning is that U-Boot anyway only uses pkg-config for host tools, so we could just as well pass those environment variables when building U-Boot.

Could you try this out?

This change works well, the build of U-boot ends properly.

I don't seem to have seen a v2 of this patch. Do you plan on sending it soonish? ;-)

Thanks!

Regards,
Yann E. MORIN.

Signature · 6 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.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/1 boot/uboot: fix uboot build

Hello Yann,

Quoted 33 lines · On Mon, 28 Jun 2021 22:26:56 +0200 "Yann E. MORIN" <[email protected]>…

K?ry, All,

On 2021-03-25 17:34 +0100, K?ry Maincent spake thusly:

Quoted 30 lines
Quoted 9 lines · On Tue, 16 Mar 2021 23:08:52 +0100 Thomas Petazzoni…
Quoted 7 lines · On Thu, 4 Feb 2021 18:04:46 +0100 Kory Maincent <[email protected]>…

The make all command run the tools/makefile on the process. This makefile use "pkg-config" command to support static link. The issue is the use of pkg-config configured for crosscompiling to build binaries tools for host architecture.
To fix it, I copied the behavior of QtWebengine by using a pkg-config executable preconfigured for host.

Quoted 3 lines
Quoted 1 line

Thanks for the patch. It would require a better commit title though, as "fix uboot build" is very vague.

Ok I will change it for v2.

Quoted 14 lines

After discussing with Yann E. Morin on IRC, could you try this change instead:

	$(TARGET_CONFIGURE_OPTS) \
	        PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
        	PKG_CONFIG_SYSROOT_DIR="/" \
	        PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
	        PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
	        PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig"

The reasoning is that U-Boot anyway only uses pkg-config for host tools, so we could just as well pass those environment variables when building U-Boot.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Could you try this out?

This change works well, the build of U-boot ends properly.

I don't seem to have seen a v2 of this patch. Do you plan on sending it soonish? ;-)

Sorry, I put it aside for a time.
I need to finish the test case asked by Thomas, I will try to find time to do it soon.

Regards

K?ry