Re: Build issue with postgresql 17 undefined reference to `pg_encoding_to_char' and `pg_char_to_encoding'

From: Mikael Sand <msand(at)seaber(dot)io>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Build issue with postgresql 17 undefined reference to `pg_encoding_to_char' and `pg_char_to_encoding'
Date: 2024-10-10 15:56:54
Message-ID: CAAwAxZf456NwLKD4ZBpyDmPc5GFmGP=b5Vw7pTMY0v9R-=+DTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

E.g. this works with 16.4 but fails in 17.0:

FROM postgres:16.4-alpine3.20 AS builder
USER root
WORKDIR /app
RUN apk update && apk add --no-cache --update-cache \
openssl-libs-static \
cyrus-sasl-static \
libevent-static \
libxml2-static \
libedit-static \
libxslt-static \
sqlite-static \
openldap-dev \
libxslt-dev \
libxml2-dev \
zstd-static \
zlib-static \
libedit-dev \
openssl-dev \
lz4-static \
e2fsprogs \
zstd-dev \
keyutils \
zlib-dev \
gdbm-dev \
clang17 \
lz4-dev \
libldap \
bison \
curl \
perl \
make

COPY <<EOF ./main.cpp
#include<libpq-fe.h>
int main(){return PQconnectdb("")==NULL;}
EOF

RUN curl -L https://kerberos.org/dist/krb5/1.21/krb5-1.21.3.tar.gz >
krb5-1.21.3.tar.gz && tar xf krb5-1.21.3.tar.gz
RUN cd krb5-1.21.3/src && \
./configure && make && make install && \
./configure --disable-shared --enable-static && make && make install

RUN curl -L https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-2.1.28/cyrus-sasl-2.1.28.tar.gz
> cyrus-sasl-2.1.28.tar.gz
RUN tar xf cyrus-sasl-2.1.28.tar.gz && cd cyrus-sasl-2.1.28 &&
./configure --enable-static && make && make install

RUN clang++ -fno-common -static -o main main.cpp \
-L/usr/local/lib -lpq -lpgcommon -lpgport \
-lldap -lsasl2 -lssl -lcrypto -llber \
-lgssapi_krb5 \
-lkrb5 -lk5crypto -lcom_err -lkrb5support \
-lgdbm

On Thu, Oct 10, 2024 at 5:28 PM Mikael Sand <msand(at)seaber(dot)io> wrote:

> I don't mind having this patch in use too much, I have a functional build
> and nothing to worry about, no luck necessary :)
>
> But, I expect a lot of unnecessary churn in the community if this is not
> fixed properly.
> Not all applications run inside docker, and not all can use dynamic
> linking.
> People can dislike static linking for whatever reason, but that doesn't
> remove the need for it (or both) in some cases and the desire for it in
> others.
>
> Judging from the commit, it doesn't seem like static linking is
> intentionally broken.
> Should a test be added so as not to break this by mistake?
> I must say I don't fully comprehend the context of that commit.
>
> On Thu, Oct 10, 2024 at 5:06 PM Mikael Sand <msand(at)seaber(dot)io> wrote:
>
>> This seems to be the commit that caused this:
>> https://github.com/postgres/postgres/commit/b6c7cfac88c47a9194d76f3d074129da3c46545a
>>
>> So it seems the commit is related to static linking.
>>
>> Is it somehow possible to statically link in a version of pgcommon with
>> correct function names into libpq?
>>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-10 16:12:20 Re: Converting tab-complete.c's else-if chain to a switch
Previous Message Artur Zakirov 2024-10-10 15:54:01 Re: type cache cleanup improvements