diff --git a/bin/ruby-build b/bin/ruby-build index be666f98b1..65b9a65bdb 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -755,8 +755,9 @@ build_package_standard() { # Ruby < 3.2 can't compile as C23, where `()` in a declaration means `(void)`. extra_cflags="-std=gnu17" fi - if [[ -n "$extra_cflags" && "$ruby_semver" -ge 20600 && "$ruby_semver" -lt 20700 ]]; then - # Ruby 2.6 checks its MJIT header with a bare $(CC), so the flags must be part of CC there. + if [[ -n "$extra_cflags" && "$ruby_semver" -ge 20600 && "$ruby_semver" -lt 20800 ]]; then + # Ruby 2.6 checks its MJIT header with a bare $(CC), and the configure script of Ruby 2.7 + # (generated by Autoconf 2.71) silently ignores cflags, so the flags go on CC for those. cc_override="$cc $extra_cflags" extra_cflags= fi diff --git a/test/compiler.bats b/test/compiler.bats index 94995b27c2..7632da3135 100755 --- a/test/compiler.bats +++ b/test/compiler.bats @@ -190,6 +190,27 @@ OUT unstub_linux_build } +@test "GCC 15 compiles Ruby 2.7 as gnu17 via CC" { + stub_linux_build + stub_cc '"#define __GNUC__ 15"' + + run_inline_definition <