This is an automated email from the ASF dual-hosted git repository.

damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 8eb9a7e66a3128669216ddb884f844d50ac59fb9
Author: Damjan Jovanovic <dam...@apache.org>
AuthorDate: Sun Apr 7 10:41:42 2024 +0200

    Build OpenSSL as a dynamic link library, instead of a static library.
    Patch its users to use an RPATH of $ORIGIN, so they use the correct copy.
    This reduces the size of the build by about 4615 KiB, or 3.78%.
    
    Patch by: me
---
 main/RepositoryExternal.mk                | 18 ++----------------
 main/curl/makefile.mk                     |  2 ++
 main/openssl/opensslunx.patch             | 17 ++++++++++++-----
 main/openssl/prj/d.lst                    |  7 +++++--
 main/scp2/source/ooo/file_library_ooo.scp |  4 ++--
 5 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/main/RepositoryExternal.mk b/main/RepositoryExternal.mk
index 25e30fb7f1..5a8503056e 100644
--- a/main/RepositoryExternal.mk
+++ b/main/RepositoryExternal.mk
@@ -361,29 +361,16 @@ endef
 
 else # !SYSTEM_OPENSSL
 
-ifeq ($(OS),WNT)
 $(eval $(call gb_Helper_register_libraries,PLAINLIBS_OOO, \
        crypto \
        ssl \
 ))
-else
-$(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
-       crypto \
-       ssl \
-))
-endif
 
 define gb_LinkTarget__use_openssl
-ifeq ($(OS),WNT)
 $(call gb_LinkTarget_add_linked_libs,$(1),\
        crypto \
        ssl \
 )
-else
-$(call gb_LinkTarget_add_linked_static_libs,$(1),\
-       crypto \
-       ssl \
-)
 ifeq ($(OS),SOLARIS)
 $(call gb_LinkTarget_add_libs,$(1),\
        -lnsl \
@@ -391,11 +378,10 @@ $(call gb_LinkTarget_add_libs,$(1),\
 )
 endif
 ifeq ($(OS),LINUX)
-$(call gb_LinkTarget_add_linked_libs,$(1),\
-       pthread \
+$(call gb_LinkTarget_add_libs,$(1),\
+       -lpthread \
 )
 endif
-endif
 endef
 
 endif # SYSTEM_OPENSSL
diff --git a/main/curl/makefile.mk b/main/curl/makefile.mk
index 044bf4d8c9..b801cb75bf 100644
--- a/main/curl/makefile.mk
+++ b/main/curl/makefile.mk
@@ -59,6 +59,8 @@ curl_LDFLAGS+:=$(ARCH_FLAGS)
 ssl_param=--with-ssl
 .ELSE
 ssl_param=--with-ssl=$(OUTDIR)
+curl_CFLAGS+=-I$(SOLARINCDIR)$/external
+curl_LDFLAGS+=-L$(SOLARLIBDIR) -Wl,-z,origin -Wl,-rpath,\\\$$\$$ORIGIN
 PATCH_FILES+= curl-bundled_openssl.patch
 .ENDIF
 
diff --git a/main/openssl/opensslunx.patch b/main/openssl/opensslunx.patch
index 7177a1c740..5ceac19471 100644
--- a/main/openssl/opensslunx.patch
+++ b/main/openssl/opensslunx.patch
@@ -1,10 +1,17 @@
---- misc/build/openssl-3.0.13/Configurations/00-base-templates.conf    
2024-01-30 15:28:16.000000000 +0200
-+++ misc/build/openssl-3.0.13/Configurations/00-base-templates.conf    
2024-03-18 02:55:09.593025000 +0200
-@@ -67,6 +67,7 @@
+--- misc/build/openssl-3.0.13/Configurations/00-base-templates.conf    
2024-04-14 20:51:59.953276000 +0200
++++ misc/build/openssl-3.0.13/Configurations/00-base-templates.conf    
2024-04-15 04:41:41.558374000 +0200
+@@ -67,9 +67,13 @@
  
          AR              => "ar",
          ARFLAGS         => "qc",
-+        ASFLAGS          => "-Wa,--noexecstack",
++        ASFLAGS         => "-Wa,--noexecstack",
          CC              => "cc",
          lflags          =>
-             sub { $withargs{zlib_lib} ? "-L".$withargs{zlib_lib} : () },
+-            sub { $withargs{zlib_lib} ? "-L".$withargs{zlib_lib} : () },
++            sub {
++                my $s = '-Wl,-z,origin -Wl,-rpath,\$$ORIGIN';
++                return $withargs{zlib_lib} ? $s." -L".$withargs{zlib_lib} : 
$s;
++            },
+         ex_libs         =>
+             sub { !defined($disabled{zlib})
+                   && defined($disabled{"zlib-dynamic"})
diff --git a/main/openssl/prj/d.lst b/main/openssl/prj/d.lst
index f381599703..cac50416cf 100644
--- a/main/openssl/prj/d.lst
+++ b/main/openssl/prj/d.lst
@@ -1,6 +1,9 @@
 mkdir: %_DEST%\inc%_EXT%\external
 mkdir: %_DEST%\inc%_EXT%\external\openssl
 ..\%__SRC%\inc\*.h %_DEST%\inc%_EXT%\external\openssl
-..\%__SRC%\lib\libcrypto.* %_DEST%\lib%_EXT%\libcrypto.*
-..\%__SRC%\lib\libssl.* %_DEST%\lib%_EXT%\libssl.*
+..\%__SRC%\lib\libcrypto.*.* %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\libssl.*.* %_DEST%\lib%_EXT%\*
 ..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+
+linklib: libcrypto.*.*
+linklib: libssl.*.*
diff --git a/main/scp2/source/ooo/file_library_ooo.scp 
b/main/scp2/source/ooo/file_library_ooo.scp
index fb82de45e6..ca9dadba1e 100644
--- a/main/scp2/source/ooo/file_library_ooo.scp
+++ b/main/scp2/source/ooo/file_library_ooo.scp
@@ -1777,7 +1777,7 @@ File gid_File_Lib_Openssl
   #ifdef WNT
     Name = "libssl-3.dll";
   #else
-    Name = "libssl.so";
+    Name = SCP2_URE_DL_VER("ssl", "3");
   #endif
 End
 #endif
@@ -1790,7 +1790,7 @@ File gid_File_Lib_Crypto
   #ifdef WNT
     Name = "libcrypto-3.dll";
   #else
-    Name = "libcrypto.so";
+    Name = SCP2_URE_DL_VER("crypto", "3");
   #endif
 End
 #endif

Reply via email to