Onigmo config.h clash with nghttp2 breaks building with GCC 14+
TL;DR: Fluentbit's use of CMake include_directories causes a wide set of include paths to be used for all compilation (even of libraries), which can cause config.h files in different libraries to shadow each other. See:
https://github.com/fluent/fluent-bit/blob/067c0642fe67b82621b3b7b0f60a994c3e579e5b/cmake/headers.cmake#L9-L47
GCC 14+ now reports various checks that were previously warnings as errors, so some issues associated with this shadowing are now actually causing the normal build to fail.
CMake docs recommend using target_include_directories() instead which scopes includes only to the targets that need them: https://cmake.org/cmake/help/latest/command/include_directories.html
I've been running into issues building Fluentbit v4.0.x on Arch Linux, which currently comes with GCC 15.
> cmake --version
cmake version 4.0.2-dirty
CMake suite maintained and supported by Kitware (kitware.com/cmake).
> /usr/bin/cc --version
cc (GCC) 15.1.1 20250425
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The root of it all seems to be that GCC 14+ enforces stricter checks on some common C pitfalls by making several checks that were previously only warnings now errors by default - see https://gcc.gnu.org/gcc-14/porting_to.html#warnings-as-errors
The main first issue I have run into is that nghttp2 fails to build with the following errors:
[ 25%] Building C object lib/nghttp2-1.65.0/lib/CMakeFiles/nghttp2_static.dir/nghttp2_helper.c.o
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c: In function ‘nghttp2_put_uint16be’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:33:16: error: implicit declaration of function ‘htons’ [-Wimplicit-function-declaration]
33 | uint16_t x = htons(n);
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:33:16: warning: nested extern declaration of ‘htons’ [-Wnested-externs]
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:33:16: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c: In function ‘nghttp2_put_uint32be’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:38:16: error: implicit declaration of function ‘htonl’ [-Wimplicit-function-declaration]
38 | uint32_t x = htonl(n);
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:38:16: warning: nested extern declaration of ‘htonl’ [-Wnested-externs]
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:38:16: warning: conversion to ‘uint32_t’ {aka ‘unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c: In function ‘nghttp2_get_uint16’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:45:10: error: implicit declaration of function ‘ntohs’ [-Wimplicit-function-declaration]
45 | return ntohs(n);
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:45:10: warning: nested extern declaration of ‘ntohs’ [-Wnested-externs]
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:45:10: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
45 | return ntohs(n);
| ^~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c: In function ‘nghttp2_get_uint32’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:51:10: error: implicit declaration of function ‘ntohl’ [-Wimplicit-function-declaration]
51 | return ntohl(n);
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:51:10: warning: nested extern declaration of ‘ntohl’ [-Wnested-externs]
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/nghttp2-1.65.0/lib/nghttp2_helper.c:51:10: warning: conversion to ‘uint32_t’ {aka ‘unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
51 | return ntohl(n);
| ^~~~~~~~
make[2]: *** [lib/nghttp2-1.65.0/lib/CMakeFiles/nghttp2_static.dir/build.make:205: lib/nghttp2-1.65.0/lib/CMakeFiles/nghttp2_static.dir/nghttp2_helper.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:6178: lib/nghttp2-1.65.0/lib/CMakeFiles/nghttp2_static.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
I've been digging into this on nghttp2/nghttp2#2195 and it seems the issue in Fluentbit's context is that the config.h from Onigmo ends up shadowing the config.h include that nghttp2 expects to reference its own generated config.h file, because of the global expanded include directory list that gets used for all compilation. This leads to some #defines not getting defined properly and leading to the required netdb headers not being included properly.
Presumably this was somehow working regardless before GCC 14 - but with implicit function declarations specifically being one of the things bumped to an error, it now breaks the build.
Have also raised #10463 for another GCC 14+ issue
I confirmed your experiments about nghttp2 in Arch Linux WSL2 box. Yeah, it's totally correct. Just compiling nghttp2 itself does not have implicit function issues. So, we need to handle/create somewhat isolated or quarantined header environment for onigmo.
The implicit function issue should be resolved by https://github.com/fluent/fluent-bit/pull/10517.
Done by #10517. Another onigmo issue should be resolved by syncing onigmo which contains https://github.com/fluent/onigmo/pull/8.
Thanks Hiroshi. I got some of the way through doing more target_include_directories() housekeeping for some of the other libraries, if I get time I'll send a PR for them