From 1b90b43e0cd0cf3191023e55403b9f4225938240 Mon Sep 17 00:00:00 2001 From: ghpzin Date: Sat, 18 Oct 2025 14:19:08 +0300 Subject: [PATCH] openjdk{8,11}: fix build with gcc15 - add "-std=gnu17" to `env.NIX_CFLAGS_COMPILE` for `openjdk8` and `openjdk11` Similar to what archlinux and gentoo did: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=65ea75ab7b558c1a7471eaf9ab542cee66631ea5 https://gitlab.archlinux.org/archlinux/packaging/packages/java8-openjdk/-/commit/e2b65f230bb5f15b75377306f41635ba44f84f61 https://gitlab.archlinux.org/archlinux/packaging/packages/java11-openjdk/-/commit/87ced23f8bd6b7e911f8b668545aa8c9950087e9 Fixes build failure of `openjdk8` with gcc15: ``` In file included from /build/source/hotspot/agent/src/os/linux/libproc_impl.h:30, from /build/source/hotspot/agent/src/os/linux/salibelf.h:30, from /build/source/hotspot/agent/src/os/linux/salibelf.c:25: /build/source/hotspot/agent/src/os/linux/libproc.h:86:13: error: 'bool' cannot be defined via 'typedef' 86 | typedef int bool; | ^~~~ /build/source/hotspot/agent/src/os/linux/libproc.h:86:13: note: 'bool' is a keyword with '-std=c23' onwards ``` Fixes build failure of `openjdk11` with gcc15: ``` /build/source/src/java.base/unix/native/libnet/DefaultProxySelector.c: In function 'getProxyByGProxyResolver': /build/source/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); | ~^~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ /build/source/src/java.base/unix/native/libnet/DefaultProxySelector.c:408:34: error: too many arguments to function 'g_network_address_parse_uri'; expected 0, have 3 408 | (*g_network_address_parse_uri)(proxies[i], 0, | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ``` --- pkgs/development/compilers/openjdk/generic.nix | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/openjdk/generic.nix b/pkgs/development/compilers/openjdk/generic.nix index 8b180376f10c..1deaf765d57c 100644 --- a/pkgs/development/compilers/openjdk/generic.nix +++ b/pkgs/development/compilers/openjdk/generic.nix @@ -412,10 +412,16 @@ stdenv.mkDerivation (finalAttrs: { if atLeast17 then "-Wno-error" else if atLeast11 then - # Workaround for - # `cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]` - # when building jtreg - "-Wformat" + lib.concatStringsSep " " ( + # Workaround for + # `cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]` + # when building jtreg + [ "-Wformat" ] + ++ lib.optionals (stdenv.cc.isGNU && featureVersion == "11") [ + # Fix build with gcc15 + "-std=gnu17" + ] + ) else lib.concatStringsSep " " ( [ @@ -436,6 +442,10 @@ stdenv.mkDerivation (finalAttrs: { "-Wno-error=int-conversion" "-Wno-error=incompatible-pointer-types" ] + ++ lib.optionals (stdenv.cc.isGNU && featureVersion == "8") [ + # Fix build with gcc15 + "-std=gnu17" + ] ); NIX_LDFLAGS = lib.concatStringsSep " " (