fluent-bit
fluent-bit copied to clipboard
Onigmo building fails on GCC 14+ due to pointer mismatch errors
Building Onigmo fails on current Arch Linux, which uses 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 issue seems to consist of:
- incompatible pointer types
- "too many arguments to function" errors - from pointer-based function calls having mismatching argument counts (presumably due to the function pointer types not being specific enough)
On a clean build, we see point 1) show up:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c: In function ‘onig_st_init_strend_table_with_size’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:409:5: error: initialization of ‘int (*)(void)’ from incompatible pointer type ‘int (*)(st_data_t, st_data_t)’ {aka ‘int (*)(long unsigned int, long unsigned int)’} [-Wincompatible-pointer-types]
409 | str_end_cmp,
| ^~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:409:5: note: (near initialization for ‘hashType.compare’)
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:367:1: note: ‘str_end_cmp’ declared here
367 | str_end_cmp(st_data_t xp, st_data_t yp)
| ^~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:410:5: error: initialization of ‘st_index_t (*)(void)’ {aka ‘long unsigned int (*)(void)’} from incompatible pointer type ‘st_index_t (*)(st_data_t)’ {aka ‘long unsigned int (*)(long unsigned int)’} [-Wincompatible-pointer-types]
410 | str_end_hash,
| ^~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:410:5: note: (near initialization for ‘hashType.hash’)
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:391:1: note: ‘str_end_hash’ declared here
391 | str_end_hash(st_data_t xp)
| ^~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c: In function ‘names_clear’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:519:24: error: passing argument 2 of ‘onig_st_foreach’ from incompatible pointer type [-Wincompatible-pointer-types]
519 | onig_st_foreach(t, i_free_name_entry, 0);
| ^~~~~~~~~~~~~~~~~
| |
| int (*)(OnigUChar *, NameEntry *, void *) {aka int (*)(unsigned char *, NameEntry *, void *)}
In file included from /home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regint.h:937,
from /home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.h:33,
from /home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:31:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.h:129:28: note: expected ‘int (*)(void)’ but argument is of type ‘int (*)(OnigUChar *, NameEntry *, void *)’ {aka ‘int (*)(unsigned char *, NameEntry *, void *)’}
129 | int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
| ^~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:504:1: note: ‘i_free_name_entry’ declared here
504 | i_free_name_entry(UChar* key, NameEntry* e, void* arg ARG_UNUSED)
| ^~~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c: In function ‘onig_foreach_name’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:588:24: error: passing argument 2 of ‘onig_st_foreach’ from incompatible pointer type [-Wincompatible-pointer-types]
588 | onig_st_foreach(t, i_names, (HashDataType )&narg);
| ^~~~~~~
| |
| int (*)(OnigUChar *, NameEntry *, INamesArg *) {aka int (*)(unsigned char *, NameEntry *, INamesArg *)}
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.h:129:28: note: expected ‘int (*)(void)’ but argument is of type ‘int (*)(OnigUChar *, NameEntry *, INamesArg *)’ {aka ‘int (*)(unsigned char *, NameEntry *, INamesArg *)’}
129 | int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
| ^~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:561:1: note: ‘i_names’ declared here
561 | i_names(UChar* key ARG_UNUSED, NameEntry* e, INamesArg* arg)
| ^~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c: In function ‘onig_renumber_name_table’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:616:24: error: passing argument 2 of ‘onig_st_foreach’ from incompatible pointer type [-Wincompatible-pointer-types]
616 | onig_st_foreach(t, i_renumber_name, (HashDataType )map);
| ^~~~~~~~~~~~~~~
| |
| int (*)(OnigUChar *, NameEntry *, GroupNumRemap *) {aka int (*)(unsigned char *, NameEntry *, GroupNumRemap *)}
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.h:129:28: note: expected ‘int (*)(void)’ but argument is of type ‘int (*)(OnigUChar *, NameEntry *, GroupNumRemap *)’ {aka ‘int (*)(unsigned char *, NameEntry *, GroupNumRemap *)’}
129 | int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
| ^~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regparse.c:594:1: note: ‘i_renumber_name’ declared here
594 | i_renumber_name(UChar* key ARG_UNUSED, NameEntry* e, GroupNumRemap* map)
| ^~~~~~~~~~~~~~~
make[1]: *** [lib/onigmo/CMakeFiles/onigmo-static.dir/build.make:93: lib/onigmo/CMakeFiles/onigmo-static.dir/regparse.c.o] Error 1
make[1]: Leaving directory '/home/stewart/Projects/OSS/fluentbit-4--clean/build'
make: *** [CMakeFiles/Makefile2:7382: lib/onigmo/CMakeFiles/onigmo-static.dir/all] Error 2
The incompatible pointer types error can be addressed by making the GCC 14+ errors count as warning again:
In lib/onigmo/CMakeLists.txt:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+ # GCC 14 and greater enforce several checks that were historically warnings
+ # to now be errors by default
+ # See: https://gcc.gnu.org/gcc-14/porting_to.html#errors-as-warnings
+ if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpermissive")
+ endif()
However even with this, the function argument counts cause other errors:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c: In function ‘do_hash’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:327:43: error: too many arguments to function ‘tab->type->hash’; expected 0, have 1
327 | st_hash_t hash = (st_hash_t)(tab->type->hash)(key);
| ~~~~~~~~~~^~~~~~~ ~~~
In file included from /home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/regint.h:937,
from /home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:106:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.h:70:18: note: declared here
70 | st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
| ^~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c: In function ‘find_entry’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:180:40: error: too many arguments to function ‘(int (*)(void))tab->type->compare’; expected 0, have 2
180 | #define EQUAL(tab,x,y) ((x) == (y) || (*(tab)->type->compare)((x),(y)) == 0)
| ~^~~~~~~~~~~~~~~~~~~~~~ ~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:182:35: note: in expansion of macro ‘EQUAL’
182 | ((ptr)->hash == (hash_val) && EQUAL((tab), (key_), (ptr)->key))
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:189:15: note: in expansion of macro ‘PTR_EQUAL’
189 | res = PTR_EQUAL(tab, ptr, hash_val, key); \
| ^~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:889:9: note: in expansion of macro ‘DO_PTR_EQUAL_CHECK’
889 | DO_PTR_EQUAL_CHECK(tab, &entries[i], hash_value, key, eq_p, rebuilt_p);
| ^~~~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c: In function ‘find_table_entry_ind’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:180:40: error: too many arguments to function ‘(int (*)(void))tab->type->compare’; expected 0, have 2
180 | #define EQUAL(tab,x,y) ((x) == (y) || (*(tab)->type->compare)((x),(y)) == 0)
| ~^~~~~~~~~~~~~~~~~~~~~~ ~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:182:35: note: in expansion of macro ‘EQUAL’
182 | ((ptr)->hash == (hash_val) && EQUAL((tab), (key_), (ptr)->key))
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:189:15: note: in expansion of macro ‘PTR_EQUAL’
189 | res = PTR_EQUAL(tab, ptr, hash_val, key); \
| ^~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:931:13: note: in expansion of macro ‘DO_PTR_EQUAL_CHECK’
931 | DO_PTR_EQUAL_CHECK(tab, &entries[bin - ENTRY_BASE], hash_value, key, eq_p, rebuilt_p);
| ^~~~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c: In function ‘find_table_bin_ind’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:180:40: error: too many arguments to function ‘(int (*)(void))tab->type->compare’; expected 0, have 2
180 | #define EQUAL(tab,x,y) ((x) == (y) || (*(tab)->type->compare)((x),(y)) == 0)
| ~^~~~~~~~~~~~~~~~~~~~~~ ~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:182:35: note: in expansion of macro ‘EQUAL’
182 | ((ptr)->hash == (hash_val) && EQUAL((tab), (key_), (ptr)->key))
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:189:15: note: in expansion of macro ‘PTR_EQUAL’
189 | res = PTR_EQUAL(tab, ptr, hash_val, key); \
| ^~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:978:13: note: in expansion of macro ‘DO_PTR_EQUAL_CHECK’
978 | DO_PTR_EQUAL_CHECK(tab, &entries[bin - ENTRY_BASE], hash_value, key, eq_p, rebuilt_p);
| ^~~~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c: In function ‘find_table_bin_ptr_and_reserve’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:180:40: error: too many arguments to function ‘(int (*)(void))tab->type->compare’; expected 0, have 2
180 | #define EQUAL(tab,x,y) ((x) == (y) || (*(tab)->type->compare)((x),(y)) == 0)
| ~^~~~~~~~~~~~~~~~~~~~~~ ~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:182:35: note: in expansion of macro ‘EQUAL’
182 | ((ptr)->hash == (hash_val) && EQUAL((tab), (key_), (ptr)->key))
| ^~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:189:15: note: in expansion of macro ‘PTR_EQUAL’
189 | res = PTR_EQUAL(tab, ptr, hash_val, key); \
| ^~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:1086:13: note: in expansion of macro ‘DO_PTR_EQUAL_CHECK’
1086 | DO_PTR_EQUAL_CHECK(tab, &entries[entry_index - ENTRY_BASE], curr_hash_value, key, eq_p, rebuilt_p);
| ^~~~~~~~~~~~~~~~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c: In function ‘st_general_foreach’:
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:1626:19: error: too many arguments to function ‘func’; expected 0, have 4
1626 | retval = (*func)(key, curr_entry_ptr->record, arg, 0);
| ~^~~~~~ ~~~
/home/stewart/Projects/OSS/fluentbit-4--clean/lib/onigmo/st.c:1655:27: error: too many arguments to function ‘func’; expected 0, have 4
1655 | retval = (*func)(0, 0, arg, 1);
| ~^~~~~~ ~
make[1]: *** [lib/onigmo/CMakeFiles/onigmo-static.dir/build.make:219: lib/onigmo/CMakeFiles/onigmo-static.dir/st.c.o] Error 1
make[1]: Leaving directory '/home/stewart/Projects/OSS/fluentbit-4--clean/build'
make: *** [CMakeFiles/Makefile2:7382: lib/onigmo/CMakeFiles/onigmo-static.dir/all] Error 2
On point 2, some googling let me to this GCC bug ticket https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118112, which comments that:
I believe this is due to GCC 15 defaulting to -std=gnu23, whereas GCC 14 defaulted to -std=gnu17, and C23 is stricter about function prototypes than C17.
The C standard version can be set in CMake with https://cmake.org/cmake/help/latest/prop_tgt/C_STANDARD.html