All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] netsnmp: fix static build with openssl
@ 2018-09-09  8:51 Fabrice Fontaine
  2018-09-09 12:16 ` Thomas Petazzoni
  0 siblings, 1 reply; 11+ messages in thread
From: Fabrice Fontaine @ 2018-09-09  8:51 UTC (permalink / raw)
  To: buildroot

- Add a patch to add crypto and zlib when statically linking
- Add AUTORECONF=YES
- Remove "hack" of setting -lz in mk as it is now done in patch

Fixes:
 - http://autobuild.buildroot.org/results/1b30f9813a4605056963bfe4532374f725830fda

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 .../0001-fix-static-build-with-openssl.patch  | 67 +++++++++++++++++++
 package/netsnmp/netsnmp.mk                    |  6 +-
 2 files changed, 69 insertions(+), 4 deletions(-)
 create mode 100644 package/netsnmp/0001-fix-static-build-with-openssl.patch

diff --git a/package/netsnmp/0001-fix-static-build-with-openssl.patch b/package/netsnmp/0001-fix-static-build-with-openssl.patch
new file mode 100644
index 0000000000..e73175e6af
--- /dev/null
+++ b/package/netsnmp/0001-fix-static-build-with-openssl.patch
@@ -0,0 +1,67 @@
+From 2675e97b76d20780a685ff4fa645d672a5513954 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sun, 9 Sep 2018 10:00:13 +0200
+Subject: [PATCH] fix static build with openssl
+
+When checking for crypto functions such as EVP_sha224, it is needed to
+link with zlib otherwise static build fails:
+
+configure:24665: checking for EVP_sha224
+configure:24665: /home/naourr/work/instance-3/output/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -static -Ulinux -Dlinux=linux -I/home/naourr/work/instance-3/output/host/bin/../xtensa-buildroot-linux-uclibc/sysroot/usr/include/libnl3   -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -static conftest.c -lcrypto >&5
+/home/naourr/work/instance-3/output/host/xtensa-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
+c_zlib.c:(.text+0x30): undefined reference to `inflate'
+/home/naourr/work/instance-3/output/host/xtensa-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
+c_zlib.c:(.text+0x78): undefined reference to `deflate'
+
+Also when checking for ssl functions such as DTLSv1_method, it is needed
+to link also with crypto (and zlib) otherwise static build fails:
+
+configure:24717: checking for DTLSv1_method
+configure:24717: /home/naourr/work/instance-3/output/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -Os -static -Ulinux -Dlinux=linux -I/home/naourr/work/instance-3/output/host/bin/../xtensa-buildroot-linux-uclibc/sysroot/usr/include/libnl3   -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -static conftest.c -lssl >&5
+/home/naourr/work/instance-3/output/host/xtensa-buildroot-linux-uclibc/sysroot/usr/lib/libssl.a(d1_srvr.o):(.text+0x4): undefined reference to `RAND_add'
+/home/naourr/work/instance-3/output/host/xtensa-buildroot-linux-uclibc/sysroot/usr/lib/libssl.a(d1_srvr.o):(.text+0x8): undefined reference to `ERR_clear_error'
+/home/naourr/work/instance-3/output/host/xtensa-buildroot-linux-uclibc/sysroot/usr/lib/libssl.a(d1_srvr.o): In function `dtls1_accept':
+d1_srvr.c:(.text+0x23c): undefined reference to `ERR_put_error'
+
+Fixes:
+ - http://autobuild.buildroot.org/results/1b30f9813a4605056963bfe4532374f725830fda
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status:
+https://sourceforge.net/p/net-snmp/code/merge-requests/17]
+---
+ configure.d/config_os_libs2 | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/configure.d/config_os_libs2 b/configure.d/config_os_libs2
+index 74bed6bf7..84ebb77f5 100644
+--- a/configure.d/config_os_libs2
++++ b/configure.d/config_os_libs2
+@@ -309,13 +309,13 @@ if test "x$tryopenssl" != "xno" -a "x$tryopenssl" != "xinternal"; then
+         LIBS="$netsnmp_save_LIBS"
+ 
+         if test x$CRYPTO = x; then
+-            AC_CHECK_LIB([crypto], [EVP_md5], [CRYPTO="crypto"])
++            AC_CHECK_LIB([crypto], [EVP_md5], [CRYPTO="crypto"], [], -lz)
+         fi
+ 
+         if test x$CRYPTO != x; then
+             AC_DEFINE(HAVE_LIBCRYPTO, 1,
+                 [Define to 1 if you have the OpenSSL library (-lcrypto or -leay32).])
+-            LIBCRYPTO="-l${CRYPTO}"
++            LIBCRYPTO="-l${CRYPTO} -lz"
+             netsnmp_save_LIBS="$LIBS"
+             LIBS="$LIBCRYPTO"
+             AC_CHECK_FUNCS([AES_cfb128_encrypt]dnl
+@@ -345,7 +345,7 @@ if test "x$tryopenssl" != "xno" -a "x$tryopenssl" != "xinternal"; then
+             LIBS="$netsnmp_save_LIBS"
+         fi
+         netsnmp_save_LIBS="$LIBS"
+-        LIBS="-lssl"
++        LIBS="-lssl $LIBCRYPTO"
+         AC_CHECK_FUNCS([TLS_method TLSv1_method DTLS_method DTLSv1_method]dnl
+                        [SSL_library_init SSL_load_error_strings])
+         LIBS="$netsnmp_save_LIBS"
+-- 
+2.17.1
+
diff --git a/package/netsnmp/netsnmp.mk b/package/netsnmp/netsnmp.mk
index 6c712ae075..acf6ecdc27 100644
--- a/package/netsnmp/netsnmp.mk
+++ b/package/netsnmp/netsnmp.mk
@@ -36,6 +36,8 @@ NETSNMP_INSTALL_STAGING_OPTS = DESTDIR=$(STAGING_DIR) LIB_LDCONFIG_CMD=true inst
 NETSNMP_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) LIB_LDCONFIG_CMD=true install
 NETSNMP_MAKE = $(MAKE1)
 NETSNMP_CONFIG_SCRIPTS = net-snmp-config
+# We're patching configure.d/config_os_libs2
+NETSNMP_AUTORECONF = YES
 
 ifeq ($(BR2_ENDIAN),"BIG")
 NETSNMP_CONF_OPTS += --with-endianness=big
@@ -57,10 +59,6 @@ NETSNMP_CONF_OPTS += \
 	--with-openssl=$(STAGING_DIR)/usr/include/openssl \
 	--with-security-modules="tsm,usm" \
 	--with-transports="DTLSUDP,TLSTCP"
-ifeq ($(BR2_STATIC_LIBS),y)
-# openssl uses zlib, so we need to explicitly link with it when static
-NETSNMP_CONF_ENV += LIBS=-lz
-endif
 else ifeq ($(BR2_PACKAGE_NETSNMP_OPENSSL_INTERNAL),y)
 NETSNMP_CONF_OPTS += --with-openssl=internal
 else
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-10-11 20:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09  8:51 [Buildroot] [PATCH 1/1] netsnmp: fix static build with openssl Fabrice Fontaine
2018-09-09 12:16 ` Thomas Petazzoni
2018-09-09 12:43   ` Fabrice Fontaine
2018-09-09 13:09     ` Thomas Petazzoni
2018-09-17 20:37       ` Giulio Benetti
2018-09-17 20:39         ` [Buildroot] [PATCH] netsnmp: fix static build failure due to missing -lssl and -lz Giulio Benetti
2018-10-11 20:46           ` Peter Korsgaard
2018-10-11 20:52             ` Giulio Benetti
2018-09-17 20:43         ` [Buildroot] [PATCH 1/1] netsnmp: fix static build with openssl Fabrice Fontaine
2018-09-17 21:22         ` Thomas Petazzoni
2018-09-17 21:44           ` Giulio Benetti

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.