diff --git a/bin/ruby-build b/bin/ruby-build index 755d4f0d60..7f8ed4cf45 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -206,6 +206,16 @@ is_freebsd() { [ "$(uname -s)" = "FreeBSD" ] } +is_fedora() { + [ -r /etc/os-release ] || return 1 + # shellcheck disable=SC1091 + source /etc/os-release + # Treat Aurora, Bazzite, BlueFin, uCore, and other Fedora variants as "fedora". + if [[ "${ID_LIKE:-$ID}" != "fedora" || ( $# -gt 0 && "$VERSION_ID" -lt "$1") ]]; then + return 1 + fi +} + freebsd_package_prefix() { local package="$1" pkg info --prefix "$package" 2>/dev/null | cut -wf2 @@ -712,6 +722,15 @@ build_package_standard() { fi if [ -z "$CC" ] && is_mac 1010; then export CC=clang + elif [ "$ruby_semver" -lt 300200 ] && is_fedora 42; then + # 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. + # + # TODO: Consider changing this to check for GCC v15 specifically + # rather than inspecting the OS itself. + export CFLAGS="-std=gnu17 $CFLAGS" fi # ./configure --prefix=/path/to/ruby # shellcheck disable=SC2086,SC2153