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
7 changes: 7 additions & 0 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,13 @@ build_package_standard() {
# override them and notably lose the -O3, producing a -O0 Ruby.
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.
# Ruby's configure detects them even when building for an older macOS, where
# they are only weakly linked and are NULL at runtime, which makes miniruby
# crash during the build: https://bugs.ruby-lang.org/issues/22311
export ac_cv_func_dup3=no ac_cv_func_pipe2=no
fi
# ./configure --prefix=/path/to/ruby
# shellcheck disable=SC2086,SC2153
capture_command ${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" \
Expand Down
76 changes: 75 additions & 1 deletion test/compiler.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export -n RUBY_CONFIGURE_OPTS
cd "$INSTALL_ROOT"

stub_repeated uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
stub_repeated sw_vers '-productVersion : echo 10.10'
stub_repeated brew 'false'
# shellcheck disable=SC2016
stub_repeated make 'echo "make $(inspect_args "$@")" >> build.log'
Expand Down Expand Up @@ -43,3 +43,77 @@ OUT
unstub brew
unstub make
}

@test "dup3 and pipe2 are hidden from configure when building on older macOS" {
mkdir -p "$INSTALL_ROOT"
cd "$INSTALL_ROOT"

stub_repeated uname '-s : echo Darwin'
stub_repeated sw_vers '-productVersion : echo 26.6.2'
stub_repeated brew 'false'
# shellcheck disable=SC2016
stub_repeated make 'echo "make $(inspect_args "$@")" >> build.log'

cat > ./configure <<CON
#!${BASH}
echo ./configure "\$@" > build.log
echo dup3=\${ac_cv_func_dup3-unset} >> build.log
echo pipe2=\${ac_cv_func_pipe2-unset} >> build.log
CON
chmod +x ./configure

run_inline_definition <<DEF
build_package_standard ruby-3.4.0
DEF
assert_success
run cat build.log
assert_output <<OUT
./configure --prefix=$INSTALL_ROOT --with-ext=openssl,psych,+
dup3=no
pipe2=no
make -j 2
make install
OUT

unstub uname
unstub sw_vers
unstub brew
unstub make
}

@test "dup3 and pipe2 are left to configure on macOS 27" {
mkdir -p "$INSTALL_ROOT"
cd "$INSTALL_ROOT"

stub_repeated uname '-s : echo Darwin'
stub_repeated sw_vers '-productVersion : echo 27.0'
stub_repeated brew 'false'
# shellcheck disable=SC2016
stub_repeated make 'echo "make $(inspect_args "$@")" >> build.log'

cat > ./configure <<CON
#!${BASH}
echo ./configure "\$@" > build.log
echo dup3=\${ac_cv_func_dup3-unset} >> build.log
echo pipe2=\${ac_cv_func_pipe2-unset} >> build.log
CON
chmod +x ./configure

run_inline_definition <<DEF
build_package_standard ruby-3.4.0
DEF
assert_success
run cat build.log
assert_output <<OUT
./configure --prefix=$INSTALL_ROOT --with-ext=openssl,psych,+
dup3=unset
pipe2=unset
make -j 2
make install
OUT

unstub uname
unstub sw_vers
unstub brew
unstub make
}