diff --git a/edgedbpkg/edgedb/__init__.py b/edgedbpkg/edgedb/__init__.py index 247e63d..26e925a 100644 --- a/edgedbpkg/edgedb/__init__.py +++ b/edgedbpkg/edgedb/__init__.py @@ -72,7 +72,7 @@ class EdgeDB(packages.BundledPythonPackage): "pgext-pgvector", ], ">=5.0.dev1": [ - "postgresql-edgedb (~= 15.0)", + "postgresql-edgedb (~= 16.0)", "python-edgedb (~= 3.12.0)", "pgext-pgvector (~= 0.6.0)", ], @@ -85,6 +85,7 @@ class EdgeDB(packages.BundledPythonPackage): bundle_deps = [ postgresql.PostgreSQL(version="14.11"), postgresql.PostgreSQL(version="15.6"), + postgresql.PostgreSQL(version="16.2"), python_bundle.Python(version="3.10.11"), python_bundle.Python(version="3.11.8"), python_bundle.Python(version="3.12.2"), diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-16.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-16.patch new file mode 100644 index 0000000..735faaf --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-16.patch @@ -0,0 +1,87 @@ +From f32032bbb2bc2726a0061dd898afd327a9e1bea4 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Tue, 16 Aug 2022 22:00:31 -0700 +Subject: [PATCH 3/5] Add an envvar escape hatch to disable argv clobbering + +The `set_ps_display` business clobbers the environment block on Linux, +thus butchering all prior `getenv` calls, which includes +`getenv(LD_LIBRARY_PATH)` done by `ld-musl.so`. Musl is at fault too, +because it really ought to `strdup` the entry, but until that's fixed, +setting `PG_DISABLE_PS_DISPLAY=1` is the fix. +--- + src/backend/utils/misc/ps_status.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c +index 104c01d966..a471a95792 100644 +--- a/src/backend/utils/misc/ps_status.c ++++ b/src/backend/utils/misc/ps_status.c +@@ -14,6 +14,7 @@ + + #include "postgres.h" + ++#include + #include + #if defined(__darwin__) + #include +@@ -29,6 +30,7 @@ extern char **environ; + + /* GUC variable */ + bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE; ++bool disable_ps_display = false; + + /* + * Alternative ways of updating ps display: +@@ -117,9 +119,16 @@ static char **save_argv; + char ** + save_ps_display_args(int argc, char **argv) + { ++ char *disable_env = getenv("PG_DISABLE_PS_DISPLAY"); ++ + save_argc = argc; + save_argv = argv; + ++ disable_ps_display = disable_env != NULL && *disable_env != '\0'; ++ ++ if (disable_ps_display) ++ return argv; ++ + #if defined(PS_USE_CLOBBER_ARGV) + + /* +@@ -241,6 +250,9 @@ save_ps_display_args(int argc, char **argv) + void + init_ps_display(const char *fixed_part) + { ++ if (disable_ps_display) ++ return; ++ + #ifndef PS_USE_NONE + bool save_update_process_title; + #endif +@@ -317,6 +329,9 @@ init_ps_display(const char *fixed_part) + static bool + update_ps_display_precheck(void) + { ++ if (disable_ps_display) ++ return; ++ + /* update_process_title=off disables updates */ + if (!update_process_title) + return false; +@@ -504,6 +519,12 @@ flush_ps_display(void) + const char * + get_ps_display(int *displen) + { ++ if (disable_ps_display) ++ { ++ *displen = 0; ++ return ""; ++ } ++ + #ifdef PS_USE_CLOBBER_ARGV + /* If ps_buffer is a pointer, it might still be null */ + if (!ps_buffer) +-- +2.43.0 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-16.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-16.patch new file mode 100644 index 0000000..7852230 --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-16.patch @@ -0,0 +1,1167 @@ +From 703463c8ff99e003b08f6ec0bab746ccf0eb0f93 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Mon, 11 Feb 2019 20:28:00 -0500 +Subject: [PATCH 5/5] Use pkg-config for libuuid, openssl and zlib + +--- + configure | 650 +++++++++++++++++++++++++++++-- + configure.ac | 109 +++++- + contrib/pgcrypto/Makefile | 4 + + contrib/sslinfo/Makefile | 2 + + src/Makefile.global.in | 9 +- + src/backend/Makefile | 4 +- + src/backend/libpq/Makefile | 1 + + src/bin/pg_verifybackup/Makefile | 4 + + src/bin/pgbench/Makefile | 3 + + src/common/Makefile | 1 + + src/include/pg_config.h.in | 2 +- + src/interfaces/libpq/Makefile | 1 + + 12 files changed, 755 insertions(+), 35 deletions(-) + +diff --git a/configure b/configure +index 7279c98da0..ca58d52b07 100755 +--- a/configure ++++ b/configure +@@ -652,9 +652,14 @@ OPENSSL + ZSTD + LZ4 + UUID_LIBS ++UUID_CFLAGS + LDAP_LIBS_BE + LDAP_LIBS_FE + with_ssl ++OPENSSL_LIBS ++OPENSSL_CFLAGS ++ZLIB_LIBS ++ZLIB_CFLAGS + PTHREAD_CFLAGS + PTHREAD_LIBS + PTHREAD_CC +@@ -906,6 +911,12 @@ LDFLAGS_EX + LDFLAGS_SL + PERL + PYTHON ++ZLIB_CFLAGS ++ZLIB_LIBS ++OPENSSL_CFLAGS ++OPENSSL_LIBS ++UUID_CFLAGS ++UUID_LIBS + MSGFMT + TCLSH' + +@@ -1618,6 +1629,14 @@ Some influential environment variables: + LDFLAGS_SL extra linker flags for linking shared libraries only + PERL Perl program + PYTHON Python program ++ ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config ++ ZLIB_LIBS linker flags for ZLIB, overriding pkg-config ++ OPENSSL_CFLAGS ++ C compiler flags for OPENSSL, overriding pkg-config ++ OPENSSL_LIBS ++ linker flags for OPENSSL, overriding pkg-config ++ UUID_CFLAGS C compiler flags for UUID, overriding pkg-config ++ UUID_LIBS linker flags for UUID, overriding pkg-config + MSGFMT msgfmt program for NLS + TCLSH Tcl interpreter program (tclsh) + +@@ -12549,7 +12568,74 @@ Use --without-readline to disable readline support." "$LINENO" 5 + fi + + if test "$with_zlib" = yes; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 ++ have_zlib=missing ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5 ++$as_echo_n "checking for zlib... " >&6; } ++ ++if test -n "$ZLIB_CFLAGS"; then ++ pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "zlib") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$ZLIB_LIBS"; then ++ pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "zlib") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib" 2>&1` ++ else ++ ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$ZLIB_PKG_ERRORS" >&5 ++ ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 + $as_echo_n "checking for inflate in -lz... " >&6; } + if ${ac_cv_lib_z_inflate+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -12586,19 +12672,105 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflate" >&5 + $as_echo "$ac_cv_lib_z_inflate" >&6; } + if test "x$ac_cv_lib_z_inflate" = xyes; then : +- cat >>confdefs.h <<_ACEOF +-#define HAVE_LIBZ 1 ++ ++ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ++ ZLIB_LIBS=${ZLIB_LIBS-"-lz"} ++ have_zlib=yes ++ ++fi ++ ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 ++$as_echo_n "checking for inflate in -lz... " >&6; } ++if ${ac_cv_lib_z_inflate+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lz $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char inflate (); ++int ++main () ++{ ++return inflate (); ++ ; ++ return 0; ++} + _ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_z_inflate=yes ++else ++ ac_cv_lib_z_inflate=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflate" >&5 ++$as_echo "$ac_cv_lib_z_inflate" >&6; } ++if test "x$ac_cv_lib_z_inflate" = xyes; then : ++ ++ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ++ ZLIB_LIBS=${ZLIB_LIBS-"-lz"} ++ have_zlib=yes ++ ++fi ++ ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++else ++ ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS ++ ZLIB_LIBS=$pkg_cv_ZLIB_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++ have_zlib=yes ++ ++fi ++ ++ if test "x$have_zlib" = xyes; then : ++ ++ ++$as_echo "#define HAVE_LIBZ 1" >>confdefs.h + +- LIBS="-lz $LIBS" ++ LIBS="-lz $LIBS" ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" + + else +- as_fn_error $? "zlib library not found ++ ++ as_fn_error $? "zlib library not found + If you have zlib already installed, see config.log for details on the + failure. It is possible the compiler isn't looking in the proper directory. + Use --without-zlib to disable zlib support." "$LINENO" 5 +-fi + ++fi + fi + + if test "$enable_spinlocks" = yes; then +@@ -12746,10 +12918,108 @@ if test "$with_openssl" = yes ; then + fi + + if test "$with_ssl" = openssl ; then +- # Minimum required OpenSSL version is 1.0.1 ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl" >&5 ++$as_echo_n "checking for openssl... " >&6; } ++ ++if test -n "$OPENSSL_CFLAGS"; then ++ pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$OPENSSL_LIBS"; then ++ pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1` ++ else ++ OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$OPENSSL_PKG_ERRORS" >&5 ++ ++ as_fn_error $? "Package requirements (openssl) were not met: ++ ++$OPENSSL_PKG_ERRORS ++ ++Consider adjusting the PKG_CONFIG_PATH environment variable if you ++installed software in a non-standard prefix. ++ ++Alternatively, you may set the environment variables OPENSSL_CFLAGS ++and OPENSSL_LIBS to avoid the need to call pkg-config. ++See the pkg-config man page for more details." "$LINENO" 5 ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it ++is in your PATH or set the PKG_CONFIG environment variable to the full ++path to pkg-config. ++ ++Alternatively, you may set the environment variables OPENSSL_CFLAGS ++and OPENSSL_LIBS to avoid the need to call pkg-config. ++See the pkg-config man page for more details. ++ ++To get pkg-config, see . ++See \`config.log' for more details" "$LINENO" 5; } ++else ++ OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS ++ OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++fi ++ # Minimum required OpenSSL version is 1.0.1 + + $as_echo "#define OPENSSL_API_COMPAT 0x10001000L" >>confdefs.h + ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $OPENSSL_CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $OPENSSL_LIBS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ + if test "$PORTNAME" != "win32"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_new_ex_data in -lcrypto" >&5 + $as_echo_n "checking for CRYPTO_new_ex_data in -lcrypto... " >&6; } +@@ -13023,6 +13293,10 @@ done + + $as_echo "#define USE_OPENSSL 1" >>confdefs.h + ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS + elif test "$with_ssl" != no ; then + as_fn_error $? "--with-ssl must specify openssl" "$LINENO" 5 + fi +@@ -13521,14 +13795,85 @@ else + fi + + elif test "$with_uuid" = e2fs ; then +- # On macOS, the UUID functions are in libc +- ac_fn_c_check_func "$LINENO" "uuid_generate" "ac_cv_func_uuid_generate" +-if test "x$ac_cv_func_uuid_generate" = xyes; then : +- UUID_LIBS="" ++ have_uuid=missing ++ ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid >= 2.20" >&5 ++$as_echo_n "checking for uuid >= 2.20... " >&6; } ++ ++if test -n "$UUID_CFLAGS"; then ++ pkg_cv_UUID_CFLAGS="$UUID_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 2.20\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "uuid >= 2.20") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_UUID_CFLAGS=`$PKG_CONFIG --cflags "uuid >= 2.20" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$UUID_LIBS"; then ++ pkg_cv_UUID_LIBS="$UUID_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 2.20\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "uuid >= 2.20") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_UUID_LIBS=`$PKG_CONFIG --libs "uuid >= 2.20" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes + else +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5 +-$as_echo_n "checking for uuid_generate in -luuid... " >&6; } +-if ${ac_cv_lib_uuid_uuid_generate+:} false; then : ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ UUID_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "uuid >= 2.20" 2>&1` ++ else ++ UUID_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "uuid >= 2.20" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$UUID_PKG_ERRORS" >&5 ++ ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $UUID_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ for ac_header in uuid/uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +@@ -13542,34 +13887,279 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext + #ifdef __cplusplus + extern "C" + #endif +-char uuid_generate (); ++char uuid_generate_time (); + int + main () + { +-return uuid_generate (); ++return uuid_generate_time (); + ; + return 0; + } + _ACEOF + if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_uuid_uuid_generate=yes ++ ac_cv_lib_uuid_uuid_generate_time=yes + else +- ac_cv_lib_uuid_uuid_generate=no ++ ac_cv_lib_uuid_uuid_generate_time=no + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5 +-$as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; } +-if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then : +- UUID_LIBS="-luuid" ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ ++ + else +- as_fn_error $? "library 'uuid' is required for E2FS UUID" "$LINENO" 5 ++ ++ for ac_header in uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-luuid $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char uuid_generate_time (); ++int ++main () ++{ ++return uuid_generate_time (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_uuid_uuid_generate_time=yes ++else ++ ac_cv_lib_uuid_uuid_generate_time=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes + fi + ++ ++fi ++ ++done ++ ++ ++fi ++ ++done ++ ++ ++ if test "x$have_uuid" = xyes; then : ++ ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-"-luuid"} ++ + fi + ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $UUID_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ for ac_header in uuid/uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-luuid $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char uuid_generate_time (); ++int ++main () ++{ ++return uuid_generate_time (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_uuid_uuid_generate_time=yes ++else ++ ac_cv_lib_uuid_uuid_generate_time=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ ++ ++else ++ ++ for ac_header in uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-luuid $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char uuid_generate_time (); ++int ++main () ++{ ++return uuid_generate_time (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_uuid_uuid_generate_time=yes ++else ++ ac_cv_lib_uuid_uuid_generate_time=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ ++ ++fi ++ ++done ++ ++ ++fi ++ ++done ++ ++ ++ if test "x$have_uuid" = xyes; then : ++ ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-"-luuid"} ++ ++fi ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++else ++ UUID_CFLAGS=$pkg_cv_UUID_CFLAGS ++ UUID_LIBS=$pkg_cv_UUID_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++ have_uuid=yes ++ ++fi ++ ++ # On macOS, the UUID functions are in libc ++ if test "x$have_uuid" = xmissing; then : ++ ++ for ac_header in uuid/uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_UUID_H 1 ++_ACEOF ++ ++ ac_fn_c_check_func "$LINENO" "uuid_generate_time" "ac_cv_func_uuid_generate_time" ++if test "x$ac_cv_func_uuid_generate_time" = xyes; then : ++ ++ have_uuid=yes ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-""} ++ ++fi ++ ++ ++fi ++ ++done ++ ++ ++fi ++ ++ if test "x$have_uuid" = xmissing; then : ++ ++ as_fn_error $? "library 'uuid' is required for E2FS UUID" "$LINENO" 5 ++ ++fi + elif test "$with_uuid" = ossp ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_export in -lossp-uuid" >&5 + $as_echo_n "checking for uuid_export in -lossp-uuid... " >&6; } +@@ -13925,6 +14515,8 @@ done + fi + + if test "$with_zlib" = yes; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" + if test "x$ac_cv_header_zlib_h" = xyes; then : + +@@ -13936,6 +14528,7 @@ Use --without-zlib to disable zlib support." "$LINENO" 5 + fi + + ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + if test -z "$LZ4"; then +@@ -14183,6 +14776,8 @@ pgac_openssl_version="$($OPENSSL version 2> /dev/null || echo openssl not found) + { $as_echo "$as_me:${as_lineno-$LINENO}: using openssl: $pgac_openssl_version" >&5 + $as_echo "$as_me: using openssl: $pgac_openssl_version" >&6;} + if test "$with_ssl" = openssl ; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS" + ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" + if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : + +@@ -14199,6 +14794,7 @@ else + fi + + ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + if test "$with_pam" = yes ; then +@@ -14352,6 +14948,9 @@ fi + + fi + ++pgac_save_CPPFLAGS=$CPPFLAGS ++CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ + # for contrib/uuid-ossp + if test "$with_uuid" = bsd ; then + for ac_header in uuid.h +@@ -14486,6 +15085,8 @@ done + + fi + ++CPPFLAGS=$pgac_save_CPPFLAGS ++ + if test "$PORTNAME" = "win32" ; then + for ac_header in crtdefs.h + do : +@@ -15221,6 +15822,8 @@ if test "$with_zlib" = yes; then + # Check that defines z_streamp (versions before about 1.0.4 + # did not). While we could work around the lack of z_streamp, it + # seems unwise to encourage people to use such old zlib versions... ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + ac_fn_c_check_type "$LINENO" "z_streamp" "ac_cv_type_z_streamp" "#include + " + if test "x$ac_cv_type_z_streamp" = xyes; then : +@@ -15230,6 +15833,7 @@ else + Use --without-zlib to disable zlib support." "$LINENO" 5 + fi + ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + case $host_cpu in +diff --git a/configure.ac b/configure.ac +index e50ef69f82..d6338ec1c0 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1321,11 +1321,39 @@ Use --without-readline to disable readline support.]) + fi + + if test "$with_zlib" = yes; then +- AC_CHECK_LIB(z, inflate, [], +- [AC_MSG_ERROR([zlib library not found ++ have_zlib=missing ++ PKG_CHECK_MODULES( ++ [ZLIB], [zlib], [ ++ have_zlib=yes ++ ], [ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ AC_CHECK_LIB(z, inflate, [ ++ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ++ ZLIB_LIBS=${ZLIB_LIBS-"-lz"} ++ have_zlib=yes ++ ]) ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ] ++ ) ++ ++ AS_VAR_IF([have_zlib], [yes], [ ++ AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if you have zlib.]) ++ LIBS="-lz $LIBS" ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ ], [ ++ AC_MSG_ERROR([zlib library not found + If you have zlib already installed, see config.log for details on the + failure. It is possible the compiler isn't looking in the proper directory. +-Use --without-zlib to disable zlib support.])]) ++Use --without-zlib to disable zlib support.]) ++ ]) + fi + + if test "$enable_spinlocks" = yes; then +@@ -1367,9 +1395,17 @@ fi + + if test "$with_ssl" = openssl ; then + dnl Order matters! ++ PKG_CHECK_MODULES(OPENSSL, openssl) + # Minimum required OpenSSL version is 1.0.1 + AC_DEFINE(OPENSSL_API_COMPAT, [0x10001000L], + [Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.]) ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $OPENSSL_CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $OPENSSL_LIBS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ + if test "$PORTNAME" != "win32"; then + AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) + AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) +@@ -1393,6 +1429,10 @@ if test "$with_ssl" = openssl ; then + # Function introduced in OpenSSL 1.1.1. + AC_CHECK_FUNCS([X509_get_signature_info]) + AC_DEFINE([USE_OPENSSL], 1, [Define to 1 to build with OpenSSL support. (--with-ssl=openssl)]) ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS + elif test "$with_ssl" != no ; then + AC_MSG_ERROR([--with-ssl must specify openssl]) + fi +@@ -1470,12 +1510,51 @@ if test "$with_uuid" = bsd ; then + [UUID_LIBS=""], + [AC_MSG_ERROR([BSD UUID functions are not present])]) + elif test "$with_uuid" = e2fs ; then ++ have_uuid=missing ++ ++ PKG_CHECK_MODULES( ++ [UUID], [uuid >= 2.20], [ ++ have_uuid=yes ++ ], [ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $UUID_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ AC_CHECK_HEADERS([uuid/uuid.h], [ ++ AC_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes]) ++ ], [ ++ AC_CHECK_HEADERS([uuid.h], [ ++ AC_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes]) ++ ]) ++ ]) ++ ++ AS_VAR_IF([have_uuid], [yes], [ ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-"-luuid"} ++ ]) ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ] ++ ) ++ + # On macOS, the UUID functions are in libc +- AC_CHECK_FUNC(uuid_generate, +- [UUID_LIBS=""], +- [AC_CHECK_LIB(uuid, uuid_generate, +- [UUID_LIBS="-luuid"], +- [AC_MSG_ERROR([library 'uuid' is required for E2FS UUID])])]) ++ AS_VAR_IF([have_uuid], [missing], [ ++ AC_CHECK_HEADERS([uuid/uuid.h], [ ++ AC_CHECK_FUNC([uuid_generate_time], [ ++ have_uuid=yes ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-""} ++ ]) ++ ]) ++ ]) ++ ++ AS_VAR_IF([have_uuid], [missing], [ ++ AC_MSG_ERROR([library 'uuid' is required for E2FS UUID]) ++ ]) + elif test "$with_uuid" = ossp ; then + AC_CHECK_LIB(ossp-uuid, uuid_export, + [UUID_LIBS="-lossp-uuid"], +@@ -1548,10 +1627,13 @@ Use --without-readline to disable libedit support.])])])]) + fi + + if test "$with_zlib" = yes; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found + If you have zlib already installed, see config.log for details on the + failure. It is possible the compiler isn't looking in the proper directory. + Use --without-zlib to disable zlib support.])]) ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + PGAC_PATH_PROGS(LZ4, lz4) +@@ -1575,8 +1657,11 @@ PGAC_PATH_PROGS(OPENSSL, openssl) + pgac_openssl_version="$($OPENSSL version 2> /dev/null || echo openssl not found)" + AC_MSG_NOTICE([using openssl: $pgac_openssl_version]) + if test "$with_ssl" = openssl ; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS" + AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file is required for OpenSSL])]) + AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file is required for OpenSSL])]) ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + if test "$with_pam" = yes ; then +@@ -1625,6 +1710,9 @@ dnl If you want to use Apple's own Bonjour code on another platform, + dnl just add -ldns_sd to LIBS manually. + fi + ++pgac_save_CPPFLAGS=$CPPFLAGS ++CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ + # for contrib/uuid-ossp + if test "$with_uuid" = bsd ; then + AC_CHECK_HEADERS(uuid.h, +@@ -1649,6 +1737,8 @@ elif test "$with_uuid" = ossp ; then + [AC_MSG_ERROR([header file or is required for OSSP UUID])])]) + fi + ++CPPFLAGS=$pgac_save_CPPFLAGS ++ + if test "$PORTNAME" = "win32" ; then + AC_CHECK_HEADERS(crtdefs.h) + fi +@@ -1701,9 +1791,12 @@ if test "$with_zlib" = yes; then + # Check that defines z_streamp (versions before about 1.0.4 + # did not). While we could work around the lack of z_streamp, it + # seems unwise to encourage people to use such old zlib versions... ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + AC_CHECK_TYPE(z_streamp, [], [AC_MSG_ERROR([zlib version is too old + Use --without-zlib to disable zlib support.])], + [#include ]) ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + case $host_cpu in +diff --git a/contrib/pgcrypto/Makefile b/contrib/pgcrypto/Makefile +index 7fb59f51b7..16183af7f7 100644 +--- a/contrib/pgcrypto/Makefile ++++ b/contrib/pgcrypto/Makefile +@@ -58,6 +58,10 @@ include $(top_builddir)/src/Makefile.global + include $(top_srcdir)/contrib/contrib-global.mk + endif + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif ++ + # Add libraries that pgcrypto depends (or might depend) on into the + # shared library link. (The order in which you list them here doesn't + # matter.) +diff --git a/contrib/sslinfo/Makefile b/contrib/sslinfo/Makefile +index dd1ff83b16..20a4615287 100644 +--- a/contrib/sslinfo/Makefile ++++ b/contrib/sslinfo/Makefile +@@ -20,4 +20,6 @@ include $(top_builddir)/src/Makefile.global + include $(top_srcdir)/contrib/contrib-global.mk + endif + ++LIBS += $(OPENSSL_LIBS) ++ + SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS)) +diff --git a/src/Makefile.global.in b/src/Makefile.global.in +index f15ca4fd85..12dc768fc3 100644 +--- a/src/Makefile.global.in ++++ b/src/Makefile.global.in +@@ -190,6 +190,13 @@ krb_srvtab = @krb_srvtab@ + ICU_CFLAGS = @ICU_CFLAGS@ + ICU_LIBS = @ICU_LIBS@ + ++OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ ++OPENSSL_LIBS = @OPENSSL_LIBS@ ++ ++UUID_CFLAGS = @UUID_CFLAGS@ ++ ++ZLIB_CFLAGS = @ZLIB_CFLAGS@ ++ + TCLSH = @TCLSH@ + TCL_LIBS = @TCL_LIBS@ + TCL_LIB_SPEC = @TCL_LIB_SPEC@ +@@ -214,7 +221,7 @@ CPP = @CPP@ + CPPFLAGS = @CPPFLAGS@ + PG_SYSROOT = @PG_SYSROOT@ + +-override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS) ++override CPPFLAGS := $(UUID_CFLAGS) $(OPENSSL_CFLAGS) $(ICU_CFLAGS) $(ZLIB_CFLAGS) $(CPPFLAGS) + + ifdef PGXS + override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS) +diff --git a/src/backend/Makefile b/src/backend/Makefile +index 3c42003175..7812d064ed 100644 +--- a/src/backend/Makefile ++++ b/src/backend/Makefile +@@ -44,8 +44,8 @@ OBJS = \ + $(top_builddir)/src/port/libpgport_srv.a + + # We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add +-# libldap and ICU +-LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS) ++# libldap, ICU, and OpenSSL. ++LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS) $(OPENSSL_LIBS) + + # The backend doesn't need everything that's in LIBS, however + LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS)) +diff --git a/src/backend/libpq/Makefile b/src/backend/libpq/Makefile +index 6d385fd6a4..e385ab4c81 100644 +--- a/src/backend/libpq/Makefile ++++ b/src/backend/libpq/Makefile +@@ -31,6 +31,7 @@ OBJS = \ + + ifeq ($(with_ssl),openssl) + OBJS += be-secure-openssl.o ++LIBS += $(OPENSSL_LIBS) + endif + + ifeq ($(with_gssapi),yes) +diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile +index 596df15118..046909d677 100644 +--- a/src/bin/pg_verifybackup/Makefile ++++ b/src/bin/pg_verifybackup/Makefile +@@ -24,6 +24,10 @@ OBJS = \ + parse_manifest.o \ + pg_verifybackup.o + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif ++ + all: pg_verifybackup + + pg_verifybackup: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils +diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile +index 68b6eb0376..224226e145 100644 +--- a/src/bin/pgbench/Makefile ++++ b/src/bin/pgbench/Makefile +@@ -23,6 +23,9 @@ override CPPFLAGS += -DFD_SETSIZE=1024 + endif + LIBS += $(PTHREAD_LIBS) + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif + + all: pgbench + +diff --git a/src/common/Makefile b/src/common/Makefile +index 372f8e4d7c..d8b6dac2ac 100644 +--- a/src/common/Makefile ++++ b/src/common/Makefile +@@ -88,6 +88,7 @@ OBJS_COMMON += \ + cryptohash_openssl.o \ + hmac_openssl.o \ + protocol_openssl.o ++LIBS += $(OPENSSL_LIBS) + else + OBJS_COMMON += \ + cryptohash.o \ +diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in +index c2e27b5416..71d67895d5 100644 +--- a/src/include/pg_config.h.in ++++ b/src/include/pg_config.h.in +@@ -289,7 +289,7 @@ + /* Define to 1 if you have the `xslt' library (-lxslt). */ + #undef HAVE_LIBXSLT + +-/* Define to 1 if you have the `z' library (-lz). */ ++/* Define to 1 if you have zlib. */ + #undef HAVE_LIBZ + + /* Define to 1 if you have the `zstd' library (-lzstd). */ +diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile +index 0919d8f32f..e0e70ce5e6 100644 +--- a/src/interfaces/libpq/Makefile ++++ b/src/interfaces/libpq/Makefile +@@ -55,6 +55,7 @@ endif + ifeq ($(with_ssl),openssl) + OBJS += \ + fe-secure-openssl.o ++LIBS += $(OPENSSL_LIBS) + endif + + ifeq ($(with_gssapi),yes) +-- +2.43.0 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__popen-16.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__popen-16.patch new file mode 100644 index 0000000..8efe558 --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__popen-16.patch @@ -0,0 +1,387 @@ +From dbdf4bc9f2d94920c3e8f9dea4edc8c4a85cffcf Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Sat, 30 May 2020 18:53:22 -0700 +Subject: [PATCH 2/5] Add a version of popen() that respects the SHELL + environment variable + +The main motivation here is to workaround SIP on macOS, where all +binaries in `/bin` will not inherit `DYLD_LIBRARY_PATH`, including +`/bin/sh`, which is spawned by `popen()`. This prevents running +Postgres from a temp installation dir. +--- + src/bin/initdb/initdb.c | 3 +- + src/bin/pg_ctl/pg_ctl.c | 3 +- + src/common/Makefile | 1 + + src/common/exec.c | 6 +- + src/common/popen.c | 224 +++++++++++++++++++++++++++++++++++++++ + src/include/port/popen.h | 42 ++++++++ + 6 files changed, 275 insertions(+), 4 deletions(-) + create mode 100644 src/common/popen.c + create mode 100644 src/include/port/popen.h + +diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c +index 3afe14cb4b..d30497ea28 100644 +--- a/src/bin/initdb/initdb.c ++++ b/src/bin/initdb/initdb.c +@@ -80,6 +80,7 @@ + #include "getopt_long.h" + #include "mb/pg_wchar.h" + #include "miscadmin.h" ++#include "port/popen.h" + + + /* Ideally this would be in a .h file, but it hardly seems worth the trouble */ +@@ -681,7 +682,7 @@ popen_check(const char *command, const char *mode) + + fflush(NULL); + errno = 0; +- cmdfd = popen(command, mode); ++ cmdfd = pg_popen(command, mode); + if (cmdfd == NULL) + pg_log_error("could not execute command \"%s\": %m", command); + return cmdfd; +diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c +index fc160b0594..a638829ebf 100644 +--- a/src/bin/pg_ctl/pg_ctl.c ++++ b/src/bin/pg_ctl/pg_ctl.c +@@ -27,6 +27,7 @@ + #include "common/logging.h" + #include "common/string.h" + #include "getopt_long.h" ++#include "port/popen.h" + #include "utils/pidfile.h" + + #ifdef WIN32 /* on Unix, we don't need libpq */ +@@ -913,7 +914,7 @@ do_init(void) + exec_path, pgdata_opt, post_opts, DEVNULL); + + fflush(NULL); +- if (system(cmd) != 0) ++ if (pg_system(cmd) != 0) + { + write_stderr(_("%s: database system initialization failed\n"), progname); + exit(1); +diff --git a/src/common/Makefile b/src/common/Makefile +index 113029bf7b..372f8e4d7c 100644 +--- a/src/common/Makefile ++++ b/src/common/Makefile +@@ -70,6 +70,7 @@ OBJS_COMMON = \ + pg_lzcompress.o \ + pg_prng.o \ + pgfnames.o \ ++ popen.o \ + psprintf.o \ + relpath.o \ + rmtree.o \ +diff --git a/src/common/exec.c b/src/common/exec.c +index f209b934df..b1c6bc88e5 100644 +--- a/src/common/exec.c ++++ b/src/common/exec.c +@@ -42,6 +42,8 @@ + #endif + #endif + ++#include "port/popen.h" ++ + /* Inhibit mingw CRT's auto-globbing of command line arguments */ + #if defined(WIN32) && !defined(_MSC_VER) + extern int _CRT_glob = 0; /* 0 turns off globbing; 1 turns it on */ +@@ -367,7 +369,7 @@ pipe_read_line(char *cmd, char *line, int maxsize) + fflush(NULL); + + errno = 0; +- if ((pgver = popen(cmd, "r")) == NULL) ++ if ((pgver = pg_popen(cmd, "r")) == NULL) + { + perror("popen failure"); + return NULL; +@@ -400,7 +402,7 @@ pclose_check(FILE *stream) + int exitstatus; + char *reason; + +- exitstatus = pclose(stream); ++ exitstatus = pg_pclose(stream); + + if (exitstatus == 0) + return 0; /* all is well */ +diff --git a/src/common/popen.c b/src/common/popen.c +new file mode 100644 +index 0000000000..6e5393d33d +--- /dev/null ++++ b/src/common/popen.c +@@ -0,0 +1,224 @@ ++/* $OpenBSD: popen.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */ ++/* ++ * Copyright (c) 1988, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * This code is derived from software written by Ken Arnold and ++ * published in UNIX Review, Vol. 6, No. 8. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#include "postgres.h" ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "port/popen.h" ++#include "libpq/pqsignal.h" ++ ++static struct pid { ++ struct pid *next; ++ FILE *fp; ++ pid_t pid; ++} *pidlist; ++ ++FILE * ++pg_popen(const char *program, const char *type) ++{ ++ if (getenv("PGOVERRIDESTDSHELL") == NULL) ++ return popen(program, type); ++ ++ struct pid * volatile cur; ++ FILE *iop; ++ int pdes[2]; ++ pid_t pid; ++ char *shell = getenv("SHELL"); ++ if (shell == NULL) ++ shell = _PATH_BSHELL; ++ char *argp[] = {shell, "-c", NULL, NULL}; ++ char *dyld_library_path = getenv("DYLD_LIBRARY_PATH"); ++ ++ if (dyld_library_path == NULL) ++ dyld_library_path = ""; ++ ++ if ((*type != 'r' && *type != 'w') || type[1] != '\0') { ++ errno = EINVAL; ++ return (NULL); ++ } ++ ++ if ((cur = malloc(sizeof(struct pid))) == NULL) ++ return (NULL); ++ ++ if (pipe(pdes) < 0) { ++ free(cur); ++ return (NULL); ++ } ++ ++ switch (pid = fork()) { ++ case -1: /* Error. */ ++ (void)close(pdes[0]); ++ (void)close(pdes[1]); ++ free(cur); ++ return (NULL); ++ /* NOTREACHED */ ++ case 0: /* Child. */ ++ { ++ struct pid *pcur; ++ /* ++ * We fork()'d, we got our own copy of the list, no ++ * contention. ++ */ ++ for (pcur = pidlist; pcur; pcur = pcur->next) ++ close(fileno(pcur->fp)); ++ ++ if (*type == 'r') { ++ (void) close(pdes[0]); ++ if (pdes[1] != STDOUT_FILENO) { ++ (void)dup2(pdes[1], STDOUT_FILENO); ++ (void)close(pdes[1]); ++ } ++ } else { ++ (void)close(pdes[1]); ++ if (pdes[0] != STDIN_FILENO) { ++ (void)dup2(pdes[0], STDIN_FILENO); ++ (void)close(pdes[0]); ++ } ++ } ++ argp[2] = (char *)program; ++ execv(shell, argp); ++ _exit(127); ++ /* NOTREACHED */ ++ } ++ } ++ ++ /* Parent; assume fdopen can't fail. */ ++ if (*type == 'r') { ++ iop = fdopen(pdes[0], type); ++ (void)close(pdes[1]); ++ } else { ++ iop = fdopen(pdes[1], type); ++ (void)close(pdes[0]); ++ } ++ ++ /* Link into list of file descriptors. */ ++ cur->fp = iop; ++ cur->pid = pid; ++ cur->next = pidlist; ++ pidlist = cur; ++ ++ return (iop); ++} ++ ++/* ++ * shell_pclose -- ++ * Pclose returns -1 if stream is not associated with a `popened' command, ++ * if already `pclosed', or waitpid returns an error. ++ */ ++int ++pg_pclose(FILE *iop) ++{ ++ if (getenv("PGOVERRIDESTDSHELL") == NULL) ++ return pclose(iop); ++ ++ struct pid *cur, *last; ++ int pstat; ++ pid_t pid; ++ ++ /* Find the appropriate file pointer. */ ++ for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next) ++ if (cur->fp == iop) ++ break; ++ ++ if (cur == NULL) ++ return (-1); ++ ++ (void)fclose(iop); ++ ++ do { ++ pid = waitpid(cur->pid, &pstat, 0); ++ } while (pid == -1 && errno == EINTR); ++ ++ /* Remove the entry from the linked list. */ ++ if (last == NULL) ++ pidlist = cur->next; ++ else ++ last->next = cur->next; ++ free(cur); ++ ++ return (pid == -1 ? -1 : pstat); ++} ++ ++ ++int ++pg_system(const char *command) ++{ ++ if (getenv("PGOVERRIDESTDSHELL") == NULL) ++ return system(command); ++ ++ char *shell = getenv("SHELL"); ++ if (shell == NULL) ++ shell = _PATH_BSHELL; ++ ++ pid_t pid; ++ sig_t intsave, quitsave; ++ sigset_t mask, omask; ++ int pstat; ++ char *argp[] = {shell, "-c", NULL, NULL}; ++ ++ if (!command) /* just checking... */ ++ return(1); ++ ++ argp[2] = (char *)command; ++ ++ sigemptyset(&mask); ++ sigaddset(&mask, SIGCHLD); ++ sigprocmask(SIG_BLOCK, &mask, &omask); ++ switch (pid = vfork()) { ++ case -1: /* error */ ++ sigprocmask(SIG_SETMASK, &omask, NULL); ++ return(-1); ++ case 0: /* child */ ++ sigprocmask(SIG_SETMASK, &omask, NULL); ++ execv(shell, argp); ++ _exit(127); ++ } ++ ++ intsave = (sig_t) pqsignal(SIGINT, SIG_IGN); ++ quitsave = (sig_t) pqsignal(SIGQUIT, SIG_IGN); ++ pid = waitpid(pid, (int *)&pstat, 0); ++ sigprocmask(SIG_SETMASK, &omask, NULL); ++ (void)pqsignal(SIGINT, intsave); ++ (void)pqsignal(SIGQUIT, quitsave); ++ return (pid == -1 ? -1 : pstat); ++} +diff --git a/src/include/port/popen.h b/src/include/port/popen.h +new file mode 100644 +index 0000000000..423aff536b +--- /dev/null ++++ b/src/include/port/popen.h +@@ -0,0 +1,42 @@ ++/* ++ * Copyright (c) 1988, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * This code is derived from software written by Ken Arnold and ++ * published in UNIX Review, Vol. 6, No. 8. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#ifndef PG_POPEN_H ++#define PG_POPEN_H ++ ++#include ++ ++extern FILE *pg_popen(const char *program, const char *type); ++extern int pg_pclose(FILE *iop); ++extern int pg_system(const char *command); ++ ++#endif +-- +2.43.0 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-16.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-16.patch new file mode 100644 index 0000000..527df7a --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-16.patch @@ -0,0 +1,81 @@ +From 76cfbf8ac75fe68d7e3dbea77edbee7a3968b861 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Mon, 17 Oct 2022 16:32:14 -0700 +Subject: [PATCH 4/5] Make sure installation directories are predictable + +Remove attempts by Postgres to strip the trailing `postgresql` part of +the installation path if any of the prior path parts contain `postgres` +or `pgsql`. +--- + src/Makefile.global.in | 38 ++++++-------------------------------- + 1 file changed, 6 insertions(+), 32 deletions(-) + +diff --git a/src/Makefile.global.in b/src/Makefile.global.in +index cc4dc6de91..f15ca4fd85 100644 +--- a/src/Makefile.global.in ++++ b/src/Makefile.global.in +@@ -82,8 +82,7 @@ vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $ + # Installation directories + # + # These are set by the equivalent --xxxdir configure options. We +-# append "postgresql" to some of them, if the string does not already +-# contain "pgsql" or "postgres", in order to avoid directory clutter. ++# append "postgresql" to some of them. + # + # In a PGXS build, we cannot use the values inserted into Makefile.global + # by configure, since the installation tree may have been relocated. +@@ -100,46 +99,21 @@ datarootdir := @datarootdir@ + + bindir := @bindir@ + +-datadir := @datadir@ +-ifeq "$(findstring pgsql, $(datadir))" "" +-ifeq "$(findstring postgres, $(datadir))" "" +-override datadir := $(datadir)/postgresql +-endif +-endif ++datadir := @datadir@/postgresql + +-sysconfdir := @sysconfdir@ +-ifeq "$(findstring pgsql, $(sysconfdir))" "" +-ifeq "$(findstring postgres, $(sysconfdir))" "" +-override sysconfdir := $(sysconfdir)/postgresql +-endif +-endif ++sysconfdir := @sysconfdir@/postgresql + + libdir := @libdir@ + +-pkglibdir = $(libdir) +-ifeq "$(findstring pgsql, $(pkglibdir))" "" +-ifeq "$(findstring postgres, $(pkglibdir))" "" +-override pkglibdir := $(pkglibdir)/postgresql +-endif +-endif ++pkglibdir = $(libdir)/postgresql + + includedir := @includedir@ + +-pkgincludedir = $(includedir) +-ifeq "$(findstring pgsql, $(pkgincludedir))" "" +-ifeq "$(findstring postgres, $(pkgincludedir))" "" +-override pkgincludedir := $(pkgincludedir)/postgresql +-endif +-endif ++pkgincludedir = $(includedir)/postgresql + + mandir := @mandir@ + +-docdir := @docdir@ +-ifeq "$(findstring pgsql, $(docdir))" "" +-ifeq "$(findstring postgres, $(docdir))" "" +-override docdir := $(docdir)/postgresql +-endif +-endif ++docdir := @docdir@/postgresql + + htmldir := @htmldir@ + +-- +2.43.0 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-16.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-16.patch new file mode 100644 index 0000000..76ad61f --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-16.patch @@ -0,0 +1,204 @@ +From 71f8c17c2ebbe2dc2a4ccc8058bdfa4a0bccefb4 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Fri, 15 Jul 2022 16:44:07 -0700 +Subject: [PATCH 1/5] Add a workaround for WSL1 signal mishandling + +WSL1 appears to mishandle `signal(..., SIG_IGN)` followed by +`sigprocmask`, which leads to `SetLatch` being completely broken because +`SIGURG` ends up being ignored instead of blocked and forwarded via +`signalfd`. + +See https://github.com/microsoft/WSL/issues/8619 +--- + configure | 2 +- + configure.ac | 1 + + src/backend/postmaster/postmaster.c | 34 +++++++++++++++++++++++++++++ + src/backend/storage/ipc/latch.c | 4 ++++ + src/backend/utils/init/globals.c | 5 +++++ + src/backend/utils/init/miscinit.c | 1 + + src/include/miscadmin.h | 1 + + src/include/pg_config.h.in | 3 +++ + src/include/postmaster/postmaster.h | 1 + + src/tools/msvc/Solution.pm | 1 + + 10 files changed, 52 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index cbc1ebfc61..7279c98da0 100755 +--- a/configure ++++ b/configure +@@ -13756,7 +13756,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h + fi + + +-for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/ucred.h termios.h ucred.h ++for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/ucred.h sys/utsname.h termios.h ucred.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +diff --git a/configure.ac b/configure.ac +index 69b2bbb576..e50ef69f82 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1507,6 +1507,7 @@ AC_CHECK_HEADERS(m4_normalize([ + sys/procctl.h + sys/signalfd.h + sys/ucred.h ++ sys/utsname.h + termios.h + ucred.h + ])) +diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c +index b42aae41fc..5cf77ff0f4 100644 +--- a/src/backend/postmaster/postmaster.c ++++ b/src/backend/postmaster/postmaster.c +@@ -77,6 +77,10 @@ + #include + #include + ++#ifdef HAVE_SYS_UTSNAME_H ++#include ++#endif ++ + #ifdef USE_BONJOUR + #include + #endif +@@ -1186,6 +1190,11 @@ PostmasterMain(int argc, char *argv[]) + ereport(LOG, + (errmsg("starting %s", PG_VERSION_STR))); + ++ IsUnderWSL1 = DetectWSL1(); ++ if (IsUnderWSL1) ++ ereport(LOG, ++ (errmsg("detected WSL1, applying workarounds"))); ++ + /* + * Establish input sockets. + */ +@@ -2684,6 +2693,31 @@ InitProcessGlobals(void) + } + + /* ++ * DetectWSL1 -- detect if we are running under WSL1 ++ */ ++bool ++DetectWSL1(void) ++{ ++#ifdef HAVE_SYS_UTSNAME_H ++ int rc; ++ struct utsname buf; ++ ++ memset(&buf, 0, sizeof buf); ++ rc = uname(&buf); ++ if (rc != 0) { ++ ereport(WARNING, ++ (errmsg("could not determine current kernel release version"))); ++ return false; ++ } else { ++ return pg_str_endswith(buf.release, "-Microsoft"); ++ } ++#else ++ return false; ++#endif ++} ++ ++/* ++ * reset_shared -- reset shared memory and semaphores + * Child processes use SIGUSR1 to notify us of 'pmsignals'. pg_ctl uses + * SIGUSR1 to ask postmaster to check for logrotate and promote files. + */ +diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c +index cdb95c1931..afc69de8a3 100644 +--- a/src/backend/storage/ipc/latch.c ++++ b/src/backend/storage/ipc/latch.c +@@ -309,6 +309,10 @@ InitializeLatchSupport(void) + if (signal_fd < 0) + elog(FATAL, "signalfd() failed"); + ReserveExternalFD(); ++ ++ if (IsUnderWSL1) ++ /* Workaround https://github.com/microsoft/WSL/issues/8619 */ ++ pqsignal(SIGURG, SIG_DFL); + #endif + + #ifdef WAIT_USE_KQUEUE +diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c +index 011ec18015..505f89ab7b 100644 +--- a/src/backend/utils/init/globals.c ++++ b/src/backend/utils/init/globals.c +@@ -114,6 +114,11 @@ bool IsUnderPostmaster = false; + bool IsBinaryUpgrade = false; + bool IsBackgroundWorker = false; + ++/* ++ * Whether we are running under WSL1, for various workarounds. ++ */ ++bool IsUnderWSL1 = false; ++ + bool ExitOnAnyError = false; + + int DateStyle = USE_ISO_DATES; +diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c +index b0ca61a8d6..e2e1710466 100644 +--- a/src/backend/utils/init/miscinit.c ++++ b/src/backend/utils/init/miscinit.c +@@ -130,6 +130,7 @@ InitPostmasterChild(void) + /* In EXEC_BACKEND case we will not have inherited BlockSig etc values */ + #ifdef EXEC_BACKEND + pqinitmask(); ++ IsUnderWSL1 = DetectWSL1(); + #endif + + /* Initialize process-local latch support */ +diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h +index 14bd574fc2..8bf5413b3b 100644 +--- a/src/include/miscadmin.h ++++ b/src/include/miscadmin.h +@@ -166,6 +166,7 @@ extern PGDLLIMPORT bool IsPostmasterEnvironment; + extern PGDLLIMPORT bool IsUnderPostmaster; + extern PGDLLIMPORT bool IsBackgroundWorker; + extern PGDLLIMPORT bool IsBinaryUpgrade; ++extern PGDLLIMPORT bool IsUnderWSL1; + + extern PGDLLIMPORT bool ExitOnAnyError; + +diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in +index 174544630e..c2e27b5416 100644 +--- a/src/include/pg_config.h.in ++++ b/src/include/pg_config.h.in +@@ -478,6 +478,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_UCRED_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_UTSNAME_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_TERMIOS_H + +diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h +index 3b3889c58c..428777a41b 100644 +--- a/src/include/postmaster/postmaster.h ++++ b/src/include/postmaster/postmaster.h +@@ -53,6 +53,7 @@ extern PGDLLIMPORT const char *progname; + extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn(); + extern void ClosePostmasterPorts(bool am_syslogger); + extern void InitProcessGlobals(void); ++extern bool DetectWSL1(void); + + extern int MaxLivePostmasterChildren(void); + +diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm +index 711fae853f..9e67013288 100644 +--- a/src/tools/msvc/Solution.pm ++++ b/src/tools/msvc/Solution.pm +@@ -355,6 +355,7 @@ sub GenerateFiles + HAVE_SYS_STAT_H => 1, + HAVE_SYS_TYPES_H => 1, + HAVE_SYS_UCRED_H => undef, ++ HAVE_SYS_UTSNAME_H => undef, + HAVE_TERMIOS_H => undef, + HAVE_TYPEOF => undef, + HAVE_UCRED_H => undef, +-- +2.43.0 + diff --git a/integration/linux/build/linux-aarch64/Dockerfile b/integration/linux/build/linux-aarch64/Dockerfile index 806e489..b980b5f 100644 --- a/integration/linux/build/linux-aarch64/Dockerfile +++ b/integration/linux/build/linux-aarch64/Dockerfile @@ -24,7 +24,7 @@ ENV GO_VERSION 1.21.6 ENV RUST_VERSION 1.76.0 ENV NODE_VERSION 16.16.0 ENV YARN_VERSION 1.22.19 -ENV GCC_VERSION 11 +ENV GCC_VERSION 10 # rpm on centos 7 iterates over all fds up to the limit, which is # extremely slow. Force it to be small.