libressl / portable

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code. Pull requests or patches sent to tech@openbsd.org are welcome.
https://www.libressl.org
1.35k stars 269 forks source link

Building dynamic nc and openssl on libressl-3.8.1 #906

Open arachsys opened 1 year ago

arachsys commented 1 year ago

As noted in the changelog:

Wanting to build dynamically linked nc and openssl tools, I followed the implied advice in the above and configured with --disable-static --enable-nc. However, this doesn't work. It still results in statically linked tools.

Am I not properly disabling the building of static libraries with --disable-static, or is there some other trick I can use to override this new behaviour? I'm happy to build libressl twice if necessary to get both shared and static libraries, but still have the dynamically-linked nc and openssl.

arachsys commented 8 months ago

Answering my own question for the benefit of anyone else who might want to do this:

diff --git a/apps/nc/Makefile.am b/apps/nc/Makefile.am
index aba306e..28ef3ec 100644
--- a/apps/nc/Makefile.am
+++ b/apps/nc/Makefile.am
@@ -16,12 +16,10 @@ endif
 EXTRA_DIST = nc.1
 EXTRA_DIST += CMakeLists.txt

-nc_LDADD = $(libcrypto_la_objects)
+nc_LDADD = $(abs_top_builddir)/tls/libtls.la
 nc_LDADD += $(libcompat_la_objects)
 nc_LDADD += $(libcompatnoopt_la_objects)
-nc_LDADD += $(libssl_la_objects)
-nc_LDADD += $(libtls_la_objects)

 nc_LDADD += $(PLATFORM_LDADD) $(PROG_LDADD)

 AM_CPPFLAGS += -I$(top_srcdir)/apps/nc/compat
diff --git a/apps/ocspcheck/Makefile.am b/apps/ocspcheck/Makefile.am
index e6f3c54..2d1aa5d 100644
--- a/apps/ocspcheck/Makefile.am
+++ b/apps/ocspcheck/Makefile.am
@@ -14,11 +14,10 @@ endif
 EXTRA_DIST = ocspcheck.8
 EXTRA_DIST += CMakeLists.txt

-ocspcheck_LDADD = $(libcrypto_la_objects)
+ocspcheck_LDADD = $(abs_top_builddir)/ssl/libssl.la
+ocspcheck_LDADD += $(abs_top_builddir)/tls/libtls.la
 ocspcheck_LDADD += $(libcompat_la_objects)
 ocspcheck_LDADD += $(libcompatnoopt_la_objects)
-ocspcheck_LDADD += $(libssl_la_objects)
-ocspcheck_LDADD += $(libtls_la_objects)
 ocspcheck_LDADD += $(PLATFORM_LDADD) $(PROG_LDADD)

 ocspcheck_SOURCES = http.c
diff --git a/apps/openssl/Makefile.am b/apps/openssl/Makefile.am
index 2567ef0..95ed845 100644
--- a/apps/openssl/Makefile.am
+++ b/apps/openssl/Makefile.am
@@ -10,10 +10,9 @@ else
 noinst_PROGRAMS = openssl
 endif

-openssl_LDADD = $(libcrypto_la_objects)
+openssl_LDADD = $(abs_top_builddir)/ssl/libssl.la
 openssl_LDADD += $(libcompat_la_objects)
 openssl_LDADD += $(libcompatnoopt_la_objects)
-openssl_LDADD += $(libssl_la_objects)
 openssl_LDADD += $(PLATFORM_LDADD) $(PROG_LDADD)

 openssl_SOURCES = apps.c
orbea commented 8 months ago

@arachsys Is there a reason to not make a PR?

arachsys commented 8 months ago

@arachsys Is there a reason to not make a PR?

Yes: this reverses an intentional change by the maintainer in https://github.com/libressl/portable/commit/a316f8ab8cf79895062c1d1fcc5d47c3d2cc6f6a. I'm assuming there's a good reason for the standard build to generate statically linked tools although the commit message doesn't hint at it.

Potentially plumbing through something like configure --enable-dynamic-tools to conditionalise this behaviour might fly with them, though, if you wanted something more packaged than a build-time patch.

orbea commented 8 months ago

It would be nice to maintain as few patches as possible, but maybe @busterb can kindly explain the reasoning behind the commit? Maybe there is something I don't realize?

ikspress commented 1 month ago

Is there any progress on this issue? I've noticed that force static liking apps in Makefile.am leads inconsistent behavior with CMakeLists.txt which is shared linked apps. If anyone who wants statically linked apps, just specify --disable-shared when configure. It's quite unusual to build dynamic libraries but statically linked apps. Here is a patch I've used to revert the changes. It based on your patch.

diff --git libressl-3.9.2-orig/apps/nc/Makefile.am libressl-3.9.2/apps/nc/Makefile.am
index aba306e..bd0c438 100644
--- libressl-3.9.2-orig/apps/nc/Makefile.am
+++ libressl-3.9.2/apps/nc/Makefile.am
@@ -1,8 +1,6 @@
 include $(top_srcdir)/Makefile.am.common

 -include $(abs_top_builddir)/crypto/libcrypto_la_objects.mk
--include $(abs_top_builddir)/ssl/libssl_la_objects.mk
--include $(abs_top_builddir)/tls/libtls_la_objects.mk

 if BUILD_NC

@@ -16,11 +14,9 @@ endif
 EXTRA_DIST = nc.1
 EXTRA_DIST += CMakeLists.txt

-nc_LDADD = $(libcrypto_la_objects)
+nc_LDADD = $(abs_top_builddir)/tls/libtls.la
 nc_LDADD += $(libcompat_la_objects)
 nc_LDADD += $(libcompatnoopt_la_objects)
-nc_LDADD += $(libssl_la_objects)
-nc_LDADD += $(libtls_la_objects)

 nc_LDADD += $(PLATFORM_LDADD) $(PROG_LDADD)

diff --git libressl-3.9.2-orig/apps/ocspcheck/Makefile.am libressl-3.9.2/apps/ocspcheck/Makefile.am
index e6f3c54..b8131e0 100644
--- libressl-3.9.2-orig/apps/ocspcheck/Makefile.am
+++ libressl-3.9.2/apps/ocspcheck/Makefile.am
@@ -1,8 +1,6 @@
 include $(top_srcdir)/Makefile.am.common

 -include $(abs_top_builddir)/crypto/libcrypto_la_objects.mk
--include $(abs_top_builddir)/ssl/libssl_la_objects.mk
--include $(abs_top_builddir)/tls/libtls_la_objects.mk

 if !ENABLE_LIBTLS_ONLY
 bin_PROGRAMS = ocspcheck
@@ -14,11 +12,10 @@ endif
 EXTRA_DIST = ocspcheck.8
 EXTRA_DIST += CMakeLists.txt

-ocspcheck_LDADD = $(libcrypto_la_objects)
+ocspcheck_LDADD = $(abs_top_builddir)/ssl/libssl.la
+ocspcheck_LDADD += $(abs_top_builddir)/tls/libtls.la
 ocspcheck_LDADD += $(libcompat_la_objects)
 ocspcheck_LDADD += $(libcompatnoopt_la_objects)
-ocspcheck_LDADD += $(libssl_la_objects)
-ocspcheck_LDADD += $(libtls_la_objects)
 ocspcheck_LDADD += $(PLATFORM_LDADD) $(PROG_LDADD)

 ocspcheck_SOURCES = http.c
diff --git libressl-3.9.2-orig/apps/openssl/Makefile.am libressl-3.9.2/apps/openssl/Makefile.am
index 2567ef0..b26c83c 100644
--- libressl-3.9.2-orig/apps/openssl/Makefile.am
+++ libressl-3.9.2/apps/openssl/Makefile.am
@@ -1,7 +1,6 @@
 include $(top_srcdir)/Makefile.am.common

 -include $(abs_top_builddir)/crypto/libcrypto_la_objects.mk
--include $(abs_top_builddir)/ssl/libssl_la_objects.mk

 if !ENABLE_LIBTLS_ONLY
 bin_PROGRAMS = openssl
@@ -10,10 +9,9 @@ else
 noinst_PROGRAMS = openssl
 endif

-openssl_LDADD = $(libcrypto_la_objects)
+openssl_LDADD = $(abs_top_builddir)/ssl/libssl.la
 openssl_LDADD += $(libcompat_la_objects)
 openssl_LDADD += $(libcompatnoopt_la_objects)
-openssl_LDADD += $(libssl_la_objects)
 openssl_LDADD += $(PLATFORM_LDADD) $(PROG_LDADD)

 openssl_SOURCES = apps.c