fix(release): serial shared-deps build, macOS strchrnul fallback, copy all Windows DLLs

Three independent pg-tools step failures on the 5th release run:

- Linux: 'ar: libpgcommon_srv.a: file format not recognized' — parallel
  `make -C` tool builds race each other's recursion into src/common
  (rm -f / ar crs on the same archive). Pre-build generated-headers +
  libpq (which pulls in common/port) serially so the -j tool builds find
  the archives up to date.
- macOS x86_64: strchrnul marked 'introduced in macOS 15.4' by Xcode 16.4
  fails -Werror=unguarded-availability-new and would crash at runtime on
  macOS < 15.4. Force ac_cv_func_strchrnul=no and rename PG16's inline
  fallback (pg_strchrnul) so it compiles on any SDK without touching the
  system symbol.
- Windows: EDB pg_dump.exe needs libcrypto/libssl/libiconv/libintl/
  libwinpthread/liblz4/libzstd/ICU DLLs; copy every bin/*.dll, not just
  libpq.dll.

All three verified locally (macOS: full build + tools run from resource
dir; YAML + bash -n for all platform variants).
This commit is contained in:
2026-08-05 21:52:45 +08:00
parent 0b8b11cef3
commit 0c8c240384
+30 -5
View File
@@ -78,10 +78,14 @@ jobs:
tar -xf /tmp/pg.tar.bz2 -C /tmp
cd /tmp/postgresql-${PG_VER}
./configure --prefix=/tmp/pgbuild --without-readline --without-icu CFLAGS="-O2"
# Generate the catalog headers (pg_class_d.h etc.) serially FIRST:
# building src/bin/pg_dump directly races its generated-headers
# prerequisite under -j and fails with 'catalog/pg_*_d.h not found'.
# Build the shared prerequisites (catalog headers + libpq/common/
# port archives) SERIALLY FIRST. Parallel `make -C` runs recurse
# into src/common concurrently and race `rm -f` / `ar crs` on the
# same .a — intermittently failing with 'ar: libpgcommon_srv.a:
# file format not recognized'. Once the archives exist, the tools'
# -j builds find them up to date and those recursions are no-ops.
make -C src/backend generated-headers
make -C src/interfaces/libpq all
make -j"$(nproc)" -C src/bin/pg_dump all
make -j"$(nproc)" -C src/bin/psql all
cp src/bin/pg_dump/pg_dump src/bin/pg_dump/pg_restore "$OUT"/
@@ -98,8 +102,25 @@ jobs:
curl -fsSL "https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.bz2" -o /tmp/pg.tar.bz2
tar -xf /tmp/pg.tar.bz2 -C /tmp
cd /tmp/postgresql-${PG_VER}
./configure --prefix=/tmp/pgbuild --without-readline --without-icu CFLAGS="-O2"
# ac_cv_func_strchrnul=no: Xcode 16.4's SDK marks strchrnul as
# introduced in macOS 15.4, so configure detects it and PG's
# snprintf.c calls the system symbol — which fails to compile
# (-Werror=unguarded-availability-new) and would crash at runtime
# on macOS < 15.4. Forcing the check off makes PG use its own
# inline fallback instead.
ac_cv_func_strchrnul=no ./configure --prefix=/tmp/pgbuild --without-readline --without-icu CFLAGS="-O2"
# macOS SDKs always declare strchrnul in <string.h> (Xcode 16.4
# marks it 'introduced in macOS 15.4'), so even with HAVE_STRCHRNUL
# disabled PG16's static-inline fallback would collide with the
# header declaration on newer SDKs. Rename PG's fallback so the
# tools compile on any SDK and never touch the (15.4+ only)
# system symbol.
sed -i '' 's/strchrnul/pg_strchrnul/g' src/port/snprintf.c
# Serial shared-prerequisite build first (see the Linux block: the
# archives must exist before the -j tool builds recurse into
# src/common).
make -C src/backend generated-headers
make -C src/interfaces/libpq all
make -j"$(sysctl -n hw.ncpu)" -C src/bin/pg_dump all
make -j"$(sysctl -n hw.ncpu)" -C src/bin/psql all
cp src/bin/pg_dump/pg_dump src/bin/pg_dump/pg_restore "$OUT"/
@@ -120,7 +141,11 @@ jobs:
sha256sum /tmp/pg.zip
unzip -o /tmp/pg.zip -d /tmp/pg
cp /tmp/pg/pgsql/bin/pg_dump.exe /tmp/pg/pgsql/bin/pg_restore.exe /tmp/pg/pgsql/bin/psql.exe "$OUT"/
cp /tmp/pg/pgsql/bin/libpq.dll "$OUT"/
# pg_dump.exe needs far more than libpq.dll (libcrypto-3-x64.dll,
# libssl-3-x64.dll, libiconv-2.dll, libintl-9.dll,
# libwinpthread-1.dll, liblz4.dll, libzstd.dll, ICU DLLs, ...);
# copy every DLL next to the tools.
cp /tmp/pg/pgsql/bin/*.dll "$OUT"/
;;
esac
(cd "$OUT" && sha256sum * | tee checksums.txt)