GOTCHA 1.0.10 fails to build with gcc 14 on glibc 2.34 or newer: getpagesize is undeclared
Symptom#
Building brahma or GOTCHA v1.0.10 in a manylinux_2_34 container (gcc 14) stops with src/libc_wrappers.h:42:28: error: implicit declaration of function 'getpagesize' [-Wimplicit-function-declaration], in create_hashtable in hash.c. The same source builds on manylinux_2_28 and on Ubuntu 24.04 (gcc 13).
Cause#
GOTCHA's CMake compiles with -D_POSIX_C_SOURCE=200809L. glibc 2.34's unistd.h declares getpagesize only under __USE_MISC || !__USE_XOPEN2K, so it is not declared in that mode, and gcc 14 makes an implicit declaration an error. The function is still exported by libc.
Fix#
Declare it in GOTCHA's src/libc_wrappers.h: replace #define gotcha_getpagesize getpagesize with extern int getpagesize(void); plus the same define. Apply it as an idempotent patch, for brahma with PATCH_COMMAND ${CMAKE_COMMAND} -P cmake/patches/gotcha_pagesize.cmake in fetch_package, and with sed after the clone for a standalone GOTCHA build. Do not use these: #include <unistd.h> (the macro setting still hides the declaration), -include unistd.h (runs before GOTCHA's _GNU_SOURCE and breaks struct dl_phdr_info), and sysconf(_SC_PAGESIZE) (brahma intercepts sysconf; the test crashed at startup).
Evidence#
With the extern declaration brahma builds and test_posix passes on manylinux_2_34 (gcc 14) and manylinux_2_28, Release and Debug, aarch64 and x86_64; dftracer's scripts/wheel/build_deps.sh also builds all five dependencies on manylinux_2_34. A -Wno-error=implicit-function-declaration flag also works but only hides the error.
Also found by searching
- error: implicit declaration of function 'getpagesize' libc_wrappers.h gotcha
- gotcha build fails manylinux_2_34 gcc 14
- Wno-error=implicit-function-declaration gotcha hash.c
- brahma cannot fetch and build gotcha on glibc 2.34