Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure with GCC 15 (C23) #3206

Open
kostadinsh opened this issue Nov 19, 2024 · 4 comments
Open

Build failure with GCC 15 (C23) #3206

kostadinsh opened this issue Nov 19, 2024 · 4 comments

Comments

@kostadinsh
Copy link

Describe the bug
jq fails to build with upcoming GCC 15 that defaults to C23. This can be reproduced on older GCC and Clang versions by adding -std=gnu23 to CFLAGS.

Downstream Gentoo bug: https://bugs.gentoo.org/944014

Environment (please complete the following information):

  • OS: Gentoo Linux
  • jq version: happens with both master and 1.7.1
src/builtin.c:1794:4: error: initialization of 'jv (*)(void)' from incompatible pointer type 'jv (*)(jq_state *, jv)' [-Wincompatible-pointer-types]
 1794 |   {f_ ## name, #name, 1},
      |    ^~
src/libm.h:2:1: note: in expansion of macro 'LIBM_DD'
    2 | LIBM_DD(acos)
      | ^~~~~~~
src/builtin.c:1794:4: note: (near initialization for 'function_list[0].fptr')
 1794 |   {f_ ## name, #name, 1},
      |    ^~
src/builtin.c:1800:4: error: initialization of 'jv (*)(void)' from incompatible pointer type 'jv (*)(jq_state *, jv,  jv,  jv)' [-Wincompatible-pointer-types]
 1800 |   {f_ ## name, #name, 3},
      |    ^~
src/libm.h:27:1: note: in expansion of macro 'LIBM_DDD'
   27 | LIBM_DDD(atan2)
      | ^~~~~~~~
src/builtin.c:1800:4: note: (near initialization for 'function_list[5].fptr')
 1800 |   {f_ ## name, #name, 3},
      |    ^~
src/libm.h:27:1: note: in expansion of macro 'LIBM_DDD'
   27 | LIBM_DDD(atan2)
      | ^~~~~~~~
src/builtin.c:1809:4: error: initialization of 'jv (*)(void)' from incompatible pointer type 'jv (*)(jq_state *, jv)' [-Wincompatible-pointer-types]
 1809 |   {f_negate, "_negate", 1},
      |    ^~~~~~~~
src/builtin.c:1809:4: note: (near initialization for 'function_list[61].fptr')
src/builtin.c:1810:22: error: initialization of 'jv (*)(void)' from incompatible pointer type 'jv (*)(jq_state *, jv,  jv,  jv)' [-Wincompatible-pointer-types]
 1810 | #define BINOP(name) {f_ ## name, "_" #name, 3},
      |                      ^~
src/builtin.h:11:3: note: in expansion of macro 'BINOP'
   11 |   BINOP(plus) \
      |   ^~~~~
src/builtin.c:1811:1: note: in expansion of macro 'BINOPS'
 1811 | BINOPS
      | ^~~~~~
src/builtin.c:1810:22: note: (near initialization for 'function_list[62].fptr')
 1810 | #define BINOP(name) {f_ ## name, "_" #name, 3},
      |                      ^~
src/builtin.h:11:3: note: in expansion of macro 'BINOP'
   11 |   BINOP(plus) \
      |   ^~~~~
src/builtin.c:1811:1: note: in expansion of macro 'BINOPS'
 1811 | BINOPS
      | ^~~~~~

Above are just some of the errors the rest are in the build log that's attached
build.log

@emanuele6
Copy link
Member

emanuele6 commented Nov 19, 2024

AC_PROG_CC_STDC should tell the compiler to use C99 (or C89 as a fallback if C99 is not supported).

m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])

https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/C-Compiler.html#index-AC_005fPROG_005fCC_005fSTDC-743

Are you sure the build failure isn't just caused by you forcing -std=gnu23 in CFLAGS?

@kostadinsh
Copy link
Author

Are you sure the build failure isn't just caused by you forcing -std=gnu23 in CFLAGS?

I don't have it in CFLAGS, it's the default for GCC 15.

See also: https://inbox.sourceware.org/gcc-cvs/20241115234634.9D1633858CDA@sourceware.org/T/#u

@emanuele6
Copy link
Member

Downstream Gentoo bug: https://bugs.gentoo.org/944014

I missed that link, it doesn't look like you are adding it in CFLAGS

@emanuele6
Copy link
Member

Are you sure the build failure isn't just caused by you forcing -std=gnu23 in CFLAGS?

I don't have it in CFLAGS, it's the default for GCC 15.

See also: https://inbox.sourceware.org/gcc-cvs/20241115234634.9D1633858CDA@sourceware.org/T/#u

@kostadinsh I know gcc changed the default, but that link doesn't say anything useful. Also adding -std=gnu23 to CFLAGS doesn't really help in reproucing issue since it is a problem related to autoconf, and not the code.
For example, gcc -std=c99 $(USERCFLAGSWITHFORCEDC23) would still cause problems which is what I was saying.
Here AC_PROG_CC_STDC should be dealing with passing something like -std=c99 to the compiler I think, anyway it looks like it isn't doing that in your setup.

It looks like AC_PROG_CC_STDC is now an obsolete undocumented macro, it probably needs to be replaced by something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants