Skip to contentSkip to conversation

package/socat: fix static openssl compatibility

PATCH In review Byron Gallagher 3 participants 8 messages Nov 21, 2023 – Nov 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/socat: fix static openssl compatibility

4028ee71743a25af172809e098e4c8eb61bf55f4 disables static openssl compatibility due to issues linking against zlib.

This patch re-enables the functionality by patching socat's autoconf to include zlib when locating openssl. Bug also reported upstream via [email protected].

---
 ...-build-link-against-zlib-for-openssl.patch | 35 +++++++++++++++++++
 package/socat/socat.mk                        |  2 +-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 package/socat/0003-build-link-against-zlib-for-openssl.patch
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +35 -0
new file mode 100644
index 0000000000..3851d5bcab
@@ -0,0 +1,35 @@
+From 0434a4674a012a35f6390d9afc4812de59a394ab Mon Sep 17 00:00:00 2001
+From: Byron Gallagher <[email protected]>
+Date: Tue, 21 Nov 2023 12:25:18 -0500
+Subject: [PATCH] build: link against zlib for openssl
+
+If openssl is static, socat will not find it due to autoconf
+failures on AC_TRY_LINK without -lz.
+
+Signed-off-by: Byron Gallagher <[email protected]>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9d60473..ae0e6bd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -580,12 +580,12 @@ if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
+       if test -n "$OPENSSL_BASE"; then
+ 	L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
+       else
+-	LIBS="$LIBS -lssl -lcrypto"
++	LIBS="$LIBS -lssl -lcrypto -lz"
+       fi
+       AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init();ERR_error_string()],
+        [sc_cv_have_libssl='yes'],
+-       [ LIBS="$LIBS -lcrypto"
++       [ LIBS="$LIBS -lcrypto -lz"
+        AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init()],
+ 	  [sc_cv_have_libssl='yes'],
+-- 
+2.34.1
+
package/socat/socat.mk +1 -1
index f958f26522..0741605687 100644
@@ -39,7 +39,7 @@ SOCAT_DEPENDENCIES = host-autoconf
 # incompatibile license (GPL-3.0+)
 SOCAT_CONF_OPTS = --disable-readline
 
-ifeq ($(BR2_PACKAGE_LIBOPENSSL):$(BR2_STATIC_LIBS),y:)
+ifeq ($(BR2_PACKAGE_LIBOPENSSL),y)
 SOCAT_DEPENDENCIES += openssl
 else
 SOCAT_CONF_OPTS += --disable-openssl
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Byron,

Quoted 21 lines · Byron Gallagher

4028ee71743a25af172809e098e4c8eb61bf55f4 disables static openssl compatibility due to issues linking against zlib.

This patch re-enables the functionality by patching socat's autoconf to include zlib when locating openssl. Bug also reported upstream via [email protected].

---
 ...-build-link-against-zlib-for-openssl.patch | 35 +++++++++++++++++++
 package/socat/socat.mk                        |  2 +-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 package/socat/0003-build-link-against-zlib-for-openssl.patch
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +0 -0
new file mode 100644
index 0000000000..3851d5bcab

package/socat/0003-build-link-against-zlib-for-openssl.patch line 8

Quoted 8 lines
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +8 -0
@@ -0,0 +1,35 @@
+From 0434a4674a012a35f6390d9afc4812de59a394ab Mon Sep 17 00:00:00 2001
+From: Byron Gallagher <[email protected]>
+Date: Tue, 21 Nov 2023 12:25:18 -0500
+Subject: [PATCH] build: link against zlib for openssl
+
+If openssl is static, socat will not find it due to autoconf
+failures on AC_TRY_LINK without -lz.
+

Patches should have Upstream: tag. See

https://buildroot.org/downloads/manual/manual.html#_additional_patch_documentation

In this case adding something like

Upstream: sent to [email protected]

should be enough.

baruch

Quoted 40 lines
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +27 -0
+Signed-off-by: Byron Gallagher <[email protected]>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9d60473..ae0e6bd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -580,12 +580,12 @@ if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
+       if test -n "$OPENSSL_BASE"; then
+ 	L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
+       else
+-	LIBS="$LIBS -lssl -lcrypto"
++	LIBS="$LIBS -lssl -lcrypto -lz"
+       fi
+       AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init();ERR_error_string()],
+        [sc_cv_have_libssl='yes'],
+-       [ LIBS="$LIBS -lcrypto"
++       [ LIBS="$LIBS -lcrypto -lz"
+        AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init()],
+ 	  [sc_cv_have_libssl='yes'],
+-- 
+2.34.1
+
package/socat/socat.mk +1 -1
index f958f26522..0741605687 100644
@@ -39,7 +39,7 @@ SOCAT_DEPENDENCIES = host-autoconf
 # incompatibile license (GPL-3.0+)
 SOCAT_CONF_OPTS = --disable-readline
 
-ifeq ($(BR2_PACKAGE_LIBOPENSSL):$(BR2_STATIC_LIBS),y:)
+ifeq ($(BR2_PACKAGE_LIBOPENSSL),y)
 SOCAT_DEPENDENCIES += openssl
 else
 SOCAT_CONF_OPTS += --disable-openssl
Signature · 7 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 1/1 package/socat: fix static openssl compatibility

4028ee71743a25af172809e098e4c8eb61bf55f4 disables static openssl compatibility due to issues linking against zlib.

This patch re-enables the functionality by patching socat's autoconf to include zlib when locating openssl. Bug also reported upstream via [email protected].

---
 ...-build-link-against-zlib-for-openssl.patch | 36 +++++++++++++++++++
 package/socat/socat.mk                        |  2 +-
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 package/socat/0003-build-link-against-zlib-for-openssl.patch
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +36 -0
new file mode 100644
index 0000000000..257f5225b1
@@ -0,0 +1,36 @@
+From 0434a4674a012a35f6390d9afc4812de59a394ab Mon Sep 17 00:00:00 2001
+From: Byron Gallagher <[email protected]>
+Date: Tue, 21 Nov 2023 12:25:18 -0500
+Subject: [PATCH] build: link against zlib for openssl
+
+If openssl is static, socat will not find it due to autoconf
+failures on AC_TRY_LINK without -lz.
+
+Upstream: sent to socat at dest-unreach.org
+Signed-off-by: Byron Gallagher <[email protected]>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9d60473..ae0e6bd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -580,12 +580,12 @@ if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
+       if test -n "$OPENSSL_BASE"; then
+ 	L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
+       else
+-	LIBS="$LIBS -lssl -lcrypto"
++	LIBS="$LIBS -lssl -lcrypto -lz"
+       fi
+       AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init();ERR_error_string()],
+        [sc_cv_have_libssl='yes'],
+-       [ LIBS="$LIBS -lcrypto"
++       [ LIBS="$LIBS -lcrypto -lz"
+        AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init()],
+ 	  [sc_cv_have_libssl='yes'],
+-- 
+2.34.1
+
package/socat/socat.mk +1 -1
index f958f26522..0741605687 100644
@@ -39,7 +39,7 @@ SOCAT_DEPENDENCIES = host-autoconf
 # incompatibile license (GPL-3.0+)
 SOCAT_CONF_OPTS = --disable-readline
 
-ifeq ($(BR2_PACKAGE_LIBOPENSSL):$(BR2_STATIC_LIBS),y:)
+ifeq ($(BR2_PACKAGE_LIBOPENSSL),y)
 SOCAT_DEPENDENCIES += openssl
 else
 SOCAT_CONF_OPTS += --disable-openssl
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Byron, All,

On 2023-11-21 13:25 -0500, Byron Gallagher spake thusly:

Quoted 6 lines

4028ee71743a25af172809e098e4c8eb61bf55f4 disables static openssl compatibility due to issues linking against zlib.

This patch re-enables the functionality by patching socat's autoconf to include zlib when locating openssl. Bug also reported upstream via [email protected].

Since you sent this new iteration, Thomas replied to your initial patch, usggesting using pkg-config to find the necessary SSL libs.

So, I've marked both your patches as changes requested in patchwork.

Thanks!

Regards,
Yann E. MORIN.

Quoted 69 lines
---
 ...-build-link-against-zlib-for-openssl.patch | 36 +++++++++++++++++++
 package/socat/socat.mk                        |  2 +-
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 package/socat/0003-build-link-against-zlib-for-openssl.patch
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +36 -0
new file mode 100644
index 0000000000..257f5225b1
@@ -0,0 +1,36 @@
+From 0434a4674a012a35f6390d9afc4812de59a394ab Mon Sep 17 00:00:00 2001
+From: Byron Gallagher <[email protected]>
+Date: Tue, 21 Nov 2023 12:25:18 -0500
+Subject: [PATCH] build: link against zlib for openssl
+
+If openssl is static, socat will not find it due to autoconf
+failures on AC_TRY_LINK without -lz.
+
+Upstream: sent to socat at dest-unreach.org
+Signed-off-by: Byron Gallagher <[email protected]>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9d60473..ae0e6bd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -580,12 +580,12 @@ if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
+       if test -n "$OPENSSL_BASE"; then
+ 	L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
+       else
+-	LIBS="$LIBS -lssl -lcrypto"
++	LIBS="$LIBS -lssl -lcrypto -lz"
+       fi
+       AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init();ERR_error_string()],
+        [sc_cv_have_libssl='yes'],
+-       [ LIBS="$LIBS -lcrypto"
++       [ LIBS="$LIBS -lcrypto -lz"
+        AC_TRY_LINK([#include <openssl/ssl.h>],
+        [SSL_library_init()],
+ 	  [sc_cv_have_libssl='yes'],
+-- 
+2.34.1
+
package/socat/socat.mk +1 -1
index f958f26522..0741605687 100644
@@ -39,7 +39,7 @@ SOCAT_DEPENDENCIES = host-autoconf
 # incompatibile license (GPL-3.0+)
 SOCAT_CONF_OPTS = --disable-readline
 
-ifeq ($(BR2_PACKAGE_LIBOPENSSL):$(BR2_STATIC_LIBS),y:)
+ifeq ($(BR2_PACKAGE_LIBOPENSSL),y)
 SOCAT_DEPENDENCIES += openssl
 else
 SOCAT_CONF_OPTS += --disable-openssl
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 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.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Byron Gallagher

Hello Byron,

package/socat/0003-build-link-against-zlib-for-openssl.patch line 23

Quoted 10 lines · On Tue, 21 Nov 2023 12:47:22 -0500 Byron Gallagher…
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +10 -0
+diff --git a/configure.ac b/configure.ac
+index 9d60473..ae0e6bd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -580,12 +580,12 @@ if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
+       if test -n "$OPENSSL_BASE"; then
+ 	L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
+       else
+-	LIBS="$LIBS -lssl -lcrypto"
++	LIBS="$LIBS -lssl -lcrypto -lz"

The downside of this is that socat is then directly linked to libz even when it's not needed (dynamic linking situation).

The correct/ideal way of handling this is to use pkg-config, as it properly says whether we need -lssl -lcrypto (dynamic linking case) or -lssl -lcrypto -lz (static linking case), without hardcoding this in socat itself.

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
#5 lore raw

Hi Thomas,

That makes sense. In this case would it be sufficient to add another layer of AC_TRY_LINK to check the static case? i.e. we try with -lssl -lcrypto first and if fail, try again with -lssl -lcrypto -lz?

Best Regards,
Byron

Quoted 25 lines · Thomas Petazzoni

Hello Byron,

package/socat/0003-build-link-against-zlib-for-openssl.patch

Quoted 5 lines · On Tue, 21 Nov 2023 12:47:22 -0500 Byron Gallagher…
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +5 -0
+diff --git a/configure.ac b/configure.ac
+index 9d60473..ae0e6bd 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -580,12 +580,12 @@ if test -n "$WITH_OPENSSL" -a

"$sc_cv_have_openssl_ssl_h" = 'yes'; then

package/socat/0003-build-link-against-zlib-for-openssl.patch line 23

Quoted 5 lines
package/socat/0003-build-link-against-zlib-for-openssl.patch new file +5 -0
+       if test -n "$OPENSSL_BASE"; then
+     L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
+       else
+-    LIBS="$LIBS -lssl -lcrypto"
++    LIBS="$LIBS -lssl -lcrypto -lz"

The downside of this is that socat is then directly linked to libz even when it's not needed (dynamic linking situation).

The correct/ideal way of handling this is to use pkg-config, as it properly says whether we need -lssl -lcrypto (dynamic linking case) or -lssl -lcrypto -lz (static linking case), without hardcoding this in socat itself.

Quoted 8 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

#6 lore raw

Hello Byron,

Quoted 3 lines · On Thu, 23 Nov 2023 12:55:33 -0500 Byron Gallagher…

That makes sense. In this case would it be sufficient to add another layer of AC_TRY_LINK to check the static case? i.e. we try with -lssl -lcrypto first and if fail, try again with -lssl -lcrypto -lz?

That's an option indeed. But the best solution is really to use pkg-config, through PKG_CHECK_MODULES(), and only if not found via pkg-config fall back on the existing crap that uses AC_TRY_LINK().

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
#7 lore raw

Hi Thomas,

I believe I've implemented the changes in my local version but would like your thoughts.
1. Socat package now has to be autoreconf rather than simple autotools with a pre-config hook that runs autoconf independently.
2. The upstream socat configure.ac uses the old AC_DEFINE(FOO) format which causes autoheader to fail. I've changed every invocation to the correct AC_DEFINE(FOO, [VAL], [Description])
3. The changes to the relevant block for finding libssl are as follows:

580,593c580,603

<       if test -n "$OPENSSL_BASE"; then
<       L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
<       else
<       LIBS="$LIBS -lssl -lcrypto"
<       fi
<       AC_TRY_LINK([#include <openssl/ssl.h>],
<        [SSL_library_init();ERR_error_string()],
<        [sc_cv_have_libssl='yes'],
<        [ LIBS="$LIBS -lcrypto"
<        AC_TRY_LINK([#include <openssl/ssl.h>],
<        [SSL_library_init()],
<         [sc_cv_have_libssl='yes'],
<         [sc_cv_have_libssl='no'])
<         ])

---

Quoted 23 lines
    PKG_CHECK_MODULES(LIBSSL, libssl,
    [
      LIBS="$LIBS $LIBSSL_LIBS"
      CFLAGS="$CFLAGS $LIBSSL_CFLAGS"
      sc_cv_have_libssl='yes'
    ],
    [
        if test -n "$OPENSSL_BASE"; then
    L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
        else
    LIBS="$LIBS -lssl -lcrypto"
        fi
        AC_TRY_LINK([#include <openssl/ssl.h>],
        [SSL_library_init();ERR_error_string()],
        [sc_cv_have_libssl='yes'],
        [ LIBS="$LIBS -lcrypto"
        AC_TRY_LINK([#include <openssl/ssl.h>],
        [SSL_library_init()],
      [sc_cv_have_libssl='yes'],
      [sc_cv_have_libssl='no'])
          ])
        AC_MSG_RESULT($sc_cv_have_libssl)
    ])
Quoted 14 lines · Thomas Petazzoni

Hello Byron,

Quoted 3 lines · On Thu, 23 Nov 2023 12:55:33 -0500 Byron Gallagher…

That makes sense. In this case would it be sufficient to add another layer of AC_TRY_LINK to check the static case? i.e. we try with -lssl -lcrypto first and if fail, try again with -lssl -lcrypto -lz?

That's an option indeed. But the best solution is really to use pkg-config, through PKG_CHECK_MODULES(), and only if not found via pkg-config fall back on the existing crap that uses AC_TRY_LINK().

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