diff --git a/bin/ruby-build b/bin/ruby-build index 58588e45..800564c7 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -208,24 +208,16 @@ is_freebsd() { [ "$(uname -s)" = "FreeBSD" ] } -# The C compiler that Ruby's configure picks: $CC, otherwise gcc if available, otherwise cc. -c_compiler() { - if [ -n "$CC" ]; then - echo "$CC" - elif command -v gcc >/dev/null; then - echo gcc - else - echo cc +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 } -# Prints the major version of GCC, or nothing if the given C compiler is not GCC (e.g. Clang). -gcc_major_version() { - # shellcheck disable=SC2086 - $1 -E -dM - /dev/null | - awk '/^#define __clang__ /{clang=1} /^#define __GNUC__ /{gnuc=$3} END{if (!clang) print gnuc}' -} - freebsd_package_prefix() { local package="$1" pkg info --prefix "$package" 2>/dev/null | cut -wf2 @@ -743,37 +735,24 @@ build_package_standard() { fi fi - local cc_override extra_cflags - if [ -z "$CC" ] && is_mac 1010; then - cc_override=clang - elif [[ "$package_var_name" = "RUBY" && "$ruby_semver" -lt 30200 ]]; then - local cc gcc_version - cc="$(c_compiler)" - gcc_version="$(gcc_major_version "$cc")" - if [ "${gcc_version:-0}" -ge 15 ]; then - # GCC 15 changed the default C mode from gnu17 to gnu23: https://gcc.gnu.org/gcc-15/changes.html#c - # 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 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 - fi - ( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then export CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}" fi - if [ -n "$cc_override" ]; then - export CC="$cc_override" - fi - if [ -n "$extra_cflags" ]; then + if [ -z "$CC" ] && is_mac 1010; then + export CC=clang + elif [[ "$package_var_name" = "RUBY" && "$ruby_semver" -lt 30200 ]] && 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. + # Use the cflags configure variable, which Ruby's configure appends to # its default optflags/debugflags/warnflags, unlike CFLAGS which would # override them and notably lose the -O3, producing a -O0 Ruby. - export cflags="$extra_cflags${cflags:+ $cflags}" + export cflags="-std=gnu17 $cflags" fi if [ "$package_var_name" = "RUBY" ] && is_mac && ! is_mac 2700; then # The macOS 27 SDK declares dup3() and pipe2() as available since macOS 27.0. @@ -1318,10 +1297,6 @@ build_package_openssl() { # Disable SSLv2 and Kerberos on older OpenSSL [[ "$1" != openssl-1.0.* ]] || package_option openssl configure no-ssl2 no-krb5 - # OpenSSL 1.0 can't be built in parallel, as two `ar` runs may create libcrypto.a at once and drop each other's objects. - # OPENSSL_MAKE_OPTS goes after MAKE_OPTS on the make command line, and a user's OPENSSL_MAKE_OPTS still goes after this. - [[ "$1" != openssl-1.0.* ]] || local OPENSSL_MAKE_OPTS="-j 1${OPENSSL_MAKE_OPTS:+ $OPENSSL_MAKE_OPTS}" - # Skip building OpenSSL docs, which is slow. local make_target="install_sw install_ssldirs" [[ "$1" != openssl-1.0.* ]] || make_target="install_sw" # OpenSSL 1.0 does not have `install_ssldirs` diff --git a/share/ruby-build/jruby-10.0.8.0 b/share/ruby-build/jruby-10.0.8.0 deleted file mode 100644 index a2cfa63f..00000000 --- a/share/ruby-build/jruby-10.0.8.0 +++ /dev/null @@ -1,2 +0,0 @@ -require_java 21 -install_package "jruby-10.0.8.0" "https://repo1.maven.org/maven2/org/jruby/jruby-dist/10.0.8.0/jruby-dist-10.0.8.0-bin.tar.gz#e33cd86d198d695bd67dc867daf4c31bced385a9f138a00c47f7c12aa1f4e789" jruby diff --git a/share/ruby-build/jruby-10.1.3.0 b/share/ruby-build/jruby-10.1.3.0 deleted file mode 100644 index 0b7ead0d..00000000 --- a/share/ruby-build/jruby-10.1.3.0 +++ /dev/null @@ -1,2 +0,0 @@ -require_java 21 -install_package "jruby-10.1.3.0" "https://repo1.maven.org/maven2/org/jruby/jruby-dist/10.1.3.0/jruby-dist-10.1.3.0-bin.tar.gz#3d76fe1fce6aa9f56fd7efb1015a9db95a0aa6f95fe9ec868f9e75d9ddc1871c" jruby diff --git a/test/build.bats b/test/build.bats index dd69b5b5..8548b987 100755 --- a/test/build.bats +++ b/test/build.bats @@ -477,32 +477,6 @@ make install OUT } -@test "bundled OpenSSL 1.0 is built without parallel make" { - cached_tarball "openssl-1.0.2u" config - - mkdir -p "${TMP}/ssl/certs" - touch "${TMP}/ssl/cert.pem" - - stub_repeated uname '-s : echo Linux' - stub openssl "version -d : echo 'OPENSSLDIR: \"${TMP}/ssl\"'" - stub_make_install "install_sw" - - mkdir -p "$INSTALL_ROOT"/openssl/ssl # OPENSSLDIR - run_inline_definition <> build.log' - - cat > ./configure < build.log -echo CC=\${CC-unset} >> build.log -echo cflags=\${cflags-unset} >> build.log -CON - chmod +x ./configure -} - -unstub_linux_build() { - unstub uname - unstub brew - unstub make -} - -# Stubs the given C compiler (default: gcc) to report the given preprocessor defines -stub_cc() { - stub_repeated "${2:-gcc}" "-E -dM - : printf '%s\n' $1" -} - -@test "GCC 15 compiles Ruby < 3.2 as gnu17" { - stub_linux_build - stub_cc '"#define __GNUC__ 15"' - - run_inline_definition <= 2.3" { - stub_linux_build - stub_cc '"#define __GNUC__ 14"' - - run_inline_definition <