How about the two attached patches?
That's on top of the libressl bump for u-boot.
I only built uboot-mvebu with these and didn't check if this works for
the others.
On 13/10/2021 10:10, Rafał Miłecki wrote:
*** Introduction ***
OpenWrt compiles U-Boot with some host tools like mkimage.
*** Problem ***
HOSTLD tools/mkimage
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld:
/home/rmilecki/openwrt/openwrt-master-bcm4908/staging_dir/host/lib/libssl.a(ssl_init.o):
in function `OPENSSL_init_ssl':
ssl_init.c:(.text+0x59): undefined reference to `pthread_once'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld:
/home/rmilecki/openwrt/openwrt-master-bcm4908/staging_dir/host/lib/libcrypto.a(libcrypto_la-crypto_init.o):
in function `OPENSSL_init_crypto':
crypto_init.c:(.text+0x51): undefined reference to `pthread_once'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld:
/home/rmilecki/openwrt/openwrt-master-bcm4908/staging_dir/host/lib/libcrypto.a(libcrypto_la-conf_sap.o):
in function `OpenSSL_config':
conf_sap.c:(.text+0xbc): undefined reference to `pthread_once'
It seems that OpenWrt wants to compile mkimage with statically linked
LibreSSL.
LibreSSL seems to be compiled OK:
$ grep Libs staging_dir/host/lib/pkgconfig/libcrypto.pc
Libs: -L${libdir} -lcrypto
Libs.private: -lresolv -lpthread
Related:
9bfca308268e ("uboot-mvebu: Fix build with libressl 2.7.2")
*** Manual pkg-config test ***
I'm not sure if I test it correctly but output looks OK:
$
PATH=/home/rmilecki/openwrt/openwrt-master-bcm4908/staging_dir/host/bin:$PATH
./staging_dir/host/bin/pkg-config --libs libssl libcrypto
-L/lib64 -lssl -lcrypto
$
PATH=/home/rmilecki/openwrt/openwrt-master-bcm4908/staging_dir/host/bin:$PATH
./staging_dir/host/bin/pkg-config --static --libs libssl libcrypto
-L/lib64 -lssl -lresolv -lpthread -lcrypto -L/lib64 -lresolv -lpthread
-lcrypto -lresolv -lpthread
*** U-Boot code ***
In tools/Makefile it uses:
HOSTLOADLIBES_mkimage += \
$(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo
"-lssl -lcrypto")
Above works for most cases. Adding -pthread was rejected, see:
[U-Boot] [PATCH] Add -pthread to HOSTLOADLIBES_mkimage
https://patchwork.ozlabs.org/project/uboot/patch/befd3339-5c21-407c-85ba-86ba2bb50...@icognize.de/
I guess OpenWrt is special case with static linking.
First of all I'm not sure if that pkg-config shouldn't use --static. I
have no idea how to tell U-Boot we want mkimage built static.
Secondly for some reason pkg-config doesn't seem to work from U-Boot
build context. After dropping "2> /dev/null" I can see:
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libssl', required by 'virtual:world', not found
Package 'libcrypto', required by 'virtual:world', not found
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libssl', required by 'virtual:world', not found
Package 'libcrypto', required by 'virtual:world', not found
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libssl', required by 'virtual:world', not found
Package 'libcrypto', required by 'virtual:world', not found
From f7cfe8ee04803b245fc17735b0f2778c243fabe1 Mon Sep 17 00:00:00 2001
From: Andre Heider <a.hei...@gmail.com>
Date: Wed, 13 Oct 2021 14:00:53 +0200
Subject: [PATCH 1/2] libressl: update pc files to always include private
libraries
These are required for static linking, and usually returned by
`pkg-config --static'. Since we're only building static libraries we add
them here to not have to worry about fixing all users.
Signed-off-by: Andre Heider <a.hei...@gmail.com>
---
...-to-always-include-private-libraries.patch | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 tools/libressl/patches/0001-Update-pc-files-to-always-include-private-libraries.patch
diff --git a/tools/libressl/patches/0001-Update-pc-files-to-always-include-private-libraries.patch b/tools/libressl/patches/0001-Update-pc-files-to-always-include-private-libraries.patch
new file mode 100644
index 0000000000..72f2c16b37
--- /dev/null
+++ b/tools/libressl/patches/0001-Update-pc-files-to-always-include-private-libraries.patch
@@ -0,0 +1,37 @@
+From cbbc9a9b1de6900ece3c3842e1c22d8ed250ee3f Mon Sep 17 00:00:00 2001
+From: Andre Heider <a.hei...@gmail.com>
+Date: Wed, 13 Oct 2021 13:57:17 +0200
+Subject: [PATCH] Update pc files to always include private libraries
+
+These are required for static linking, and usually returned by
+`pkg-config --static'. Since we're only building static libraries we add
+them here to not have to worry about fixing all users.
+
+Signed-off-by: Andre Heider <a.hei...@gmail.com>
+---
+ libcrypto.pc.in | 4 ++--
+ libtls.pc.in | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+--- a/libcrypto.pc.in
++++ b/libcrypto.pc.in
+@@ -8,6 +8,6 @@ includedir=@includedir@
+ Name: LibreSSL-libcrypto
+ Description: LibreSSL cryptography library
+ Version: @VERSION@
+-Libs: -L${libdir} -lcrypto
+-Libs.private: @LIBS@ @PLATFORM_LDADD@
++Libs: -L${libdir} -lcrypto @LIBS@ @PLATFORM_LDADD@
++Libs.private:
+ Cflags: -I${includedir}
+--- a/libtls.pc.in
++++ b/libtls.pc.in
+@@ -8,6 +8,6 @@ includedir=@includedir@
+ Name: LibreSSL-libtls
+ Description: Secure communications using the TLS socket protocol.
+ Version: @VERSION@
+-Libs: -L${libdir} -ltls
+-Libs.private: @LIBS@ @PLATFORM_LDADD@
++Libs: -L${libdir} -ltls @LIBS@ @PLATFORM_LDADD@
++Libs.private:
+ Cflags: -I${includedir}
--
2.33.0
From 33b6d364dff80f9190bddd6ff7e0097b634bb66e Mon Sep 17 00:00:00 2001
From: Andre Heider <a.hei...@gmail.com>
Date: Wed, 13 Oct 2021 14:01:22 +0200
Subject: [PATCH 2/2] u-boot: fix pkg-config usage
Using Host/Exports doesn't work as intended, explicitly add the
required vars so that u-boot finds the required libraries when building
its tools.
Signed-off-by: Andre Heider <a.hei...@gmail.com>
---
include/u-boot.mk | 3 +++
package/boot/uboot-mediatek/Makefile | 2 --
package/boot/uboot-mvebu/Makefile | 2 --
package/boot/uboot-mxs/Makefile | 2 --
package/boot/uboot-zynq/Makefile | 2 --
5 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/include/u-boot.mk b/include/u-boot.mk
index c0a1e87bf3..8c6941b88a 100644
--- a/include/u-boot.mk
+++ b/include/u-boot.mk
@@ -45,6 +45,9 @@ UBOOT_MAKE_FLAGS = \
HOSTCC="$(HOSTCC)" \
HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \
HOSTLDFLAGS="$(HOST_LDFLAGS)" \
+ STAGING_PREFIX="$(STAGING_DIR_HOST)" \
+ PKG_CONFIG_PATH="$(STAGING_DIR_HOST)/lib/pkgconfig" \
+ PKG_CONFIG_LIBDIR="$(STAGING_DIR_HOST)/lib/pkgconfig" \
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
define Build/U-Boot/Target
diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile
index a5801afa2d..5d9459d461 100644
--- a/package/boot/uboot-mediatek/Makefile
+++ b/package/boot/uboot-mediatek/Makefile
@@ -111,8 +111,6 @@ UBOOT_TARGETS := \
UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE:.fip=.bin)
-Build/Exports:=$(Host/Exports)
-
define Build/fip-image
$(STAGING_DIR_HOST)/bin/fiptool create \
--soc-fw $(STAGING_DIR_IMAGE)/$(BUILD_SUBTARGET)-$(BL2_BOOTDEV)-$(BL2_DDRBLOB)ddr-bl31.bin \
diff --git a/package/boot/uboot-mvebu/Makefile b/package/boot/uboot-mvebu/Makefile
index bf03fdd2b2..e2f2a2a382 100644
--- a/package/boot/uboot-mvebu/Makefile
+++ b/package/boot/uboot-mvebu/Makefile
@@ -53,8 +53,6 @@ UBOOT_TARGETS:= \
espressobin \
uDPU
-Build/Exports:=$(Host/Exports)
-
define Build/Configure
# enable additional options beyond <device>_defconfig
echo CONFIG_CMD_SETEXPR=y >> $(PKG_BUILD_DIR)/configs/$(UBOOT_CONFIG)_defconfig
diff --git a/package/boot/uboot-mxs/Makefile b/package/boot/uboot-mxs/Makefile
index f4211d3a54..3c908874fa 100644
--- a/package/boot/uboot-mxs/Makefile
+++ b/package/boot/uboot-mxs/Makefile
@@ -38,8 +38,6 @@ UBOOT_TARGETS := \
UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE)
-Build/Exports:=$(Host/Exports)
-
define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-$(UBOOT_IMAGE)
diff --git a/package/boot/uboot-zynq/Makefile b/package/boot/uboot-zynq/Makefile
index b6b1dc8b85..c605cfaeb2 100644
--- a/package/boot/uboot-zynq/Makefile
+++ b/package/boot/uboot-zynq/Makefile
@@ -60,6 +60,4 @@ endef
define Package/u-boot/install/default
endef
-Build/Exports:=$(Host/Exports)
-
$(eval $(call BuildPackage/U-Boot))
--
2.33.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel