diff mbox series

[1/1] package/rsync: fix openssl static build

Message ID 20231229214418.9331-1-fontaine.fabrice@gmail.com
State Accepted
Headers show
Series [1/1] package/rsync: fix openssl static build | expand

Commit Message

Fabrice Fontaine Dec. 29, 2023, 9:44 p.m. UTC
Fix the following openssl static build raised since commit
80fa5672da85a110e60be0d2143e85f9e08a0f4a:

/home/buildroot/autobuild/instance-0/output-1/host/lib/gcc/aarch64_be-buildroot-linux-uclibc/12.3.0/../../../../aarch64_be-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/aarch64_be-buildroot-linux-uclibc/sysroot/lib/../lib64/libcrypto.a(libcrypto-lib-c_zlib.o): in function `zlib_oneshot_expand_block':
c_zlib.c:(.text+0xaec): undefined reference to `uncompress'

Commit b9a062b354953f3fbfee702bb5b5007598299925 can also be reverted as
pkg-config will also retrieve -latomic to avoid the following build
failure:

/home/autobuild/autobuild/instance-1/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/autobuild/autobuild/instance-1/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_atomic_add':
threads_pthread.c:(.text+0x208): undefined reference to `__atomic_is_lock_free'

RSYNC_POST_CONFIGURE_HOOKS must be added to call reconfigure and avoid
the following build failure after autoreconf:

autoconf -o configure.sh
autoheader && touch config.h.in
configure.sh has CHANGED.
config.h.in is unchanged.
You may need to run:
  make reconfigure

Fixes:
 - http://autobuild.buildroot.org/results/6c1636f7556e7370a4c9f6d02c63cf3e20dc985c
 - http://autobuild.buildroot.org/results/49abbaa1eab94b248bff434b40728065d687e278

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...py-in-crypto-lib-instead-of-MD5_Init.patch | 28 +++++++++++
 ...-pkg-config-to-retrieve-openssl-depe.patch | 48 +++++++++++++++++++
 package/rsync/rsync.mk                        | 12 +++--
 3 files changed, 84 insertions(+), 4 deletions(-)
 create mode 100644 package/rsync/0001-Check-for-EVP_MD_CTX_copy-in-crypto-lib-instead-of-MD5_Init.patch
 create mode 100644 package/rsync/0002-configure.ac-use-pkg-config-to-retrieve-openssl-depe.patch

Comments

Thomas Petazzoni Feb. 12, 2024, 10:04 p.m. UTC | #1
On Fri, 29 Dec 2023 22:44:18 +0100
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> Fix the following openssl static build raised since commit
> 80fa5672da85a110e60be0d2143e85f9e08a0f4a:
> 
> /home/buildroot/autobuild/instance-0/output-1/host/lib/gcc/aarch64_be-buildroot-linux-uclibc/12.3.0/../../../../aarch64_be-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/aarch64_be-buildroot-linux-uclibc/sysroot/lib/../lib64/libcrypto.a(libcrypto-lib-c_zlib.o): in function `zlib_oneshot_expand_block':
> c_zlib.c:(.text+0xaec): undefined reference to `uncompress'
> 
> Commit b9a062b354953f3fbfee702bb5b5007598299925 can also be reverted as
> pkg-config will also retrieve -latomic to avoid the following build
> failure:
> 
> /home/autobuild/autobuild/instance-1/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/autobuild/autobuild/instance-1/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_atomic_add':
> threads_pthread.c:(.text+0x208): undefined reference to `__atomic_is_lock_free'
> 
> RSYNC_POST_CONFIGURE_HOOKS must be added to call reconfigure and avoid
> the following build failure after autoreconf:
> 
> autoconf -o configure.sh
> autoheader && touch config.h.in
> configure.sh has CHANGED.
> config.h.in is unchanged.
> You may need to run:
>   make reconfigure
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/6c1636f7556e7370a4c9f6d02c63cf3e20dc985c
>  - http://autobuild.buildroot.org/results/49abbaa1eab94b248bff434b40728065d687e278
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  ...py-in-crypto-lib-instead-of-MD5_Init.patch | 28 +++++++++++
>  ...-pkg-config-to-retrieve-openssl-depe.patch | 48 +++++++++++++++++++
>  package/rsync/rsync.mk                        | 12 +++--
>  3 files changed, 84 insertions(+), 4 deletions(-)
>  create mode 100644 package/rsync/0001-Check-for-EVP_MD_CTX_copy-in-crypto-lib-instead-of-MD5_Init.patch
>  create mode 100644 package/rsync/0002-configure.ac-use-pkg-config-to-retrieve-openssl-depe.patch

Applied to master, thanks.

Thomas
Peter Korsgaard March 16, 2024, 9:09 p.m. UTC | #2
>>>>> "Thomas" == Thomas Petazzoni via buildroot <buildroot@buildroot.org> writes:

 > On Fri, 29 Dec 2023 22:44:18 +0100
 > Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

 >> Fix the following openssl static build raised since commit
 >> 80fa5672da85a110e60be0d2143e85f9e08a0f4a:
 >> 
 >> /home/buildroot/autobuild/instance-0/output-1/host/lib/gcc/aarch64_be-buildroot-linux-uclibc/12.3.0/../../../../aarch64_be-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/aarch64_be-buildroot-linux-uclibc/sysroot/lib/../lib64/libcrypto.a(libcrypto-lib-c_zlib.o): in function `zlib_oneshot_expand_block':
 >> c_zlib.c:(.text+0xaec): undefined reference to `uncompress'
 >> 
 >> Commit b9a062b354953f3fbfee702bb5b5007598299925 can also be reverted as
 >> pkg-config will also retrieve -latomic to avoid the following build
 >> failure:
 >> 
 >> /home/autobuild/autobuild/instance-1/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/autobuild/autobuild/instance-1/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_atomic_add':
 >> threads_pthread.c:(.text+0x208): undefined reference to `__atomic_is_lock_free'
 >> 
 >> RSYNC_POST_CONFIGURE_HOOKS must be added to call reconfigure and avoid
 >> the following build failure after autoreconf:
 >> 
 >> autoconf -o configure.sh
 >> autoheader && touch config.h.in
 >> configure.sh has CHANGED.
 >> config.h.in is unchanged.
 >> You may need to run:
 >> make reconfigure
 >> 
 >> Fixes:
 >> - http://autobuild.buildroot.org/results/6c1636f7556e7370a4c9f6d02c63cf3e20dc985c
 >> - http://autobuild.buildroot.org/results/49abbaa1eab94b248bff434b40728065d687e278
 >> 
 >> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
 >> ---
 >> ...py-in-crypto-lib-instead-of-MD5_Init.patch | 28 +++++++++++
 >> ...-pkg-config-to-retrieve-openssl-depe.patch | 48 +++++++++++++++++++
 >> package/rsync/rsync.mk                        | 12 +++--
 >> 3 files changed, 84 insertions(+), 4 deletions(-)
 >> create mode 100644 package/rsync/0001-Check-for-EVP_MD_CTX_copy-in-crypto-lib-instead-of-MD5_Init.patch
 >> create mode 100644 package/rsync/0002-configure.ac-use-pkg-config-to-retrieve-openssl-depe.patch

 > Applied to master, thanks.

Committed to 2023.02.x and 2023.11.x, thanks.
diff mbox series

Patch

diff --git a/package/rsync/0001-Check-for-EVP_MD_CTX_copy-in-crypto-lib-instead-of-MD5_Init.patch b/package/rsync/0001-Check-for-EVP_MD_CTX_copy-in-crypto-lib-instead-of-MD5_Init.patch
new file mode 100644
index 0000000000..5381159968
--- /dev/null
+++ b/package/rsync/0001-Check-for-EVP_MD_CTX_copy-in-crypto-lib-instead-of-MD5_Init.patch
@@ -0,0 +1,28 @@ 
+From 556a2c5bc2f6244f140a96302d4df92cfc25af8b Mon Sep 17 00:00:00 2001
+From: Wayne Davison <wayne@opencoder.net>
+Date: Tue, 25 Oct 2022 21:55:53 -0700
+Subject: [PATCH] Check for EVP_MD_CTX_copy in crypto lib instead of MD5_Init.
+
+Upstream: https://github.com/WayneD/rsync/commit/556a2c5bc2f6244f140a96302d4df92cfc25af8b
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index a2c99558..ccad7f13 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -432,10 +432,10 @@ AH_TEMPLATE([USE_OPENSSL],
+ if test x"$enable_openssl" != x"no"; then
+     if test x"$ac_cv_header_openssl_md4_h" = x"yes" && test x"$ac_cv_header_openssl_md5_h" = x"yes"; then
+       AC_MSG_RESULT(yes)
+-      AC_SEARCH_LIBS(MD5_Init, crypto,
++      AC_SEARCH_LIBS(EVP_MD_CTX_copy, crypto,
+           [AC_DEFINE(USE_OPENSSL)
+ 	   enable_openssl=yes],
+-          [err_msg="$err_msg$nl- Failed to find MD5_Init function in openssl crypto lib.";
++          [err_msg="$err_msg$nl- Failed to find EVP_MD_CTX_copy function in openssl crypto lib.";
+ 	   no_lib="$no_lib openssl"])
+     else
+         AC_MSG_RESULT(no)
diff --git a/package/rsync/0002-configure.ac-use-pkg-config-to-retrieve-openssl-depe.patch b/package/rsync/0002-configure.ac-use-pkg-config-to-retrieve-openssl-depe.patch
new file mode 100644
index 0000000000..61fe4b0269
--- /dev/null
+++ b/package/rsync/0002-configure.ac-use-pkg-config-to-retrieve-openssl-depe.patch
@@ -0,0 +1,48 @@ 
+From 93865bad4c00e7d3c867965663fdb9a1a0448db8 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sun, 1 Jan 2023 16:53:23 +0100
+Subject: [PATCH] configure.ac: use pkg-config to retrieve openssl dependencies
+
+Use pkg-config to retrieve openssl dependencies such as -latomic and
+avoids the following build failure when building statically on
+architectures such as sparc:
+
+/home/autobuild/autobuild/instance-1/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/autobuild/autobuild/instance-1/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_atomic_add':
+threads_pthread.c:(.text+0x208): undefined reference to `__atomic_is_lock_free'
+
+Fixes:
+ - http://autobuild.buildroot.org/results/49abbaa1eab94b248bff434b40728065d687e278
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Upstream: https://github.com/WayneD/rsync/pull/426
+---
+ configure.ac | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index ccad7f13..b9591866 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -432,11 +432,15 @@ AH_TEMPLATE([USE_OPENSSL],
+ if test x"$enable_openssl" != x"no"; then
+     if test x"$ac_cv_header_openssl_md4_h" = x"yes" && test x"$ac_cv_header_openssl_md5_h" = x"yes"; then
+       AC_MSG_RESULT(yes)
+-      AC_SEARCH_LIBS(EVP_MD_CTX_copy, crypto,
++      PKG_CHECK_MODULES(LIBCRYPTO, libcrypto,
+           [AC_DEFINE(USE_OPENSSL)
+-	   enable_openssl=yes],
+-          [err_msg="$err_msg$nl- Failed to find EVP_MD_CTX_copy function in openssl crypto lib.";
+-	   no_lib="$no_lib openssl"])
++           enable_openssl=yes
++           LIBS="$LIBS $LIBCRYPTO_LIBS"],
++          [AC_SEARCH_LIBS(EVP_MD_CTX_copy, crypto,
++              [AC_DEFINE(USE_OPENSSL)
++	       enable_openssl=yes],
++              [err_msg="$err_msg$nl- Failed to find EVP_MD_CTX_copy function in openssl crypto lib.";
++	       no_lib="$no_lib openssl"])])
+     else
+         AC_MSG_RESULT(no)
+ 	err_msg="$err_msg$nl- Failed to find openssl/md4.h and openssl/md5.h for openssl crypto lib support."
+-- 
+2.35.1
+
diff --git a/package/rsync/rsync.mk b/package/rsync/rsync.mk
index 3fd2ef257e..b9d392c8cb 100644
--- a/package/rsync/rsync.mk
+++ b/package/rsync/rsync.mk
@@ -10,7 +10,9 @@  RSYNC_LICENSE = GPL-3.0+ with exceptions
 RSYNC_LICENSE_FILES = COPYING
 RSYNC_CPE_ID_VENDOR = samba
 RSYNC_SELINUX_MODULES = rsync
-RSYNC_DEPENDENCIES = zlib popt
+# We're patching configure.ac
+RSYNC_AUTORECONF = YES
+RSYNC_DEPENDENCIES = host-pkgconf zlib popt
 # We know that our C library is modern enough for C99 vsnprintf(). Since
 # configure can't detect this, we tell configure that vsnprintf() is safe.
 RSYNC_CONF_ENV = rsync_cv_HAVE_C99_VSNPRINTF=yes
@@ -20,9 +22,11 @@  RSYNC_CONF_OPTS = \
 	--disable-roll-simd \
 	--disable-md5-asm
 
-ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
-RSYNC_CONF_ENV += LIBS=-latomic
-endif
+# reconfigure must be run after autoreconf
+define RSYNC_RUN_RECONFIGURE
+	cd $(@D) && PATH=$(BR_PATH) make reconfigure
+endef
+RSYNC_POST_CONFIGURE_HOOKS += RSYNC_RUN_RECONFIGURE
 
 ifeq ($(BR2_PACKAGE_ACL),y)
 RSYNC_DEPENDENCIES += acl