Skip to content

Commit 5693b62

Browse files
pbolingmislav
andauthored
Allow installation of Ruby 2.7, 3.0, 3.1 on Fedora >= 42 (#2543)
Fedora 42+ has updated to GCC v15. GCC v15 changed the default mode from gnu17 to gnu23: https://gcc.gnu.org/gcc-15/changes.html#c Ruby < 3.2 can't compile on GCC v15 in the default mode of gnu23. Fixes #2542 --------- Co-authored-by: Mislav Marohnić <[email protected]>
1 parent 1195268 commit 5693b62

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bin/ruby-build

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ is_freebsd() {
206206
[ "$(uname -s)" = "FreeBSD" ]
207207
}
208208

209+
is_fedora() {
210+
[ -r /etc/os-release ] || return 1
211+
# shellcheck disable=SC1091
212+
source /etc/os-release
213+
# Treat Aurora, Bazzite, BlueFin, uCore, and other Fedora variants as "fedora".
214+
if [[ "${ID_LIKE:-$ID}" != "fedora" || ( $# -gt 0 && "$VERSION_ID" -lt "$1") ]]; then
215+
return 1
216+
fi
217+
}
218+
209219
freebsd_package_prefix() {
210220
local package="$1"
211221
pkg info --prefix "$package" 2>/dev/null | cut -wf2
@@ -712,6 +722,15 @@ build_package_standard() {
712722
fi
713723
if [ -z "$CC" ] && is_mac 1010; then
714724
export CC=clang
725+
elif [ "$ruby_semver" -lt 300200 ] && is_fedora 42; then
726+
# Fedora 42+ has updated to GCC v15. GCC v15 changed the default
727+
# mode from gnu17 to gnu23: https://gcc.gnu.org/gcc-15/changes.html#c
728+
#
729+
# Ruby < 3.2 can't compile on GCC v15 in the default mode of gnu23.
730+
#
731+
# TODO: Consider changing this to check for GCC v15 specifically
732+
# rather than inspecting the OS itself.
733+
export CFLAGS="-std=gnu17 $CFLAGS"
715734
fi
716735
# ./configure --prefix=/path/to/ruby
717736
# shellcheck disable=SC2086,SC2153

0 commit comments

Comments
 (0)