boot/barebox: Fix building of internal scripts
PATCH 1/1 boot/barebox: Fix building of internal scripts
Some barebox targets need to use internal scripts, for example rockchip64 uses scripts/rkimage which requires the pkg-config package to look up the openssl options. Since the buildroot uses its own pkkconf package for this purpose, the scripts cannot be built correctly.
To fix this situation, let's use the CONFIGURATOR_MAKE_ENV wrapper.
HOSTCC scripts/rkimage
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openssl', required by 'virtual:world', not found /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/ccN8Xyaj.o: in function `main':
rkimage.c:(.text.startup+0x218): undefined reference to SHA256_Init' /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: rkimage.c:(.text.startup+0x22b): undefined reference to SHA256_Update' /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: rkimage.c:(.text.startup+0x23e): undefined reference to SHA256_Final' /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: rkimage.c:(.text.startup+0x253): undefined reference to SHA256_Init' /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: rkimage.c:(.text.startup+0x265): undefined reference to SHA256_Update' /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: rkimage.c:(.text.startup+0x275): undefined reference to SHA256_Final'
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:107: scripts/rkimage] Error 1
make[1]: *** [Makefile:976: scripts] Error 2
--- boot/barebox/Config.in | 1 + boot/barebox/barebox.mk | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
boot/barebox/Config.in +1 -0
@@ -1,5 +1,6 @@ config BR2_TARGET_BAREBOX bool "Barebox" + select BR2_PACKAGE_HOST_PKGCONF help The Barebox bootloader, formerly known as U-Boot v2.
boot/barebox/barebox.mk +3 -1
@@ -128,7 +128,9 @@ endef define $(1)_BUILD_CMDS $$($(1)_BUILD_BAREBOXENV_CMDS) - $$($(1)_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) +# In order to compile some barebox target tools we need to use pkg-config, +# so lets always use CONFIGURATOR_MAKE_ENV wrapper. + $$($(1)_CONFIGURATOR_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) $$($(1)_BUILD_CUSTOM_ENV) endef
Signature · 6 lines
2.39.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Alexander,
boot/barebox/Config.in line 3
Quoted 8 lines · On Fri, 21 Jul 2023 09:37:55 +0300 Alexander Shiyan…
boot/barebox/Config.in +1
-0@@ -1,5 +1,6 @@ config BR2_TARGET_BAREBOX bool "Barebox" + select BR2_PACKAGE_HOST_PKGCONF
Strictly speaking, this is not needed.
However, one issue with your patch is that you don't add host-pkgconf in BAREBOX_DEPENDENCIES, so there is nothing that ensures host-pkgconf will be built before barebox.
Another issue is that Barebox is looking for host OpenSSL, and you have no guarantee that OpenSSL is installed system-wide on the build machine. Therefore, a dependency on host-openssl is also needed. I think this calls for an option like BR2_TARGET_UBOOT_NEEDS_OPENSSL, but for Barebox.
boot/barebox/Config.in
Quoted 5 lines
boot/barebox/Config.in +3
-0+# In order to compile some barebox target tools we need to use pkg-config, +# so lets always use CONFIGURATOR_MAKE_ENV wrapper. + $$($(1)_CONFIGURATOR_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) $$($(1)_BUILD_CUSTOM_ENV) endef
I don't think <pkg>_CONFIGURATOR_MAKE_ENV is intended to be used here. It is indeed to be used for the steps related to the configuration of kconfig-package, to run make menuconfig, make xconfig, etc.
In U-Boot, we're doing this:
$(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" \
$(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
$(UBOOT_MAKE_TARGET)So probably we need something similar here.
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thanks for the comments, I will do v2.
пт, 21 июл. 2023 г. в 23:55, Thomas Petazzoni <[email protected]>:
Quoted 50 lines
Hello Alexander,
boot/barebox/Config.in line 3
Quoted 8 lines · On Fri, 21 Jul 2023 09:37:55 +0300 Alexander Shiyan…
boot/barebox/Config.in +1
-0@@ -1,5 +1,6 @@ config BR2_TARGET_BAREBOX bool "Barebox" + select BR2_PACKAGE_HOST_PKGCONFStrictly speaking, this is not needed.
However, one issue with your patch is that you don't add host-pkgconf in
BAREBOX_DEPENDENCIES, so there is nothing that ensures host-pkgconf will be built before barebox.Another issue is that Barebox is looking for host OpenSSL, and you have no guarantee that OpenSSL is installed system-wide on the build machine. Therefore, a dependency on host-openssl is also needed. I think this calls for an option like
BR2_TARGET_UBOOT_NEEDS_OPENSSL, but for Barebox.boot/barebox/Config.in
Quoted 5 lines
boot/barebox/Config.in +3
-0+# In order to compile some barebox target tools we need to use pkg-config, +# so lets always use CONFIGURATOR_MAKE_ENV wrapper. + $$($(1)_CONFIGURATOR_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) $$($(1)_BUILD_CUSTOM_ENV) endefI don't think <pkg>_CONFIGURATOR_MAKE_ENV is intended to be used here. It is indeed to be used for the steps related to the configuration of kconfig-package, to run make menuconfig, make xconfig, etc.
In U-Boot, we're doing this:
$(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" \ $(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \ $(UBOOT_MAKE_TARGET)So probably we need something similar here.
Quoted 7 lines
Best regards,
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot