Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions test/compiler.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<DEF
build_package_standard ruby-2.7.8
DEF
assert_success
run cat build.log
assert_output <<OUT
./configure --prefix=$INSTALL_ROOT --with-ext=openssl,psych,+
CC=gcc -std=gnu17
cflags=unset
make -j 2
make install
OUT

unstub gcc
unstub_linux_build
}

@test "GCC 15 compiles Ruby <= 2.2 as gnu17" {
stub_linux_build
stub_cc '"#define __GNUC__ 15"'
Expand Down
Loading