Sorry for not having a properly minimal reproduction to begin with, seems I
can't reduce this any further at the moment at least:

# syntax=docker/dockerfile:1
> FROM chainguard/git:latest-dev AS builder
> USER root
> WORKDIR /app
> RUN apk update && apk add --no-cache --update-cache \
>     clang-19 \
>     bison \
>     curl \
>     flex \
>     make \
>     perl
>
> ARG PG=17.0
> RUN curl -L https://ftp.postgresql.org/pub/source/v$PG/postgresql-$PG.tar.bz2 
> | tar -xj
> COPY <<EOF ./pg.patch
> Subject: [PATCH] Fix static build
> ---
> Index: src/bin/initdb/Makefile
> <+>UTF-8
> ===================================================================
> diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
> --- a/src/bin/initdb/Makefile (revision 
> c4b8a916f8a53379621825028532b038e004f891)
> +++ b/src/bin/initdb/Makefile (date 1728466911177)
> @@ -20,7 +20,8 @@
>  # from libpq, else we have risks of version skew if we run with a libpq
>  # shared library from a different PG version.  Define
>  # USE_PRIVATE_ENCODING_FUNCS to ensure that that happens.
> -override CPPFLAGS := -DUSE_PRIVATE_ENCODING_FUNCS -I$(libpq_srcdir) 
> -I$(top_srcdir)/src/timezone $(ICU_CFLAGS) $(CPPFLAGS)
> +#override CPPFLAGS := -DUSE_PRIVATE_ENCODING_FUNCS -I$(libpq_srcdir) 
> -I$(top_srcdir)/src/timezone $(ICU_CFLAGS) $(CPPFLAGS)
> +override CPPFLAGS := -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone 
> $(ICU_CFLAGS) $(CPPFLAGS)
>
>  # We need libpq only because fe_utils does.
>  LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils 
> $(libpq_pgport) $(ICU_LIBS)
> Index: src/common/Makefile
> <+>UTF-8
> ===================================================================
> diff --git a/src/common/Makefile b/src/common/Makefile
> --- a/src/common/Makefile (revision c4b8a916f8a53379621825028532b038e004f891)
> +++ b/src/common/Makefile (date 1728466354406)
> @@ -143,7 +143,7 @@
>  # Files in libpgcommon.a should use/export the "xxx_private" versions
>  # of pg_char_to_encoding() and friends.
>  #
> -$(OBJS_FRONTEND): CPPFLAGS += -DUSE_PRIVATE_ENCODING_FUNCS
> +#$(OBJS_FRONTEND): CPPFLAGS += -DUSE_PRIVATE_ENCODING_FUNCS
>
>
>  #
> EOF
> RUN cd postgresql-$PG && \
>     git apply ../pg.patch && \
>     export CC=clang CXX=clang++ && \
>     ./configure --without-openssl --without-icu --without-ldap 
> --without-readline --without-zlib --without-tcl --without-python 
> --prefix=/usr/local && \
>     cd src && for lib in include common port interfaces/libpq ; do cd $lib && 
> make && make install && cd - ; done
>
> COPY <<EOF ./main.cpp
> #include<libpq-fe.h>
> int main(){return PQconnectdb("")==NULL;}
> EOF
>
> RUN clang++ -static -o main main.cpp -lpq -lpgcommon -lpgport
> ENTRYPOINT ["./main"]
> CMD []
>
>

Reply via email to