From fb8030b335a81b40249917029e59a4e0e00f550d Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Tue, 24 Jun 2025 13:13:14 +0700 Subject: [PATCH 1/7] Allow installation of Ruby < 3.2 on Fedora <= 42 Fixes https://github.com/rbenv/ruby-build/issues/2542 ``` > ruby-build 3.1.7 ~/.rubies/ruby-3.1.7 ==> Downloading ruby-3.1.7.tar.gz...by-3.1.7 -> curl -q -fL -o ruby-3.1.7.tar.gz https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.7.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 19.8M 100 19.8M 0 0 10.1M 0 0:00:01 0:00:01 --:--:-- 10.1M ==> Installing ruby-3.1.7... WARNING: ruby-3.1.7 is past its end of life and is now unsupported. It no longer receives bug fixes or critical security updates. ruby-build: using readline from homebrew -> ./configure "--prefix=$HOME/.rubies/ruby-3.1.7" --enable-shared --with-readline-dir=/home/linuxbrew/.linuxbrew/opt/readline --with-ext=openssl,psych,+ -> make -j 22 -> make install ==> Installed ruby-3.1.7 to /home/pboling/.rubies/ruby-3.1.7 ``` --- bin/ruby-build | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bin/ruby-build b/bin/ruby-build index 755d4f0d60..8caa66f744 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -206,6 +206,21 @@ is_freebsd() { [ "$(uname -s)" = "FreeBSD" ] } +is_fedora() { + if [ -r /etc/os-release ]; then + # shellcheck disable=SC1091 + source /etc/os-release + # This will treat Aurora, Bazzite, BlueFin, uCore, and other Fedora variants as `fedora`. + # shellcheck disable=SC2153 + local os_id + od_id="${ID_LIKE:-$ID}" + local os_version + os_version=$VERSION_ID + [ "${od_id}" = "fedora" ] || return 1 + [ $# -eq 0 ] || [ "${os_version}" -ge "$1" ] + fi +} + freebsd_package_prefix() { local package="$1" pkg info --prefix "$package" 2>/dev/null | cut -wf2 @@ -712,6 +727,13 @@ build_package_standard() { fi if [ -z "$CC" ] && is_mac 1010; then export CC=clang + elif [ "$ruby_semver" -lt 300200 ]; then + # Ruby older than 3.2 can't compile on GCC v15 unless options are provided to + # use older GNU standard that is effectively "like GCC v14" => -std=gnu17 + if is_fedora && is_fedora 42; then + # Fedora 42+ has GCC v15 as default + export CFLAGS="$CFLAGS -std=gnu17" + fi fi # ./configure --prefix=/path/to/ruby # shellcheck disable=SC2086,SC2153 From 0a4413fb8df39bd2b84d1177a98ffc778dfa1777 Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Tue, 24 Jun 2025 15:35:48 +0700 Subject: [PATCH 2/7] Improve documentation of GCC modes - https://gcc.gnu.org/gcc-15/changes.html#c --- bin/ruby-build | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 8caa66f744..9c129b8daa 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -728,10 +728,12 @@ build_package_standard() { if [ -z "$CC" ] && is_mac 1010; then export CC=clang elif [ "$ruby_semver" -lt 300200 ]; then - # Ruby older than 3.2 can't compile on GCC v15 unless options are provided to - # use older GNU standard that is effectively "like GCC v14" => -std=gnu17 + # GCC v15 changed the default mode from gnu17 to gnu23. + # See: https://gcc.gnu.org/gcc-15/changes.html#c + # Ruby older than 3.2 can't compile on GCC v15 in the default mode of gnu23. + # See: https://github.com/rbenv/ruby-build/discussions/2529 if is_fedora && is_fedora 42; then - # Fedora 42+ has GCC v15 as default + # Fedora 42+ uses GCC v15 with mode gnu23 as default, so we configure for mode gnu17 export CFLAGS="$CFLAGS -std=gnu17" fi fi From f6e8dc91a85c7c8606e7c1210b516e0ece11c622 Mon Sep 17 00:00:00 2001 From: "|7eter l-|. l3oling" Date: Wed, 25 Jun 2025 00:02:30 +0700 Subject: [PATCH 3/7] Simplified condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- bin/ruby-build | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 9c129b8daa..1acdb1f837 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -211,13 +211,9 @@ is_fedora() { # shellcheck disable=SC1091 source /etc/os-release # This will treat Aurora, Bazzite, BlueFin, uCore, and other Fedora variants as `fedora`. - # shellcheck disable=SC2153 - local os_id - od_id="${ID_LIKE:-$ID}" - local os_version - os_version=$VERSION_ID - [ "${od_id}" = "fedora" ] || return 1 - [ $# -eq 0 ] || [ "${os_version}" -ge "$1" ] + if [[ "${ID_LIKE:-$ID}" != "fedora" || ( $# -gt 0 && "$VERSION_ID" -lt "$1") ]]; then + return 1 + fi fi } From 8ffa5fb737760e2eca91d3c11437febb3135414c Mon Sep 17 00:00:00 2001 From: "|7eter l-|. l3oling" Date: Wed, 25 Jun 2025 00:02:55 +0700 Subject: [PATCH 4/7] Short circuit condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 1acdb1f837..9be894183b 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -207,7 +207,7 @@ is_freebsd() { } is_fedora() { - if [ -r /etc/os-release ]; then + [ -r /etc/os-release ] || return 1 # shellcheck disable=SC1091 source /etc/os-release # This will treat Aurora, Bazzite, BlueFin, uCore, and other Fedora variants as `fedora`. From f9e81aa1360dfa5b8c485680dfa2ade3419cd8f5 Mon Sep 17 00:00:00 2001 From: "|7eter l-|. l3oling" Date: Wed, 25 Jun 2025 00:03:24 +0700 Subject: [PATCH 5/7] Simplified condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 9be894183b..113c315c85 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -728,7 +728,7 @@ build_package_standard() { # See: https://gcc.gnu.org/gcc-15/changes.html#c # Ruby older than 3.2 can't compile on GCC v15 in the default mode of gnu23. # See: https://github.com/rbenv/ruby-build/discussions/2529 - if is_fedora && is_fedora 42; then + if is_fedora 42; then # Fedora 42+ uses GCC v15 with mode gnu23 as default, so we configure for mode gnu17 export CFLAGS="$CFLAGS -std=gnu17" fi From 438097e93b391a21a031987221a78ef083c2df78 Mon Sep 17 00:00:00 2001 From: "|7eter l-|. l3oling" Date: Wed, 25 Jun 2025 00:03:39 +0700 Subject: [PATCH 6/7] Allow user overrides to CFLAGS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 113c315c85..3e50011f6f 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -730,7 +730,7 @@ build_package_standard() { # See: https://github.com/rbenv/ruby-build/discussions/2529 if is_fedora 42; then # Fedora 42+ uses GCC v15 with mode gnu23 as default, so we configure for mode gnu17 - export CFLAGS="$CFLAGS -std=gnu17" + export CFLAGS="-std=gnu17 $CFLAGS " fi fi # ./configure --prefix=/path/to/ruby From 6e57ceba883497bc8e6192444e20bada75fcd2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 26 Jun 2025 01:17:51 +0200 Subject: [PATCH 7/7] tweaks --- bin/ruby-build | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 3e50011f6f..7f8ed4cf45 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -208,12 +208,11 @@ is_freebsd() { is_fedora() { [ -r /etc/os-release ] || return 1 - # shellcheck disable=SC1091 - source /etc/os-release - # This will 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 + # 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 } @@ -723,15 +722,15 @@ build_package_standard() { fi if [ -z "$CC" ] && is_mac 1010; then export CC=clang - elif [ "$ruby_semver" -lt 300200 ]; then - # GCC v15 changed the default mode from gnu17 to gnu23. - # See: https://gcc.gnu.org/gcc-15/changes.html#c - # Ruby older than 3.2 can't compile on GCC v15 in the default mode of gnu23. - # See: https://github.com/rbenv/ruby-build/discussions/2529 - if is_fedora 42; then - # Fedora 42+ uses GCC v15 with mode gnu23 as default, so we configure for mode gnu17 - export CFLAGS="-std=gnu17 $CFLAGS " - fi + 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