Re: Libpq linked statically linked to OpenSSL/LibreSSL

From: Andres Freund <andres(at)anarazel(dot)de>
To: Marco Bambini <marco(at)creolabs(dot)com>
Cc: ALBERTO CABELLO SÁNCHEZ <alberto(at)unex(dot)es>, "pgsql-interfaces(at)lists(dot)postgresql(dot)org" <pgsql-interfaces(at)lists(dot)postgresql(dot)org>
Subject: Re: Libpq linked statically linked to OpenSSL/LibreSSL
Date: 2022-12-06 18:01:00
Message-ID: 20221206180100.yoluppdnsaivckwi@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi,

On 2022-12-06 11:05:49 +0100, Marco Bambini wrote:
> I made some progresses, especially in understanding where the issue can be.
>
> I started with a fresh postgresql-15.1 source code installation:
> # ./configure --with-openssl --without-readline
>
> I then modified the Makefile.global in the src directory by replacing the occurrences of -lssl and -lcrypto with:
> /root/rothsoft/libressl-3.6.1/ssl/.libs/libssl.a /root/rothsoft/libressl-3.6.1/crypto/.libs/libcrypto.a
> in the LIBS entry.

I think this is completely the wrong path. You should add libressl's include
and library directories to --with-includes=, --with-libraries=.

> Please notice all the U entries in the crypto/ssl functions, so it looks like that they are NOT statically linked inside the libpq.so shared library, even if I replaced the LIBS in the Makefile.

If there's also a shared version of libressl, you possibly would need to
specify that you'd want to link statically. Something like
-Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic

But I suspect that you're better of linking dynamically, specifying
--with-includes= --with-libraries= should provide a path towards that. It's
possible that you should add -Wl,-rpath,/path/to/libressl/lib to the LDFLAGS,
so that the dynamic version can be found at runtime.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruce Momjian 2022-12-06 18:24:22 Re: Libpq linked statically linked to OpenSSL/LibreSSL
Previous Message Marco Bambini 2022-12-06 10:05:49 Re: Libpq linked statically linked to OpenSSL/LibreSSL