From 855efb94214cc519805de89934d82bc5e0f92685 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 28 Nov 2023 18:29:18 +0300 Subject: Release version 14.1.0+2 Add psql package. Don't compile port/strlcpy.c on Linux if GNU libc is 2.38 or newer. Switch to using -pthread instead of -D_REENTRANT/-lpthread in buildfiles and bump build2 version requirement to 0.15.0. --- libpq/.gitignore | 1 + libpq/README-DEV | 23 ++++++------ libpq/build/export.build | 2 +- libpq/libpq/buildfile | 21 ++++++----- libpq/libpq/pg_config.h | 93 ++++++++++++++++++++++++++++++++++++++++++------ libpq/libpq/strlcpy.c | 6 ++++ libpq/manifest | 8 ++--- 7 files changed, 117 insertions(+), 37 deletions(-) create mode 100644 libpq/libpq/strlcpy.c (limited to 'libpq') diff --git a/libpq/.gitignore b/libpq/.gitignore index 3dcc22f..d4a1da2 100644 --- a/libpq/.gitignore +++ b/libpq/.gitignore @@ -13,6 +13,7 @@ *.ifc *.so *.so.* +*.dylib *.dll *.a *.lib diff --git a/libpq/README-DEV b/libpq/README-DEV index 0a204c4..6ccf1cc 100644 --- a/libpq/README-DEV +++ b/libpq/README-DEV @@ -4,8 +4,8 @@ understanding will be useful when upgrading to a new upstream version. See The upstream package builds the common and ports static libraries and links them to the libpq library. These static libraries are generic enough to fit -all the binaries built by the package. We will build libpq selecting only the -required static libraries source files, relying on the linker diagnostics +all the binaries built by the package. We will build libpq by only selecting +the required static libraries source files, relying on the linker diagnostics (unresolved symbol errors, etc). Symlink the required upstream components and provide our own implementations @@ -19,26 +19,27 @@ directory prefixes. $ ln -s ../../upstream/src/interfaces/libpq libpq/pq -Note that while we could symlink the upstream's top source directories, this -would potentially bloat the distribution, uglify the buildfile, and complicate -pg_config.h change tracking on upgrade (see below). Thus, we selectively -symlink only the required files. +Note that symlinking all the upstream's top source directories is a bad idea +since this would potentially bloat the distribution, uglify the buildfile, and +complicate pg_config.h change tracking on upgrade (see below). Also note that +some of the source files are shared with the psql package and this sharing +doesn't align with such an approach. Thus, we selectively symlink only the +required files. $ mkdir -p libpq/include/libpq libpq/include/mb libpq/include/port $ ln -s ../../../upstream/src/include/{c,getaddrinfo,pg_config_manual,port,postgres_ext,postgres_fe}.h libpq/include +$ ln -s ../../../upstream/src/include/common libpq/include $ ln -s ../../../../upstream/src/include/libpq/{libpq-fs,pqcomm}.h libpq/include/libpq $ ln -s ../../../../upstream/src/include/mb/pg_wchar.h libpq/include/mb $ ln -s ../../../../upstream/src/include/port/{linux,freebsd,darwin,win32,win32_port,pg_bswap}.h libpq/include/port $ ln -s ../../../../upstream/src/include/port/{win32,win32_msvc} libpq/include/port $ mkdir libpq/common -$ ln -s ../../../upstream/src/common/{base64,cryptohash_openssl,encnames,hmac_openssl,ip,link-canary,md5,md5_common,saslprep,scram-common,string,unicode_norm,wchar}.c \ - libpq/common +$ ln -s ../../../upstream/src/common/{base64,cryptohash_openssl,encnames,hmac_openssl,ip,link-canary,md5,md5_common,saslprep,scram-common,string,unicode_norm,wchar}.c libpq/common $ ln -s ../../../upstream/src/common/md5_int.h libpq/common $ mkdir libpq/port -$ ln -s ../../../upstream/src/port/{chklocale,explicit_bzero,getaddrinfo,getpeereid,gettimeofday,inet_aton,inet_net_ntop,noblock,open,pg_strong_random,pgsleep,pgstrcasecmp,snprintf,strerror,strlcpy,system,thread,win32error,win32setlocale,win32stat}.c \ - libpq/port +$ ln -s ../../../upstream/src/port/{chklocale,explicit_bzero,getaddrinfo,getpeereid,gettimeofday,inet_aton,inet_net_ntop,noblock,open,pg_strong_random,pgsleep,pgstrcasecmp,snprintf,strerror,strlcpy,system,thread,win32error,win32setlocale,win32stat}.c libpq/port $ ln -s ../../../upstream/src/port/pthread-win32.h libpq/port $ ln -s ../../upstream/src/include/pg_config_ext.h.in libpq/pg_config_ext.h.in.orig @@ -58,7 +59,7 @@ macro sets: $ for m in `cat libpq/pg_config.h.in.orig | \ sed -n 's/^.*#\s*\(define\|undef\)\s\{1,\}\([_A-Z0-9]\{1,\}\)\(\s.*\)\{0,1\}$/\2/p' | \ sort -u`; do - if grep -q -e "\b$m\b" `find -L . -name '*.h' -a ! -name 'pg_config.h' -o -name '*.c'`; then + if grep -q -e "\b$m\b" `find -L . ../psql -name '*.h' -a ! -name 'pg_config.h' -o -name '*.c'`; then echo "$m" fi done >used-macros diff --git a/libpq/build/export.build b/libpq/build/export.build index bb54707..6c8c87c 100644 --- a/libpq/build/export.build +++ b/libpq/build/export.build @@ -6,4 +6,4 @@ $out_root/ include libpq/ } -export $out_root/libpq/lib{pq} +export $out_root/libpq/$import.target diff --git a/libpq/libpq/buildfile b/libpq/libpq/buildfile index 413583c..94fa06b 100644 --- a/libpq/libpq/buildfile +++ b/libpq/libpq/buildfile @@ -44,7 +44,13 @@ windows = ($tclass == 'windows') # lib{pq}: port/c{explicit_bzero}: include = (!$bsd) lib{pq}: port/c{gettimeofday}: include = ($tsys == 'win32-msvc') -lib{pq}: port/c{strlcpy}: include = (!$bsd && !$macos) + +# Note that we never compile port/strlcpy.c directly but rather conditionally +# include it from our strlcpy.c if HAVE_DECL_STRLCAT is 0 (see +# libpq/pg_config.h for the macro definition). +# +lib{pq}: port/c{strlcpy}: include = adhoc +lib{pq}: c{strlcpy}: include = (!$bsd && !$macos) lib{pq}: pq/{h c}{*win32* } \ port/{h c}{*win32* +getaddrinfo +inet_aton}: include = $windows @@ -84,14 +90,7 @@ h{version}: in{version} $src_root/manifest # c.poptions += -DFRONTEND -DUNSAFE_STAT_OK -DSO_MAJOR_VERSION=$abi_major -if! $windows - # Note that the upstream package uses the -pthread compiler/linker option. - # The option is unsupported by build2 so we pass -D_REENTRANT and -lpthread - # preprocessor/linker options instead. We also omit -D_THREAD_SAFE (synonym - # for -D_REENTRANT) and Solaris-specific -D_POSIX_PTHREAD_SEMANTICS. - # - c.poptions += -D_REENTRANT -else +if $windows # Note that the upstream package defines the WIN32 macro for VC only, # relying on the fact that MinGW GCC defines it by default. However, the # macro disappears from the default ones if to compile with -std=c9x (as we @@ -237,11 +236,11 @@ switch $tclass, $tsys c.loptions += "-Wl,--version-script=$out_base/libpqdll.map" - c.libs += -lpthread + c.libs += -pthread } default - c.libs += -lpthread + c.libs += -pthread } # Export options. diff --git a/libpq/libpq/pg_config.h b/libpq/libpq/pg_config.h index c834880..e0e61ad 100644 --- a/libpq/libpq/pg_config.h +++ b/libpq/libpq/pg_config.h @@ -15,14 +15,23 @@ #include /* offsetof() */ +#if defined(__linux__) +# include /* __GLIBC__, __GLIBC_MINOR__ */ +#endif + #include /* OPENSSL_VERSION_NUMBER */ +#define PACKAGE_NAME "PostgreSQL" +#define PACKAGE_URL "https://www.postgresql.org/" +#define PACKAGE_BUGREPORT "pgsql-bugs@lists.postgresql.org" + /* * Version. */ #undef PG_VERSION #undef PG_VERSION_NUM #undef PG_MAJORVERSION +#undef PG_VERSION_STR #include /* @@ -110,6 +119,22 @@ #define INT64_MODIFIER "ll" /* + * GNU libc added strlcpy() and strlcat() in version 2.38 (in anticipation + * of their addition to POSIX). + */ +#if defined(__FreeBSD__) || \ + defined(__APPLE__) || \ + (defined(__GLIBC__) && \ + defined(__GLIBC_MINOR__) && \ + (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 38)) +# define HAVE_DECL_STRLCAT 1 +# define HAVE_DECL_STRLCPY 1 +#else +# define HAVE_DECL_STRLCAT 0 +# define HAVE_DECL_STRLCPY 0 +#endif + +/* * Specific for FreeBSD. */ #ifdef __FreeBSD__ @@ -142,8 +167,6 @@ * Specific for FreeBSD and Mac OS. */ #if defined(__FreeBSD__) || defined(__APPLE__) -# define HAVE_DECL_STRLCAT 1 -# define HAVE_DECL_STRLCPY 1 # define STRERROR_R_INT 1 # define HAVE_FLS 1 # define HAVE_GETPEEREID 1 @@ -154,9 +177,7 @@ # define HAVE_SYS_UCRED_H 1 # define HAVE_UNION_SEMUN 1 # define HAVE_MEMSET_S 1 -#else -# define HAVE_DECL_STRLCAT 0 -# define HAVE_DECL_STRLCPY 0 +# define HAVE_INT_OPTRESET 1 #endif /* @@ -190,6 +211,8 @@ # define HAVE_PWRITE 1 # define HAVE_LINK 1 # define HAVE_STRUCT_SOCKADDR_UN 1 +# define HAVE_READLINK 1 +# define HAVE_STRSIGNAL 1 /* * Specific for Windows. @@ -224,6 +247,12 @@ # define HAVE__BUILTIN_BSWAP64 1 # define HAVE__BUILTIN_OP_OVERFLOW 1 # define HAVE_SETENV 1 +# define HAVE_CLOCK_GETTIME 1 +# define HAVE_GETOPT 1 +# define HAVE_GETOPT_H 1 +# define HAVE_GETOPT_LONG 1 +# define HAVE_INT_OPTERR 1 +# define HAVE_STRUCT_OPTION 1 /* * _Static_assert() was introduced in C11. However, all the latest major @@ -288,11 +317,7 @@ #undef ENABLE_GSS #undef USE_LDAP -/* - * Is meaningless if NLS support is disabled (see above and libpq/buildfile for - * details). - */ -#undef LOCALEDIR +#undef HAVE_LIBREADLINE /* * Is meaningless if GSSAPI support is disabled (see above). It also seems that @@ -355,4 +380,52 @@ #undef HAVE___STRTOLL #undef HAVE___STRTOULL +/* + * None of the supported platforms provides append_history(). + */ +#undef HAVE_APPEND_HISTORY + +/* + * None of the supported OSes have or + * . + */ +#undef HAVE_EDITLINE_HISTORY_H +#undef HAVE_EDITLINE_READLINE_H + +/* + * None of the supported OSes have . + */ +#undef HAVE_HISTORY_H +#undef HAVE_HISTORY_TRUNCATE_FILE + +/* + * None of the supported OSes have , , or + * . + */ +#undef HAVE_READLINE_H +#undef HAVE_READLINE_HISTORY_H +#undef HAVE_READLINE_READLINE_H + +/* + * None of the supported platforms provides rl_completion_append_character and + * rl_completion_suppress_quote global variables and rl_completion_matches(). + */ +#undef HAVE_RL_COMPLETION_APPEND_CHARACTER +#undef HAVE_RL_COMPLETION_MATCHES +#undef HAVE_RL_COMPLETION_SUPPRESS_QUOTE + +/* + * None of the supported platforms provides rl_filename_quote_characters and + * rl_filename_quoting_function global variables and + * rl_filename_completion_function(). + */ +#undef HAVE_RL_FILENAME_COMPLETION_FUNCTION +#undef HAVE_RL_FILENAME_QUOTE_CHARACTERS +#undef HAVE_RL_FILENAME_QUOTING_FUNCTION + +/* + * None of the supported platforms provides rl_reset_screen_size(). + */ +#undef HAVE_RL_RESET_SCREEN_SIZE + #define pg_restrict __restrict diff --git a/libpq/libpq/strlcpy.c b/libpq/libpq/strlcpy.c new file mode 100644 index 0000000..2dd9f29 --- /dev/null +++ b/libpq/libpq/strlcpy.c @@ -0,0 +1,6 @@ +/* file : libpq/strlcpy.c -*- C -*- + * license : PostgreSQL License; see accompanying COPYRIGHT file + */ +#if !HAVE_DECL_STRLCPY +# include +#endif diff --git a/libpq/manifest b/libpq/manifest index da81144..a71dc42 100644 --- a/libpq/manifest +++ b/libpq/manifest @@ -3,7 +3,7 @@ name: libpq # Note: remember to update doc-url below! # -version: 14.1.0+1 +version: 14.1.0+2 upstream-version: 14.1 project: postgresql @@ -15,12 +15,12 @@ url: https://www.postgresql.org/ doc-url: https://www.postgresql.org/docs/14/libpq.html src-url: https://git.build2.org/cgit/packaging/postgresql/postgresql/tree/libpq/ package-url: https://git.build2.org/cgit/packaging/postgresql/ -email: pgsql-general@postgresql.org ; Mailing list. +email: pgsql-general@lists.postgresql.org ; Mailing list. package-email: packaging@build2.org ; Mailing list. build-warning-email: builds@build2.org builds: all builds: -wasm -depends: * build2 >= 0.13.0 -depends: * bpkg >= 0.13.0 +depends: * build2 >= 0.15.0 +depends: * bpkg >= 0.15.0 depends: libcrypto >= 1.1.1 depends: libssl >= 1.1.1 -- cgit v1.1