On Wed, Dec 4, 2024 at 3:48 PM Daniel Gustafsson <dan...@yesql.se> wrote:

> > On 2 Dec 2024, at 22:12, Darek Ślusarczyk <dslusarc...@splunk.com>
> wrote:
> [...]
> > -    ssl_lib = cc.find_library('ssl',
> > +    ssl_lib = cc.find_library(['ssl', 'ssleay32'],
>
> I'm not a meson expert by any means but I was suprised to see this,
> libname is
> defined as str and not list[str] in the meson documentaion so I didn't
> expect
> that to work.  Is the list prioritized in order in case both libs exist on
> the
> system?  On a non-Windows system I wouldn't want libssleay32 to be picked
> up
> over libssl if it happened to exist etc.
>


Good catch - indeed, you are right. Due to some other changes, the flow in
our internal builds went through
https://github.com/postgres/postgres/blob/master/meson.build#L1358
instead of
https://github.com/postgres/postgres/blob/master/meson.build#L1346
and I thought I fixed the issue by making the build green. But it wasn't
the case :-P

I've prepared another patch:
- it prioritizes libssl and libcrypto over ssleay32 and libeay32
- it checks ssleay32 and libeay32 on windows only
- I tested it locally on both lnx/win enforcing various possible scenarios

diff --git a/meson.build b/meson.build
index e5ce437a5c7..70b003a5f23 100644
--- a/meson.build
+++ b/meson.build
@@ -1343,14 +1343,35 @@ if sslopt in ['auto', 'openssl']

   # via library + headers
   if not ssl.found()
+    is_windows = build_system == 'windows'
+
+    ssl_lib_common_params = {
+      'dirs': test_lib_d,
+      'header_include_directories': postgres_inc,
+      'has_headers': ['openssl/ssl.h', 'openssl/err.h'],
+    }
     ssl_lib = cc.find_library('ssl',
-      dirs: test_lib_d,
-      header_include_directories: postgres_inc,
-      has_headers: ['openssl/ssl.h', 'openssl/err.h'],
-      required: openssl_required)
+      kwargs: ssl_lib_common_params,
+      required: openssl_required and not is_windows
+    )
+    # if 'ssl' is not found and it's windows, try 'ssleay32'
+    if not ssl_lib.found() and is_windows
+      ssl_lib = cc.find_library('ssleay32',
+        kwargs: ssl_lib_common_params,
+        required: openssl_required
+      )
+    endif
+
     crypto_lib = cc.find_library('crypto',
       dirs: test_lib_d,
-      required: openssl_required)
+      required: openssl_required and not is_windows)
+    # if 'crypto' is not found and it's windows, try 'libeay32'
+    if not crypto_lib.found() and is_windows
+      crypto_lib = cc.find_library('libeay32',
+        dirs: test_lib_d,
+        required: openssl_required)
+    endif
+
     if ssl_lib.found() and crypto_lib.found()
       ssl_int = [ssl_lib, crypto_lib]
       ssl = declare_dependency(dependencies: ssl_int, include_directories:
postgres_inc)


for easier reading, it is also available as a pull-request (closed
automatically as expected)
https://github.com/postgres/postgres/pull/191

--
marines() {
    return Darek_Slusarczyk;
}

Reply via email to