[jdk11u-dev] RFR: 8224087: Compile C code for at least C99 Standard compliance
Zdenek Zambersky
zzambers at openjdk.org
Mon Sep 8 14:30:26 UTC 2025
On Wed, 3 Sep 2025 11:23:31 GMT, Zdenek Zambersky <zzambers at openjdk.org> wrote:
> This backport explicitly sets c99 standard for jdk c sources on compilers, where appropriate. Motivation for this is, [recent gcc switch to c23 as default](https://www.phoronix.com/news/GCC-15-Default-C23), causing errors (jdk sources are not c23 compatible).
>
> Main problem is, that c23 no longer supports non-prototype function declarations (see (3) [here](https://en.cppreference.com/w/c/language/function_declaration.html)). Example errors:
>
> /mnt/ramdisk/java-11-openjdk-11.0.28.0.6-1.portable.jdk.el.x86_64.tarxz/src/src/java.base/unix/native/libnet/DefaultProxySelector.c:389:16: error: too many arguments to function 'g_proxy_resolver_lookup'; expected 0, have 4
> 389 | proxies = (*g_proxy_resolver_lookup)(resolver, uri, NULL, &error);
> | ~^~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
>
>
>
> /mnt/ramdisk/java-11-openjdk-11.0.28.0.6-1.portable.jdk.el.x86_64.tarxz/src/test/hotspot/jtreg/runtime/jsig/libTestJNI.c:45:22: error: assignment to 'void (*)(int, siginfo_t *, void *)' from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
> 45 | act.sa_sigaction = (void (*)())sig_handler;
> | ^
>
>
> There are more, if above are fixed. Non prototype function declarations are present even in newest jdk, but newer jdks have c standard set explicitly, so they do not cause errors there.
>
> This should not increase minimum requirements for compiler toolchains needed to build jdk11. [Jdk13](https://github.com/openjdk/jdk13/blob/master/doc/building.md#native-compiler-toolchain-requirements), where this originates from, has same minimal compiler requirements as [jdk11](https://github.com/zzambers/jdk11u-dev/blob/master/doc/building.md#native-compiler-toolchain-requirements). ( gcc 4.8, clang 3.2, Xcode 8, Solaris Studio 12.4)
I was also thinking, whether c99 is ok here, but given that jdk13 has same minimum compiler versions, it should be safe.
Apart from testing in GHA. I tested these compiler versions (WORK):
- gcc-15.2.1 (f42; original motivation for this backport)
- gcc-4.8.5 (rhel-7)
- clang-3.8.1 (debian stretch)
Minimum accepted versions are gcc-4.8 and clang 3.2, so I tried to get close to that, based on what is available in old rhel/debian, not building my own toolchain. (Debian Jessie has clang 3.5, but that one (clang) was segfaulting during the build even o master, and Wheezy has clang 3.0)
(builds needed to disable warnings as errors, but that was same for master (and warnings seem the same))
For msvc there should be no change in compiler flags by this backport.
When it comes to Solaris, I could not test build there, because I don't have that OS available to me. But given that some awt libraries were already compiled with c99 flags, compiler flags should work.
-------------
PR Comment: https://git.openjdk.org/jdk11u-dev/pull/3087#issuecomment-3266588195
More information about the jdk-updates-dev
mailing list