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 " " (