pgpool / pgpool2

This is the official mirror of git://git.postgresql.org/git/pgpool2.git. Note that this is just a *mirror* - we don't work with pull requests on github. Please subscribe to pgpool-hackers mailing list from our website and submit your patch to this mailing list.
https://www.pgpool.net
Other
323 stars 88 forks source link

build fails on 32bit arm systems #63

Open sudipm-mukherjee opened 1 month ago

sudipm-mukherjee commented 1 month ago

I tried to build v4.5.2 on an armhf system. Its trying to build the replacement snprintf and failing.

This are the build errors:

snprintf.c:409:1: error: conflicting types for 'strchrnul'; have 'const char *(const char *, int)'
  409 | strchrnul(const char *s, int c)
      | ^~~~~~~~~
In file included from snprintf.c:43:
/usr/include/string.h:286:14: note: previous declaration of 'strchrnul' with type 'char *(const char *, int)'
  286 | extern char *strchrnul (const char *__s, int __c)
      |              ^~~~~~~~~
snprintf.c: In function 'dopr':
snprintf.c:770:64: error: 'PG_STRERROR_R_BUFLEN' undeclared (first use in this function)
  770 |                                         char            errbuf[PG_STRERROR_R_BUFLEN];
      |                                                                ^~~~~~~~~~~~~~~~~~~~
snprintf.c:770:64: note: each undeclared identifier is reported only once for each function it appears in
snprintf.c:770:57: warning: unused variable 'errbuf' [-Wunused-variable]
  770 |                                         char            errbuf[PG_STRERROR_R_BUFLEN];
      |                                                         ^~~~~~
snprintf.c: In function 'fmtfloat':
snprintf.c:1231:13: error: implicit declaration of function 'isnan' [-Wimplicit-function-declaration]
 1231 |         if (isnan(value))
      |             ^~~~~
snprintf.c:49:1: note: include '<math.h>' or provide a declaration of 'isnan'
   48 | #include "utils/palloc.h"
  +++ |+#include <math.h>
   49 | 
snprintf.c:1253:21: error: implicit declaration of function 'isinf' [-Wimplicit-function-declaration]
 1253 |                 if (isinf(value))
      |                     ^~~~~
snprintf.c:1253:21: note: include '<math.h>' or provide a declaration of 'isinf'

This is the output from ./configure.

$ ./configure 
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... armv7l-unknown-linux-gnueabihf
checking host system type... armv7l-unknown-linux-gnueabihf
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert armv7l-unknown-linux-gnueabihf file names to armv7l-unknown-linux-gnueabihf format... func_convert_file_noop
checking how to convert armv7l-unknown-linux-gnueabihf file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... none needed
checking whether yytext is a pointer... no
checking for bison... bison -y
checking whether gcc and cc understand -c and -o together... yes
checking for onsgmls... onsgmls
checking for openjade... openjade
checking for DocBook V4.2... yes
checking for DocBook stylesheets... /usr/share/sgml/docbook/stylesheet/dsssl/modular
checking for collateindex.pl... /usr/bin/collateindex.pl
checking for xsltproc... xsltproc
checking for xmllint... xmllint
checking for osx... osx
checking for perl... perl
checking for lynx... no
checking for sunifdef... no
checking for -Wall option... yes
checking for -Wmissing-prototypes option... yes
checking for -Wmissing-declarations option... yes
checking for main in -lm... yes
checking for main in -lnsl... no
checking for main in -lsocket... no
checking for main in -lipc... no
checking for main in -lIPC... no
checking for main in -llc... no
checking for main in -lBSD... no
checking for main in -lgen... no
checking for main in -lPW... no
checking for main in -lresolv... yes
checking for main in -lcrypt... yes
checking for strlcat,... no
checking for strlcpy... yes
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking netinet/tcp.h usability... yes
checking netinet/tcp.h presence... yes
checking for netinet/tcp.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for sys/types.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/un.h usability... yes
checking sys/un.h presence... yes
checking for sys/un.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/sem.h usability... yes
checking sys/sem.h presence... yes
checking for sys/sem.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking crypt.h usability... yes
checking crypt.h presence... yes
checking for crypt.h... yes
checking sys/pstat.h usability... no
checking sys/pstat.h presence... no
checking for sys/pstat.h... no
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for snprintf... yes
checking for vsnprintf... yes
checking whether long int is 64 bits... no
checking whether long long int is 64 bits... yes
checking snprintf format for long long int... none
checking whether gcc supports -Wformat-truncation, for NOT_THE_CFLAGS... yes
checking whether gcc supports -Wstringop-truncation, for NOT_THE_CFLAGS... yes
checking size of unsigned long... 4
checking size of void *... 4
checking size of size_t... 4
checking whether to build with float4 passed by value... yes
checking whether to build with float8 passed by value... no
checking for struct sockaddr_storage... yes
checking for struct sockaddr_storage.ss_family... yes
checking for struct sockaddr_storage.__ss_family... no
checking for struct sockaddr_storage.ss_len... no
checking for struct sockaddr_storage.__ss_len... no
checking for struct sockaddr.sa_len... no
checking for union semun... no
checking return type of signal handlers... void
checking for vprintf... yes
checking for _doprnt... no
checking for wait3 that fills in rusage... yes
checking types of arguments for accept()... int, int, struct sockaddr *, size_t *
checking for setsid... yes
checking for select... yes
checking for socket... yes
checking for sigprocmask... yes
checking for strdup... yes
checking for strerror... yes
checking for strftime... yes
checking for strtok... yes
checking for asprintf... yes
checking for vasprintf... yes
checking for gai_strerror... yes
checking for hstrerror... yes
checking for pstat... no
checking for setproctitle... no
checking for syslog... yes
checking for __builtin_types_compatible_p... yes
checking for pg_config... pg_config
checking for PQexecPrepared in -lpq... yes
checking for PQprepare... yes
checking for PQpingParams... yes
checking whether to use row lock against the sequence table for insert_lock... no
checking whether to use table lock against the target table for insert_lock... no
enable cassert = no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating doc/src/Makefile
config.status: creating doc/src/sgml/Makefile
config.status: creating doc.ja/Makefile
config.status: creating doc.ja/src/Makefile
config.status: creating doc.ja/src/sgml/Makefile
config.status: creating src/Makefile
config.status: creating src/include/Makefile
config.status: creating src/parser/Makefile
config.status: creating src/libs/Makefile
config.status: creating src/libs/pcp/Makefile
config.status: creating src/tools/Makefile
config.status: creating src/tools/pgmd5/Makefile
config.status: creating src/tools/pgenc/Makefile
config.status: creating src/tools/pcp/Makefile
config.status: creating src/tools/pgproto/Makefile
config.status: creating src/tools/watchdog/Makefile
config.status: creating src/watchdog/Makefile
config.status: creating src/include/config.h
config.status: executing libtool commands

I will be happy to provide more logs or test any patch if needed.

sudipm-mukherjee commented 1 month ago

I have added the following change, not sure if that is correct.

diff --git a/src/parser/snprintf.c b/src/parser/snprintf.c
index 0e5283947..68e93ba78 100644
--- a/src/parser/snprintf.c
+++ b/src/parser/snprintf.c
@@ -43,9 +43,11 @@
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
+#include <math.h>
 #include "pool_parser.h"
 #include "stringinfo.h"
 #include "utils/palloc.h"
+#include "postgresql/16/server/postgres_fe.h"

 /*
  * We used to use the platform's NL_ARGMAX here, but that's a bad idea,

and building with make CFLAGS='-DHAVE_STRCHRNUL' the previous errors are fixed. But now it fails with:

wd_json_data.c: In function 'get_watchdog_node_from_json':
wd_json_data.c:540:66: error: passing argument 3 of 'json_get_long_value_for_key' from incompatible pointer type [-Wincompatible-pointer-types]
  540 |         if (json_get_long_value_for_key(root, "StartupTimeSecs", &wdNode->startup_time.tv_sec))
      |                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                  |
      |                                                                  __time64_t * {aka long long int *}
In file included from wd_json_data.c:28:
../../src/include/utils/json.h:316:97: note: expected 'long int *' but argument is of type '__time64_t *' {aka 'long long int *'}
  316 | int                     json_get_long_value_for_key(json_value * source, const char *key, long *value);
      |                       

I must mention this is with gcc-14.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/arm-linux-gnueabihf/14/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 14.2.0-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-14 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv7-a+fp --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Ubuntu 14.2.0-1ubuntu1)