diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 593 |
1 files changed, 401 insertions, 192 deletions
diff --git a/configure.ac b/configure.ac index 39e7fd831b..ac6f821a8f 100644 --- a/configure.ac +++ b/configure.ac @@ -9,49 +9,67 @@ tooldir="$srcdir/tool" AC_DISABLE_OPTION_CHECKING -m4_include([tool/m4/_colorize_result_prepare.m4])dnl -m4_include([tool/m4/ac_msg_result.m4])dnl -m4_include([tool/m4/colorize_result.m4])dnl -m4_include([tool/m4/ruby_append_option.m4])dnl -m4_include([tool/m4/ruby_append_options.m4])dnl -m4_include([tool/m4/ruby_check_builtin_func.m4])dnl -m4_include([tool/m4/ruby_check_builtin_setjmp.m4])dnl -m4_include([tool/m4/ruby_check_printf_prefix.m4])dnl -m4_include([tool/m4/ruby_check_setjmp.m4])dnl -m4_include([tool/m4/ruby_check_signedness.m4])dnl -m4_include([tool/m4/ruby_check_sizeof.m4])dnl -m4_include([tool/m4/ruby_check_sysconf.m4])dnl -m4_include([tool/m4/ruby_cppoutfile.m4])dnl -m4_include([tool/m4/ruby_decl_attribute.m4])dnl -m4_include([tool/m4/ruby_default_arch.m4])dnl -m4_include([tool/m4/ruby_define_if.m4])dnl -m4_include([tool/m4/ruby_defint.m4])dnl -m4_include([tool/m4/ruby_dtrace_available.m4])dnl -m4_include([tool/m4/ruby_dtrace_postprocess.m4])dnl -m4_include([tool/m4/ruby_func_attribute.m4])dnl -m4_include([tool/m4/ruby_mingw32.m4])dnl -m4_include([tool/m4/ruby_prepend_option.m4])dnl -m4_include([tool/m4/ruby_prog_gnu_ld.m4])dnl -m4_include([tool/m4/ruby_prog_makedirs.m4])dnl -m4_include([tool/m4/ruby_replace_funcs.m4])dnl -m4_include([tool/m4/ruby_replace_type.m4])dnl -m4_include([tool/m4/ruby_require_funcs.m4])dnl -m4_include([tool/m4/ruby_rm_recursive.m4])dnl -m4_include([tool/m4/ruby_setjmp_type.m4])dnl -m4_include([tool/m4/ruby_stack_grow_direction.m4])dnl -m4_include([tool/m4/ruby_thread.m4])dnl -m4_include([tool/m4/ruby_try_cflags.m4])dnl -m4_include([tool/m4/ruby_try_cxxflags.m4])dnl -m4_include([tool/m4/ruby_try_ldflags.m4])dnl -m4_include([tool/m4/ruby_universal_arch.m4])dnl -m4_include([tool/m4/ruby_wasm_tools.m4])dnl -m4_include([tool/m4/ruby_werror_flag.m4])dnl +m4_define([RUBY_M4_INCLUDED], [])dnl +AC_DEFUN([RUBY_M4_INCLUDE], [m4_include([tool/m4/$1])dnl + m4_append([RUBY_M4_INCLUDED], [ \ + $(tooldir)/m4/$1])dnl +]) +RUBY_M4_INCLUDE([_colorize_result_prepare.m4])dnl +RUBY_M4_INCLUDE([ac_msg_result.m4])dnl +RUBY_M4_INCLUDE([colorize_result.m4])dnl +RUBY_M4_INCLUDE([ruby_append_option.m4])dnl +RUBY_M4_INCLUDE([ruby_append_options.m4])dnl +RUBY_M4_INCLUDE([ruby_check_builtin_func.m4])dnl +RUBY_M4_INCLUDE([ruby_check_builtin_setjmp.m4])dnl +RUBY_M4_INCLUDE([ruby_check_header.m4])dnl +RUBY_M4_INCLUDE([ruby_check_printf_prefix.m4])dnl +RUBY_M4_INCLUDE([ruby_check_setjmp.m4])dnl +RUBY_M4_INCLUDE([ruby_check_signedness.m4])dnl +RUBY_M4_INCLUDE([ruby_check_sizeof.m4])dnl +RUBY_M4_INCLUDE([ruby_check_sysconf.m4])dnl +RUBY_M4_INCLUDE([ruby_cppoutfile.m4])dnl +RUBY_M4_INCLUDE([ruby_decl_attribute.m4])dnl +RUBY_M4_INCLUDE([ruby_default_arch.m4])dnl +RUBY_M4_INCLUDE([ruby_define_if.m4])dnl +RUBY_M4_INCLUDE([ruby_defint.m4])dnl +RUBY_M4_INCLUDE([ruby_dtrace_available.m4])dnl +RUBY_M4_INCLUDE([ruby_dtrace_postprocess.m4])dnl +RUBY_M4_INCLUDE([ruby_func_attribute.m4])dnl +RUBY_M4_INCLUDE([ruby_mingw32.m4])dnl +RUBY_M4_INCLUDE([ruby_prepend_option.m4])dnl +RUBY_M4_INCLUDE([ruby_prog_gnu_ld.m4])dnl +RUBY_M4_INCLUDE([ruby_prog_makedirs.m4])dnl +RUBY_M4_INCLUDE([ruby_replace_funcs.m4])dnl +RUBY_M4_INCLUDE([ruby_replace_type.m4])dnl +RUBY_M4_INCLUDE([ruby_require_funcs.m4])dnl +RUBY_M4_INCLUDE([ruby_rm_recursive.m4])dnl +RUBY_M4_INCLUDE([ruby_setjmp_type.m4])dnl +RUBY_M4_INCLUDE([ruby_shared_gc.m4])dnl +RUBY_M4_INCLUDE([ruby_stack_grow_direction.m4])dnl +RUBY_M4_INCLUDE([ruby_thread.m4])dnl +RUBY_M4_INCLUDE([ruby_try_cflags.m4])dnl +RUBY_M4_INCLUDE([ruby_try_cxxflags.m4])dnl +RUBY_M4_INCLUDE([ruby_try_ldflags.m4])dnl +RUBY_M4_INCLUDE([ruby_universal_arch.m4])dnl +RUBY_M4_INCLUDE([ruby_wasm_tools.m4])dnl +RUBY_M4_INCLUDE([ruby_werror_flag.m4])dnl + +AS_IF([test "x${GITHUB_ACTIONS}" = xtrue], +[AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl +dnl 93(bright yellow) is copied from .github/workflows/mingw.yml + begin_group() { AS_ECHO(["::group::@<:@93m$[]1@<:@m"]);} + end_group() { AS_ECHO(["::endgroup::"]);} +], +[dnl + begin_group() { :;} + end_group() { :;} +]) AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl -: "environment section" && { +[begin]_group "environment section" && { HAVE_BASERUBY=yes BASERUBY_VERSION= AC_ARG_WITH(baseruby, @@ -64,8 +82,10 @@ AC_ARG_WITH(baseruby, [ AC_PATH_PROG([BASERUBY], [ruby], [false]) ]) -# BASERUBY must be >= 2.2.0. Note that `"2.2.0" > "2.2"` is true. -AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'print 42 if RUBY_VERSION > "2.2"' 2>/dev/null`" = 42], [ +AS_IF([test "$HAVE_BASERUBY" != no], [ + RUBYOPT=- $BASERUBY --disable=gems "${tooldir}/missing-baseruby.bat" || HAVE_BASERUBY=no +]) +AS_IF([test "${HAVE_BASERUBY:=no}" != no], [ AS_CASE(["$build_os"], [mingw*], [ # Can MSys shell run a command with a drive letter? RUBYOPT=- `cygpath -ma "$BASERUBY"` --disable=gems -e exit 2>/dev/null || HAVE_BASERUBY=no @@ -73,12 +93,10 @@ AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'p RUBY_APPEND_OPTION(BASERUBY, "--disable=gems") BASERUBY_VERSION=`$BASERUBY -v` $BASERUBY -C "$srcdir" tool/downloader.rb -d tool -e gnu config.guess config.sub >&AS_MESSAGE_FD -], [ - HAVE_BASERUBY=no ]) AS_IF([test "$HAVE_BASERUBY" = no], [ AS_IF([test "$cross_compiling" = yes], [AC_MSG_ERROR([executable host ruby is required for cross-compiling])]) - BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false" + BASERUBY=${tooldir}/missing-baseruby.bat ]) AC_SUBST(BASERUBY) AC_SUBST(HAVE_BASERUBY) @@ -214,15 +232,23 @@ AS_CASE(["/${rb_CC} "], [*clang*], [ # Ditto for LLVM. Note however that llvm-as is a LLVM-IR to LLVM bitcode # assembler that does not target your machine native binary. - : ${LD:="${CC}"} # ... try -fuse-ld=lld ? - RUBY_CHECK_PROG_FOR_CC([AR], [s/clang/llvm-ar/]) -# RUBY_CHECK_PROG_FOR_CC([AS], [s/clang/llvm-as/]) + + # Xcode has its own version tools that may be incompatible with + # genuine LLVM tools, use the tools in the same directory. + + AS_IF([$rb_CC -E -dM -xc - < /dev/null | grep -F __apple_build_version__ > /dev/null], + [llvm_prefix=], [llvm_prefix=llvm-]) + # AC_PREPROC_IFELSE cannot be used before AC_USE_SYSTEM_EXTENSIONS + + RUBY_CHECK_PROG_FOR_CC([LD], [s/clang/ld/]) # ... maybe try lld ? + RUBY_CHECK_PROG_FOR_CC([AR], [s/clang/${llvm_prefix}ar/]) +# RUBY_CHECK_PROG_FOR_CC([AS], [s/clang/${llvm_prefix}as/]) RUBY_CHECK_PROG_FOR_CC([CXX], [s/clang/clang++/]) - RUBY_CHECK_PROG_FOR_CC([NM], [s/clang/llvm-nm/]) - RUBY_CHECK_PROG_FOR_CC([OBJCOPY], [s/clang/llvm-objcopy/]) - RUBY_CHECK_PROG_FOR_CC([OBJDUMP], [s/clang/llvm-objdump/]) - RUBY_CHECK_PROG_FOR_CC([RANLIB], [s/clang/llvm-ranlib/]) - RUBY_CHECK_PROG_FOR_CC([STRIP], [s/clang/llvm-strip/]) + RUBY_CHECK_PROG_FOR_CC([NM], [s/clang/${llvm_prefix}nm/]) + RUBY_CHECK_PROG_FOR_CC([OBJCOPY], [s/clang/${llvm_prefix}objcopy/]) + RUBY_CHECK_PROG_FOR_CC([OBJDUMP], [s/clang/${llvm_prefix}objdump/]) + RUBY_CHECK_PROG_FOR_CC([RANLIB], [s/clang/${llvm_prefix}ranlib/]) + RUBY_CHECK_PROG_FOR_CC([STRIP], [s/clang/${llvm_prefix}strip/]) ]) AS_UNSET(rb_CC) AS_UNSET(rb_dummy) @@ -235,7 +261,7 @@ AS_CASE(["${build_os}"], AC_PATH_TOOL([NM], [nm], [/usr/ccs/bin/nm], [/usr/ccs/bin:$PATH]) ]) AS_CASE(["${target_os}"], -[cygwin*|msys*|mingw*], [ +[cygwin*|msys*|mingw*|darwin*], [ ac_cv_prog_ac_ct_OBJCOPY=":" ]) @@ -254,10 +280,14 @@ AC_CHECK_TOOLS([AR], [gar ar]) AC_CHECK_TOOLS([AS], [gas as]) AC_CHECK_TOOLS([LD], [gld ld]) # ... try gold ? AC_CHECK_TOOLS([NM], [gnm nm]) -AC_CHECK_TOOLS([OBJCOPY], [gobjcopy objcopy]) +AC_CHECK_TOOLS([OBJCOPY], [gobjcopy objcopy], [:]) AC_CHECK_TOOLS([OBJDUMP], [gobjdump objdump]) AC_CHECK_TOOLS([STRIP], [gstrip strip], [:]) +# nm errors with Rust's LLVM bitcode when Rust uses a newer LLVM version than nm. +# In case we're working with llvm-nm, tell it to not worry about the bitcode. +AS_IF([${NM} --help 2>&1 | grep -q 'llvm-bc'], [NM="$NM --no-llvm-bc"]) + AS_IF([test ! $rb_test_CFLAGS], [AS_UNSET(CFLAGS)]); AS_UNSET(rb_test_CFLAGS) AS_IF([test ! $rb_test_CXXFLAGS], [AS_UNSET(CXXFLAGS)]); AS_UNSET(rb_save_CXXFLAGS) @@ -330,7 +360,7 @@ test -z "$warnflags" || AS_IF([test -z "${CFLAGS+set}"], [ cflags=`echo " $cflags " | sed "$cflagspat;s/^ *//;s/ *$//"` orig_cflags="$cflags" - cflags="$cflags "'${optflags} ${debugflags} ${warnflags}' + cflags='${hardenflags} '"$cflags "'${optflags} ${debugflags} ${warnflags}' ]) dnl AS_IF([test -z "${CXXFLAGS+set}"], [ dnl cxxflags=`echo " $cxxflags " | sed "$cflagspat;s/^ *//;s/ *$//"` @@ -366,12 +396,6 @@ AS_CASE(["$target_os"], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) AC_MSG_ERROR([Unsupported OS X version is required])]) - AC_CACHE_CHECK([if thread-local storage is supported], [rb_cv_tls_supported], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int __thread conftest;]])], - [rb_cv_tls_supported=yes], - [rb_cv_tls_supported=no])]) - AS_IF([test x"$rb_cv_tls_supported" != xyes], - [AC_DEFINE(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)]) ]) RUBY_MINGW32 @@ -405,39 +429,26 @@ AC_SUBST(OUTFLAG) AC_SUBST(COUTFLAG) AC_SUBST(CSRCFLAG) -: ${MJIT_CC=$CC} -AS_IF([test "x$cross_compiling" = xno], [ - AC_PATH_PROG([MJIT_CC], ${MJIT_CC}) - - # if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache) - AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null && - echo $MJIT_CC | grep ^/usr/lib/ccache > /dev/null], [ - PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` MJIT_CC=`which $CC`]) - - AS_CASE([$target_os], - [*mingw*], [command -v cygpath > /dev/null && MJIT_CC=`cygpath -ma $MJIT_CC`]) - shift 2 - MJIT_CC="$MJIT_CC${1+ }$*" -]) - AS_CASE(["$build_os"], - [darwin1*.*], [ + [darwin*], [ + # gcc 13 warns duplicate -l options, which are added by the + # default spec. # Xcode linker warns for deprecated architecture and wrongly # installed TBD files. - CC_WRAPPER="" + AC_MSG_CHECKING(for $CC linker warning) + suppress_ld_waring=no echo 'int main(void) {return 0;}' > conftest.c AS_IF([$CC -framework Foundation -o conftest conftest.c 2>&1 | - grep '^ld: warning: text-based stub file' >/dev/null], [ - CC_WRAPPER=`cd -P "${tooldir}" && pwd`/darwin-cc - CC="$CC_WRAPPER $CC" + grep \ + -e '^ld: warning: ignoring duplicate libraries:' \ + -e '^ld: warning: text-based stub file' \ + -e '^ld: warning: -multiply_defined is obsolete' \ + >/dev/null], [ + suppress_ld_waring=yes ]) rm -fr conftest* - ]) -AS_CASE(["$build_os"], - [darwin*], [ - AC_SUBST(X_WRAPPER_AR, "`cd -P "${tooldir}" && pwd`/darwin-ar $AR") - ], [ - AC_SUBST(X_WRAPPER_AR, "$AR") + test $suppress_ld_waring = yes && warnflags="${warnflags:+${warnflags} }-Wl,-w" + AC_MSG_RESULT($suppress_ld_waring) ]) AS_CASE(["$target_os"], [wasi*], [ @@ -464,8 +475,8 @@ AC_SUBST(CC_VERSION_MESSAGE, $cc_version_message) : ${DLDFLAGS="$LDFLAGS"} RUBY_UNIVERSAL_ARCH -AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no -a "${universal_binary:-no}" = no], [ - RUBY_DEFAULT_ARCH("$target_cpu") +AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "${universal_binary:-no}" = no], [ + RUBY_DEFAULT_ARCH($target_cpu) ]) host_os=$target_os host_vendor=$target_vendor @@ -509,6 +520,7 @@ AS_CASE(["$target_os"], ]) rb_cv_binary_elf=no : ${enable_shared=yes} + AS_IF([$WINDRES --version | grep LLVM > /dev/null], [USE_LLVM_WINDRES=yes], [USE_LLVM_WINDRES=no]) ], [hiuxmpp*], [AC_DEFINE(__HIUX_MPP__)]) # by TOYODA Eizi <toyoda@npd.kishou.go.jp> @@ -592,7 +604,7 @@ AC_MSG_RESULT([$CHDIR]) AC_SUBST(CHDIR) } -: "compiler section" && { +[begin]_group "compiler section" && { RUBY_WERROR_FLAG([ AC_MSG_CHECKING([whether CFLAGS is valid]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], @@ -687,6 +699,10 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"], AS_IF([test $gcc_major -le 6], [ extra_warnflags="$extra_warnflags -Wno-maybe-uninitialized" ]) + AS_CASE([ $CFLAGS ], [*" -save-temps="*|*" -save-temps "*], [], [ + extra_warnflags="$extra_warnflags -Werror=misleading-indentation" + ]) + # ICC doesn't support -Werror= AS_IF([test $icc_version -gt 0], [ particular_werror_flags=no @@ -698,7 +714,6 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"], -Werror=duplicated-cond \ -Werror=implicit-function-declaration \ -Werror=implicit-int \ - -Werror=misleading-indentation \ -Werror=pointer-arith \ -Werror=shorten-64-to-32 \ -Werror=write-strings \ @@ -798,12 +813,10 @@ AS_IF([test "$GCC" = yes], [ [fortify_source=$enableval]) AS_IF([test "x$fortify_source" != xno], [ RUBY_TRY_CFLAGS([$optflags -D_FORTIFY_SOURCE=2], - [RUBY_APPEND_OPTION(XCFLAGS, -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)], [], + [RUBY_PREPEND_OPTION(hardenflags, -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)], [], [@%:@include <stdio.h>]) ]) - : ${MJIT_HEADER_FLAGS='-P -dD'} - # -fstack-protector AS_CASE(["$target_os"], [emscripten*|wasi*], [ @@ -821,17 +834,24 @@ AS_IF([test "$GCC" = yes], [ AC_MSG_CHECKING([for -fstack-protector]) AC_MSG_RESULT(["$stack_protector"]) AS_CASE(["$stack_protector"], [-*], [ - RUBY_APPEND_OPTION(XCFLAGS, $stack_protector) - RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector) - RUBY_APPEND_OPTION(LDFLAGS, $stack_protector) + RUBY_PREPEND_OPTION(hardenflags, $stack_protector) + RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector) + RUBY_APPEND_OPTION(LDFLAGS, $stack_protector) ]) # aarch64 branch protection AS_CASE(["$target_cpu"], [aarch64], [ AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [ - RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no]) + # Try these flags in the _prepended_ position - i.e. we want to try building a program + # with CFLAGS="-mbranch-protection=pac-ret $CFLAGS". If the builder has provided different + # branch protection flags in CFLAGS, we don't want to overwrite those. We just want to + # find some branch protection flags which work if none were provided. + RUBY_TRY_CFLAGS_PREPEND(option, [branch_protection=yes], [branch_protection=no]) AS_IF([test "x$branch_protection" = xyes], [ - RUBY_APPEND_OPTION(XCFLAGS, option) + # _prepend_ the options to CFLAGS, so that user-provided flags will overwrite them. + # These CFLAGS are used during the configure script to compile further test programs; + # however, $harden_flags is prepended separately to CFLAGS at the end of the script. + RUBY_PREPEND_OPTION(hardenflags, $opt) break ]) ]) @@ -888,9 +908,9 @@ AS_IF([test "$GCC" = yes], [ # suppress annoying -Wstrict-overflow warnings RUBY_TRY_CFLAGS(-fno-strict-overflow, [RUBY_APPEND_OPTION(XCFLAGS, -fno-strict-overflow)]) - test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-ggdb3, [debugflags=-ggdb3])} - test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-ggdb, [debugflags=-ggdb])} - test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-g3, [debugflags=-g3])} + test "${debugflags+set}" || {RUBY_TRY_LDFLAGS(-ggdb3, [debugflags=-ggdb3])} + test "${debugflags+set}" || {RUBY_TRY_LDFLAGS(-ggdb, [debugflags=-ggdb])} + test "${debugflags+set}" || {RUBY_TRY_LDFLAGS(-g3, [debugflags=-g3])} ]) test $ac_cv_prog_cc_g = yes && : ${debugflags=-g} @@ -907,7 +927,6 @@ AS_IF([test "$GCC" = yes], [ ], [ RUBY_TRY_LDFLAGS([-Wl,-unexported_symbol,_Init_*], [visibility_option=ld], [visibility_option=no]) ]) - test "$visibility_option" = no || OBJCOPY=: ]) AS_IF([test "$GCC" = yes], [ @@ -963,22 +982,83 @@ AC_ARG_WITH(opt-dir, [OPT_DIR="${OPT_DIR:+$OPT_DIR$PATH_SEPARATOR}$withval"], []) AS_IF([test "x$OPT_DIR" != x], [ + save_IFS="$IFS" IFS="$PATH_SEPARATOR" val= PWD= + for dir in $OPT_DIR; do + test -z "$dir" && continue + dir=`eval $CHDIR '"$dir"' && pwd` || continue + val="${val:+$val$PATH_SEPARATOR}$dir" + done + IFS="$save_IFS" OPT_DIR="$val" + unset PWD + unset save_IFS val=`IFS="$PATH_SEPARATOR" for dir in $OPT_DIR; do - test -z "$dir" && continue echo x ${LIBPATHFLAG} ${RPATHFLAG} | sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g" done | tr '\012' ' ' | sed 's/ *$//'` LDFLAGS="${LDFLAGS:+$LDFLAGS }$val" DLDFLAGS="${DLDFLAGS:+$DLDFLAGS }$val" LDFLAGS_OPTDIR="$val" - CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }"`echo "$OPT_DIR" | tr "${PATH_SEPARATOR}" '\012' | + INCFLAGS="${INCFLAGS:+$INCFLAGS }"`echo "$OPT_DIR" | tr "${PATH_SEPARATOR}" '\012' | sed '/^$/d;s|^|-I|;s|$|/include|' | tr '\012' ' ' | sed 's/ *$//'` ]) +AC_SUBST(incflags, "$INCFLAGS") test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\"" test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\"" -} + +# The lines above expand out the $cflags/$optflags/$debugflags/$hardenflags variables into the +# CFLAGS variable. So, at this point, we have a $CFLAGS var with the actual compiler flags we're +# going to use. +# That means this is the right time to check what branch protection flags are going to be in use +# and define appropriate macros for use in Context.S based on this +AS_CASE(["$target_cpu"], [aarch64], [ + AC_CACHE_CHECK([whether __ARM_FEATURE_BTI_DEFAULT is defined], + rb_cv_aarch64_bti_enabled, + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + @%:@ifndef __ARM_FEATURE_BTI_DEFAULT + @%:@error "__ARM_FEATURE_BTI_DEFAULT not defined" + @%:@endif + ]])], + [rb_cv_aarch64_bti_enabled=yes], + [rb_cv_aarch64_bti_enabled=no]) + ) + AS_IF([test "$rb_cv_aarch64_bti_enabled" = yes], + AC_DEFINE(RUBY_AARCH64_BTI_ENABLED, 1)) + AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT is defined], + rb_cv_aarch64_pac_enabled, + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + @%:@ifndef __ARM_FEATURE_PAC_DEFAULT + @%:@error "__ARM_FEATURE_PAC_DEFAULT not defined" + @%:@endif + ]])], + [rb_cv_aarch64_pac_enabled=yes], + [rb_cv_aarch64_pac_enabled=no]) + ) + AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes], + AC_DEFINE(RUBY_AARCH64_PAC_ENABLED, 1)) + # Context.S will only ever sign its return address with the A-key; it doesn't support + # the B-key at the moment. + AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes], [ + AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT specifies the b-key bit 0x02], + rb_cv_aarch64_pac_b_key, + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + @%:@ifdef __ARM_FEATURE_PAC_DEFAULT + @%:@if __ARM_FEATURE_PAC_DEFAULT & 0x02 + @%:@error "__ARM_FEATURE_PAC_DEFAULT specifies B key" + @%:@endif + @%:@endif + ]])], + [rb_cv_aarch64_pac_b_key=no], + [rb_cv_aarch64_pac_b_key=yes]) + ) + AS_IF([test "$rb_cv_aarch64_pac_b_key" = yes], + AC_MSG_ERROR(-mbranch-protection flag specified b-key but Ruby's Context.S does not support this yet.)) + ]) +]) AC_CACHE_CHECK([whether compiler has statement and declarations in expressions], rb_cv_have_stmt_and_decl_in_expr, @@ -988,8 +1068,9 @@ AC_CACHE_CHECK([whether compiler has statement and declarations in expressions], AS_IF([test "$rb_cv_have_stmt_and_decl_in_expr" = yes], [ AC_DEFINE(HAVE_STMT_AND_DECL_IN_EXPR) ]) +} -: "header and library section" && { +[begin]_group "header and library section" && { AC_ARG_WITH(winnt-ver, AS_HELP_STRING([--with-winnt-ver=0xXXXX], [target Windows NT version (default to 0x0600)]), [with_winnt_ver="$withval"], [with_winnt_ver="0x0600"]) @@ -1092,21 +1173,23 @@ main() ]) POSTLINK="" AC_CHECK_PROGS(codesign, codesign) - AC_CHECK_PROGS(dsymutil, dsymutil) + dsymutils= + AS_CASE("$CC_NO_WRAPPER", [gcc*-1[[3-9]]], [ + dsymutils=${CC_NO_WRAPPER@%:@gcc} + dsymutils=dsymutil${dsymutils%-1*} + dsymutils="$dsymutils-19 $dsymutils-18 $dsymutils-17" + ]) + AC_CHECK_PROGS(dsymutil, $dsymutils dsymutil) AS_IF([test -n "$codesign"], [ - POSTLINK="{ test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' -f \$@; }${POSTLINK:+; $POSTLINK}" + POSTLINK="{ test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' \$@; }${POSTLINK:+; $POSTLINK}" ]) AS_IF([test -n "$dsymutil"], [ - POSTLINK="$dsymutil \$@${POSTLINK:+; $POSTLINK}" - ]) - AS_IF([test -n "${POSTLINK}"], [ - LINK_SO="$LINK_SO -\$(POSTLINK)" + POSTLINK="$dsymutil \$@ 2>/dev/null${POSTLINK:+; $POSTLINK}" ]) AC_CHECK_HEADERS(crt_externs.h, [], [], [ #include <crt_externs.h> ]) - cleanlibs='$(TARGET_SO).dSYM' + cleanlibs='$(TARGET_SO:=.dSYM)' ], [solaris*], [ LIBS="-lm $LIBS" ac_cv_func_vfork=no @@ -1241,10 +1324,11 @@ main() # __builtin_longjmp in ppc64* Linux does not restore # the TOC register (r2), which is problematic # when a global exit happens from JITted .so code. - AS_CASE(["$target_cpu"], [powerpc64*], [ + # __builtin_setjmp can have issues on arm64 linux (see [Bug #14480]). + AS_CASE(["$target_cpu"], [powerpc64*|arm64|aarch64], [ ac_cv_func___builtin_setjmp=no ]) - # With gcc-8's -fcf-protection, MJIT's __builtin_longjmp fails. + # With gcc-8's -fcf-protection, RJIT's __builtin_longjmp fails. AS_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no]) AS_IF([test "$cf_protection" = yes], [ ac_cv_func___builtin_setjmp=no @@ -1259,7 +1343,7 @@ main() [wasi*],[ LIBS="-lm -lwasi-emulated-mman -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks $LIBS" RUBY_APPEND_OPTIONS(CFLAGS, -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_GETPID -D_WASI_EMULATED_PROCESS_CLOCKS) RUBY_APPEND_OPTIONS(CPPFLAGS, -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_GETPID -D_WASI_EMULATED_PROCESS_CLOCKS) - POSTLINK="\$(WASMOPT) --asyncify \$(wasmoptflags) --pass-arg=asyncify-ignore-imports -o \$@ \$@${POSTLINK:+; $POSTLINK}" + POSTLINK="\$(WASMOPT) --asyncify \$(wasmoptflags) -o \$@ \$@${POSTLINK:+; $POSTLINK}" # wasi-libc's sys/socket.h is not compatible with -std=gnu99, # so re-declare shutdown in include/ruby/missing.h ac_cv_func_shutdown=no @@ -1267,6 +1351,13 @@ main() [ LIBS="-lm $LIBS"]) : ${ORIG_LIBS=$LIBS} +AS_IF([test -n "${POSTLINK}"], [ + # NOTE: A (part of) link commands used link shared extension libraries. If + # the first line of the value is empty, mkmf prepends default link steps. + LINK_SO="$LINK_SO +\$(POSTLINK)" +]) + AS_IF([test -n "${rb_there_is_in_fact_no_gplusplus_but_autoconf_is_cheating_us}"], [ AC_MSG_NOTICE([Test skipped due to lack of a C++ compiler.]) ], @@ -1346,13 +1437,17 @@ AC_CHECK_HEADERS(syscall.h) AC_CHECK_HEADERS(time.h) AC_CHECK_HEADERS(ucontext.h) AC_CHECK_HEADERS(utime.h) +AC_CHECK_HEADERS(sys/epoll.h) +AC_CHECK_HEADERS(sys/event.h) +AC_CHECK_HEADERS(stdckdint.h) + AS_CASE("$target_cpu", [x64|x86_64|i[3-6]86*], [ AC_CHECK_HEADERS(x86intrin.h) ]) RUBY_UNIVERSAL_CHECK_HEADER([x86_64, i386], x86intrin.h) AS_IF([test "x$with_gmp" != xno], - [AC_CHECK_HEADERS(gmp.h) + [RUBY_CHECK_HEADER(gmp.h) AS_IF([test "x$ac_cv_header_gmp_h" != xno], AC_SEARCH_LIBS([__gmpz_init], [gmp], [AC_DEFINE(HAVE_LIBGMP, 1)]))]) @@ -1362,6 +1457,8 @@ AC_ARG_WITH([jemalloc], [with_jemalloc=$withval], [with_jemalloc=no]) AS_IF([test "x$with_jemalloc" != xno],[ # find jemalloc header first + save_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${INCFLAGS} ${CPPFLAGS}" malloc_header= AC_CHECK_HEADER(jemalloc/jemalloc.h, [malloc_header=jemalloc/jemalloc.h], [ AC_CHECK_HEADER(jemalloc.h, [malloc_header=jemalloc.h]) @@ -1393,6 +1490,8 @@ AS_IF([test "x$with_jemalloc" != xno],[ done done ]) + CPPFLAGS="${save_CPPFLAGS}" + unset save_CPPFLAGS with_jemalloc=${rb_cv_jemalloc_library} AS_CASE(["$with_jemalloc"], [no], @@ -1418,7 +1517,7 @@ AC_SYS_LARGEFILE # which is not added by AC_SYS_LARGEFILE. AS_IF([test x"$enable_largefile" != xno], [ AS_CASE(["$target_os"], [solaris*], [ - AC_MSG_CHECKING([wheather _LARGEFILE_SOURCE should be defined]) + AC_MSG_CHECKING([whether _LARGEFILE_SOURCE should be defined]) AS_CASE(["${ac_cv_sys_file_offset_bits}:${ac_cv_sys_large_files}"], ["64:"|"64:no"|"64:unknown"], [ # insert _LARGEFILE_SOURCE before _FILE_OFFSET_BITS line @@ -1479,6 +1578,25 @@ RUBY_CHECK_SIZEOF(float) RUBY_CHECK_SIZEOF(double) RUBY_CHECK_SIZEOF(time_t, [long "long long"], [], [@%:@include <time.h>]) RUBY_CHECK_SIZEOF(clock_t, [], [], [@%:@include <time.h>]) +AC_SUBST(X_BUILTIN_BINARY, yes) +AS_IF([test "$cross_compiling" = yes], +[dnl miniruby cannot run if cross compiling + X_BUILTIN_BINARY=no +], +[ + AS_CASE([ac_cv_sizeof_voidp], + [[1-9]*], [dnl fixed value + ], + [ + AC_CACHE_CHECK([word size], [rb_cv_word_size], + [for w in 4 8; do + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@if SIZEOF_VOIDP != ${w} + @%:@error SIZEOF_VOIDP + @%:@endif]])], [rb_cv_word_size=${w}; break]) + done]) + AS_IF([test -z $rb_cv_word_size], [X_BUILTIN_BINARY=no]) + ]) +]) AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct, [rb_cv_packed_struct=no @@ -1491,10 +1609,9 @@ AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct, [rb_cv_packed_struct=$mac; break]) done]) AS_IF([test "$rb_cv_packed_struct" != no], [ - AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], [$rb_cv_packed_struct]) + AC_DEFINE_UNQUOTED([RBIMPL_ATTR_PACKED_STRUCT_BEGIN()], [`echo " $rb_cv_packed_struct " | sed 's/ x .*//;s/^ *//'`]) + AC_DEFINE_UNQUOTED([RBIMPL_ATTR_PACKED_STRUCT_END()], [`echo " $rb_cv_packed_struct " | sed 's/.* x //;s/ *$//'`]) RUBY_TRY_CFLAGS(-Wno-address-of-packed-member, [AC_DEFINE(USE_UNALIGNED_MEMBER_ACCESS)]) -], [ - AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], x) ]) AS_IF([test "x$ac_cv_type_long_long" = xyes], [ @@ -1709,7 +1826,7 @@ AS_IF([test "$GCC" = yes], [ AC_CACHE_CHECK(for exported function attribute, rb_cv_func_exported, [ rb_cv_func_exported=no RUBY_WERROR_FLAG([ -for mac in '__attribute__ ((__visibility__("default")))' '__declspec(dllexport)'; do +for mac in '__declspec(dllexport)' '__attribute__ ((__visibility__("default")))'; do AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@define RUBY_FUNC_EXPORTED $mac extern RUBY_FUNC_EXPORTED void conftest_attribute_check(void);]], [[]])], [rb_cv_func_exported="$mac"; break]) @@ -1735,7 +1852,7 @@ AC_CACHE_CHECK(for function name string predefined identifier, [AS_CASE(["$target_os"],[openbsd*],[ rb_cv_function_name_string=__func__ ],[ - rb_cv_function_name_string=no + rb_cv_function_name_string=no RUBY_WERROR_FLAG([ for func in __func__ __FUNCTION__; do AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]], @@ -1743,7 +1860,8 @@ AC_CACHE_CHECK(for function name string predefined identifier, [rb_cv_function_name_string=$func break]) done - ])])] + ]) + ])] ) AS_IF([test "$rb_cv_function_name_string" != no], [ AC_DEFINE_UNQUOTED(RUBY_FUNCTION_NAME_STRING, [$rb_cv_function_name_string]) @@ -2026,6 +2144,7 @@ AC_CHECK_FUNCS(execv) AC_CHECK_FUNCS(execve) AC_CHECK_FUNCS(explicit_memset) AC_CHECK_FUNCS(fcopyfile) +AC_CHECK_FUNCS(fchdir) AC_CHECK_FUNCS(fchmod) AC_CHECK_FUNCS(fchown) AC_CHECK_FUNCS(fcntl) @@ -2066,7 +2185,6 @@ AC_CHECK_FUNCS(gettimeofday) # for making ac_cv_func_gettimeofday AC_CHECK_FUNCS(getuid) AC_CHECK_FUNCS(getuidx) AC_CHECK_FUNCS(gmtime_r) -AC_CHECK_FUNCS(grantpt) AC_CHECK_FUNCS(initgroups) AC_CHECK_FUNCS(ioctl) AC_CHECK_FUNCS(isfinite) @@ -2083,6 +2201,7 @@ AC_CHECK_FUNCS(lstat) AC_CHECK_FUNCS(lutimes) AC_CHECK_FUNCS(malloc_usable_size) AC_CHECK_FUNCS(malloc_size) +AC_CHECK_FUNCS(malloc_trim) AC_CHECK_FUNCS(mblen) AC_CHECK_FUNCS(memalign) AC_CHECK_FUNCS(memset_s) @@ -2136,6 +2255,7 @@ AC_CHECK_FUNCS(sigaction) AC_CHECK_FUNCS(sigaltstack) AC_CHECK_FUNCS(sigprocmask) AC_CHECK_FUNCS(sinh) +AC_CHECK_FUNCS(snprintf) AC_CHECK_FUNCS(spawnv) AC_CHECK_FUNCS(symlink) AC_CHECK_FUNCS(syscall) @@ -2160,9 +2280,6 @@ AC_CHECK_FUNCS(__sinpi) AS_IF([test "x$ac_cv_member_struct_statx_stx_btime" = xyes], [AC_CHECK_FUNCS(statx)]) -AS_CASE(["$ac_cv_func_memset_s:$ac_cv_func_qsort_s"], [*yes*], - [RUBY_DEFINE_IF([!defined __STDC_WANT_LIB_EXT1__], [__STDC_WANT_LIB_EXT1__], 1)]) - AS_IF([test "$ac_cv_func_getcwd" = yes], [ AC_CACHE_CHECK(if getcwd allocates buffer if NULL is given, [rb_cv_getcwd_malloc], [AC_RUN_IFELSE([AC_LANG_SOURCE([[ @@ -2231,6 +2348,27 @@ RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatibl RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()]) RUBY_CHECK_BUILTIN_FUNC(__builtin_expect, [__builtin_expect(0, 0)]) +AS_IF([test "$rb_cv_builtin___builtin_mul_overflow" != no], [ + AC_CACHE_CHECK(for __builtin_mul_overflow with long long arguments, rb_cv_use___builtin_mul_overflow_long_long, [ + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +#pragma clang optimize off + +int +main(void) +{ + long long x = 0, y; + __builtin_mul_overflow(x, x, &y); + + return 0; +} +]])], + rb_cv_use___builtin_mul_overflow_long_long=yes, + rb_cv_use___builtin_mul_overflow_long_long=no)]) +]) +AS_IF([test "$rb_cv_use___builtin_mul_overflow_long_long" = yes], [ + AC_DEFINE(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG, 1) +]) + AS_IF([test "$ac_cv_func_qsort_r" != no], [ AC_CACHE_CHECK(whether qsort_r is GNU version, rb_cv_gnu_qsort_r, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @@ -2618,6 +2756,9 @@ AS_CASE([$coroutine_type], [yes|''], [ [*86-mingw*], [ coroutine_type=win32 ], + [aarch64-mingw*], [ + coroutine_type=arm64 + ], [arm*-linux*], [ coroutine_type=arm32 ], @@ -2630,6 +2771,9 @@ AS_CASE([$coroutine_type], [yes|''], [ [riscv64-linux*], [ coroutine_type=riscv64 ], + [loongarch64-linux*], [ + coroutine_type=loongarch64 + ], [x86_64-freebsd*], [ coroutine_type=amd64 ], @@ -2754,6 +2898,22 @@ AS_IF([test "$THREAD_MODEL" = pthread], [ AC_DEFINE_UNQUOTED(SET_ANOTHER_THREAD_NAME(thid,name), $set_another_thread_name) ]) ]) + + AC_CACHE_CHECK([for thread-local storage specifier], [rb_cv_tls_specifier], + rb_cv_tls_specifier=none + RUBY_WERROR_FLAG([ + for attr in \ + _Thread_local \ + __thread \ + ; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$attr int conftest;]])], + [rb_cv_tls_specifier=$attr; break]) + done + ]) + ) + AS_IF([test x"${rb_cv_tls_specifier}" != xnone], + [AC_DEFINE_UNQUOTED(RB_THREAD_LOCAL_SPECIFIER, ${rb_cv_tls_specifier})] + ) ]) AS_IF([test x"$ac_cv_header_ucontext_h" = xno], [ @@ -2897,8 +3057,8 @@ AS_IF([test "x$ac_cv_func_ioctl" = xyes], [ } -: "runtime section" && { -dnl wheather use dln_a_out or not +[begin]_group "runtime section" && { +dnl whether use dln_a_out or not AC_ARG_WITH(dln-a-out, AS_HELP_STRING([--with-dln-a-out], [dln_a_out is deprecated]), [ @@ -2931,22 +3091,8 @@ AS_CASE(["$target_os"], ])]) LIBEXT=a -AC_ARG_WITH(mjit-tabs, - AS_HELP_STRING([--without-mjit-tabs], [expand tabs in mjit header]), - [AS_IF([test $withval = no], [MJIT_TABS=false])]) -AC_SUBST(MJIT_TABS)dnl AC_SUBST(DLDFLAGS)dnl AC_SUBST(ARCH_FLAG)dnl -AC_SUBST(MJIT_HEADER_FLAGS)dnl -AC_SUBST(MJIT_HEADER_INSTALL_DIR)dnl -AC_SUBST(MJIT_CC)dnl -AS_CASE(["$GCC:$target_os"], - [yes:aix*], [mjit_std_cflag="-std=gnu99"], - [mjit_std_cflag=]) -AC_SUBST(MJIT_CFLAGS, [${MJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl -AC_SUBST(MJIT_OPTFLAGS, [${MJIT_OPTFLAGS-'$(optflags)'}])dnl -AC_SUBST(MJIT_DEBUGFLAGS, [${MJIT_DEBUGFLAGS-'$(debugflags)'}])dnl -AC_SUBST(MJIT_LDSHARED)dnl AC_SUBST(STATIC)dnl AC_SUBST(CCDLFLAGS)dnl @@ -3060,11 +3206,10 @@ AC_SUBST(EXTOBJS) [darwin*], [ : ${LDSHARED='$(CC) -dynamic -bundle'} : ${DLDSHARED='$(CC) -dynamiclib'} : ${LDFLAGS=""} - : ${LIBPATHENV=DYLD_FALLBACK_LIBRARY_PATH} + : ${LIBPATHENV=DYLD_LIBRARY_PATH} : ${PRELOADENV=DYLD_INSERT_LIBRARIES} AS_IF([test x"$enable_shared" = xyes], [ - # Resolve symbols from libruby.dylib when --enable-shared - EXTDLDFLAGS='$(LIBRUBYARG_SHARED)' + # Resolve symbols from libruby.dylib in $(LIBS) when --enable-shared ], [test "x$EXTSTATIC" = x], [ # When building exts as bundles, a mach-o bundle needs to know its loader # program to bind symbols from the ruby executable @@ -3100,6 +3245,7 @@ AC_SUBST(EXTOBJS) [hiuxmpp], [ : ${LDSHARED='$(LD) -r'}], [atheos*], [ : ${LDSHARED='$(CC) -shared'} rb_cv_dlopen=yes], + [wasi*], [ : ${LDSHARED='$(LD) -shared -Xlinker --export-dynamic'}], [ : ${LDSHARED='$(LD)'}]) AC_MSG_RESULT($rb_cv_dlopen) } @@ -3355,7 +3501,7 @@ done BTESTRUBY='$(MINIRUBY)' AS_IF([test x"$cross_compiling" = xyes], [ - test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I`$CHDIR .; pwd` "-r'$(arch)-fake' + test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I${ac_abs_builddir-.} "-r'$(arch)-fake' XRUBY_LIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["libdir"]']` XRUBY_RUBYLIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["rubylibdir"]']` XRUBY_RUBYHDRDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["rubyhdrdir"]']` @@ -3413,9 +3559,6 @@ AC_ARG_ENABLE(multiarch, [multiarch=], [unset multiarch]) AS_IF([test ${multiarch+set}], [ AC_DEFINE(ENABLE_MULTIARCH) - MJIT_HEADER_INSTALL_DIR=include/'${arch}/${RUBY_VERSION_NAME}' -], [ - MJIT_HEADER_INSTALL_DIR=include/'${RUBY_VERSION_NAME}/${arch}' ]) archlibdir='${libdir}/${arch}' @@ -3501,7 +3644,7 @@ AS_CASE("$enable_shared", [yes], [ RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ['-Wl,-soname,$(LIBRUBY_SONAME)' "$LDFLAGS_OPTDIR"]) LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)' AS_IF([test "$load_relative" = yes], [ - libprefix="'\$\${ORIGIN}/../${libdir_basename}'" + libprefix="'\$\${ORIGIN}/../${multiarch+../../}${libdir_basename}'" LIBRUBY_RPATHFLAGS="-Wl,-rpath,${libprefix}" LIBRUBY_RELATIVE=yes ]) @@ -3513,7 +3656,7 @@ AS_CASE("$enable_shared", [yes], [ LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)" LIBRUBY_ALIASES='' ], [test "$load_relative" = yes], [ - libprefix="'\$\$ORIGIN/../${libdir_basename}'" + libprefix="'\$\$ORIGIN/../${multiarch+../../}${libdir_basename}'" LIBRUBY_RPATHFLAGS="-Wl,-rpath,${libprefix}" LIBRUBY_RELATIVE=yes ]) @@ -3537,7 +3680,7 @@ AS_CASE("$enable_shared", [yes], [ LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)' RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-h${linker_flag:+,}"'$(@F)']) AS_IF([test "$load_relative" = yes], [ - libprefix="'\$\$ORIGIN/../${libdir_basename}'" + libprefix="'\$\$ORIGIN/../${multiarch+../../}${libdir_basename}'" LIBRUBY_RPATHFLAGS="-R${libprefix}" LIBRUBY_RELATIVE=yes ], [ @@ -3554,7 +3697,7 @@ AS_CASE("$enable_shared", [yes], [ LIBRUBY_SONAME='$(LIBRUBY_SO)' LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(SOEXT)' AS_IF([test "$load_relative" = yes], [ - libprefix="@executable_path/../${libdir_basename}" + libprefix="@executable_path/../${multiarch+../../}${libdir_basename}" LIBRUBY_RELATIVE=yes ]) LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS -install_name ${libprefix}"'/$(LIBRUBY_SONAME)' @@ -3688,14 +3831,15 @@ AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage measurement by gcov]), [gcov=yes]) AS_IF([test x"$gcov" = xyes], [ - CFLAGS="$CFLAGS -coverage" + CFLAGS="$CFLAGS -coverage -fprofile-update=atomic" LDFLAGS="$LDFLAGS -coverage" ]) RUBY_SETJMP_TYPE +RUBY_SHARED_GC } -: "build section" && { +[begin]_group "installation section" && { dnl build rdoc index if requested RDOCTARGET="" CAPITARGET="" @@ -3743,20 +3887,19 @@ AC_SUBST(CAPITARGET) AS_CASE(["$RDOCTARGET:$CAPITARGET"],[nodoc:nodoc],[INSTALLDOC=nodoc],[INSTALLDOC=all]) AC_SUBST(INSTALLDOC) -AC_ARG_ENABLE(jit-support, - AS_HELP_STRING([--disable-jit-support], [disable JIT features]), - [MJIT_SUPPORT=$enableval], - [AS_CASE(["$target_os"], - [wasi | mingw* | solaris*], [MJIT_SUPPORT=no], - [MJIT_SUPPORT=yes] - )]) - -AS_IF([test x"$MJIT_SUPPORT" = "xyes"], - [AC_DEFINE(USE_MJIT, 1)], - [AC_DEFINE(USE_MJIT, 0)]) - -AC_SUBST(MJIT_SUPPORT) +AC_ARG_ENABLE(install-static-library, + AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]), + [INSTALL_STATIC_LIBRARY=$enableval + AS_IF([test x"$enable_shared" = xno -a x"$INSTALL_STATIC_LIBRARY" = xno], + [AC_MSG_ERROR([must install either static or shared library])], + [])], + AS_IF([test x"$enable_shared" = xyes], + [INSTALL_STATIC_LIBRARY=no], + [INSTALL_STATIC_LIBRARY=yes])) +AC_SUBST(INSTALL_STATIC_LIBRARY) +} +[begin]_group "JIT section" && { AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix dnl check if rustc is recent enough to build YJIT (rustc >= 1.58.0) @@ -3802,8 +3945,8 @@ AC_ARG_ENABLE(yjit, AS_HELP_STRING([--enable-yjit], [enable in-process JIT compiler that requires Rust build tools. enabled by default on supported platforms if rustc 1.58.0+ is available]), [YJIT_SUPPORT=$enableval], - [AS_CASE(["$enable_jit_support:$YJIT_TARGET_OK:$YJIT_RUSTC_OK"], - [yes:yes:yes|:yes:yes], [ + [AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"], + [yes:yes], [ YJIT_SUPPORT=yes ], [YJIT_SUPPORT=no] @@ -3815,9 +3958,6 @@ CARGO_BUILD_ARGS= YJIT_LIBS= AS_CASE(["${YJIT_SUPPORT}"], [yes|dev|stats|dev_nodebug], [ - AS_IF([test x"$enable_jit_support" = "xno"], - AC_MSG_ERROR([--disable-jit-support but --enable-yjit. YJIT requires JIT support]) - ) AS_IF([test x"$RUSTC" = "xno"], AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install]) ) @@ -3834,6 +3974,7 @@ AS_CASE(["${YJIT_SUPPORT}"], [dev_nodebug], [ rb_rust_target_subdir=dev_nodebug CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm' + AC_DEFINE(YJIT_STATS, 1) ], [stats], [ rb_rust_target_subdir=stats @@ -3857,7 +3998,9 @@ AS_CASE(["${YJIT_SUPPORT}"], AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT]) ]) AC_DEFINE(USE_YJIT, 1) -], [AC_DEFINE(USE_YJIT, 0)]) +], [ + AC_DEFINE(USE_YJIT, 0) +]) dnl These variables end up in ::RbConfig::CONFIG AC_SUBST(YJIT_SUPPORT)dnl what flavor of YJIT the Ruby build includes @@ -3867,17 +4010,53 @@ AC_SUBST(CARGO_BUILD_ARGS)dnl for selecting Rust build profiles AC_SUBST(YJIT_LIBS)dnl for optionally building the Rust parts of YJIT AC_SUBST(YJIT_OBJ)dnl for optionally building the C parts of YJIT -AC_ARG_ENABLE(install-static-library, - AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]), - [INSTALL_STATIC_LIBRARY=$enableval - AS_IF([test x"$enable_shared" = xno -a x"$INSTALL_STATIC_LIBRARY" = xno], - [AC_MSG_ERROR([must install either static or shared library])], - [])], - AS_IF([test x"$enable_shared" = xyes], - [INSTALL_STATIC_LIBRARY=no], - [INSTALL_STATIC_LIBRARY=yes])) -AC_SUBST(INSTALL_STATIC_LIBRARY) +dnl RJIT supports only x86_64 platforms, but allows arm64/aarch64 for custom JITs. +RJIT_TARGET_OK=no +AS_IF([test "$cross_compiling" = no], + AS_CASE(["$target_cpu-$target_os"], + [*android*], [ + RJIT_TARGET_OK=no + ], + [arm64-darwin*|aarch64-darwin*|x86_64-darwin*], [ + RJIT_TARGET_OK=yes + ], + [arm64-*linux*|aarch64-*linux*|x86_64-*linux*], [ + RJIT_TARGET_OK=yes + ], + [arm64-*bsd*|aarch64-*bsd*|x86_64-*bsd*], [ + RJIT_TARGET_OK=yes + ] + ) +) + +dnl Build RJIT on supported platforms or if --enable-rjit is specified. +AC_ARG_ENABLE(rjit, + AS_HELP_STRING([--enable-rjit], + [enable pure-Ruby JIT compiler. enabled by default on Unix x86_64 platforms]), + [RJIT_SUPPORT=$enableval], + [AS_CASE(["$RJIT_TARGET_OK"], + [yes], [RJIT_SUPPORT=yes], + [RJIT_SUPPORT=no] + )] +) + +AS_CASE(["$RJIT_SUPPORT"], +[yes|dev], [ + AS_CASE(["$RJIT_SUPPORT"], + [dev], [ + # Link libcapstone for --rjit-dump-disasm + AC_CHECK_LIB([capstone], [cs_disasm]) + ]) + + AC_DEFINE(USE_RJIT, 1) +], [ + AC_DEFINE(USE_RJIT, 0) +]) +AC_SUBST(RJIT_SUPPORT) +} + +[begin]_group "build section" && { AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern void conftest_external(void) {}]], [[]])],[ rb_cv_symbol_prefix=`$NM conftest.$ac_objext | @@ -3888,6 +4067,25 @@ AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [ ]) SYMBOL_PREFIX="$rb_cv_symbol_prefix" test "x$SYMBOL_PREFIX" = xNONE && SYMBOL_PREFIX='' + +AS_IF([test x"$SOEXT" = xdll], [ + # DLL on Windows is managed by win32/mkexports.rb +], [test x"$enable_shared" = xyes], [ + AC_CACHE_CHECK([for default symbols in empty shared library], rb_cv_symbols_in_emptylib, [ + save_CC="$CC" + eval CC=\"`printf "%s" "${DLDSHARED}" | sed ['s/\$(CC)/${CC}/']`\" + AC_LINK_IFELSE([AC_LANG_PROGRAM()],[ + rb_cv_symbols_in_emptylib=`$NM -Pgp conftest$ac_exeext | + sed ["/ [A-TV-Z] .*/!d;s///;s/^${SYMBOL_PREFIX}//;/^main$/d"]` + ]) + set dummy ${rb_cv_symbols_in_emptylib} + shift + rb_cv_symbols_in_emptylib="$*" + CC="$save_CC" + ]) +]) +AC_SUBST(XSYMBOLS_IN_EMPTYLIB, "${rb_cv_symbols_in_emptylib}") + DLNOBJ=dln.o AC_ARG_ENABLE(dln, AS_HELP_STRING([--disable-dln], [disable dynamic link feature]), @@ -4065,8 +4263,9 @@ AS_IF([test "${universal_binary-no}" = yes ], [ const char arch[[]] = __ARCHITECTURE__;]], [[puts(arch);]])], [rb_cv_architecture_available=yes], [rb_cv_architecture_available=no])) ]) +} -: ${MJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(MJIT_CC)|g']`} +[end]_group MAINLIBS="$LIBS" LIBS=$ORIG_LIBS @@ -4094,12 +4293,13 @@ AS_IF([test "${ARCH_FLAG}"], [ rb_cv_warnflags=`echo "$rb_cv_warnflags" | sed 's/^ *//;s/ *$//'` warnflags="$rb_cv_warnflags" AC_SUBST(cppflags)dnl -AC_SUBST(cflags, ["${orig_cflags:+$orig_cflags }"'${optflags} ${debugflags} ${warnflags}'])dnl +AC_SUBST(cflags, ['${hardenflags} '"${orig_cflags:+$orig_cflags }"' ${optflags} ${debugflags} ${warnflags}'])dnl AC_SUBST(cxxflags)dnl AC_SUBST(optflags)dnl AC_SUBST(debugflags)dnl AC_SUBST(warnflags)dnl AC_SUBST(strict_warnflags)dnl +AC_SUBST(hardenflags)dnl AC_SUBST(XCFLAGS)dnl AC_SUBST(XLDFLAGS)dnl AC_SUBST(EXTLDFLAGS)dnl @@ -4132,6 +4332,7 @@ AC_SUBST(MINIOBJS) AC_SUBST(THREAD_MODEL) AC_SUBST(COROUTINE_TYPE, ${coroutine_type}) AC_SUBST(PLATFORM_DIR) +AC_SUBST(USE_LLVM_WINDRES) firstmf=`echo $FIRSTMAKEFILE | sed 's/:.*//'` firsttmpl=`echo $FIRSTMAKEFILE | sed 's/.*://'` @@ -4283,6 +4484,10 @@ AS_IF([test "${universal_binary-no}" = yes ], [ arch="${target_cpu}-${target_os}" ]) AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "$arch") + + AS_IF([test "$arch" = "s390x-linux"], [ + AC_DEFINE_UNQUOTED(USE_MN_THREADS, 0) + ]) ]) unset sitearch @@ -4387,7 +4592,7 @@ guard=INCLUDE_RUBY_CONFIG_H { echo "#ifndef $guard" echo "#define $guard 1" - grep -v "^#define PACKAGE_" confdefs.h + sed "/^@%:@define PACKAGE_/d;s/ *$//" confdefs.h echo "#endif /* $guard */" } | tr -d '\015' | ( @@ -4475,6 +4680,9 @@ AC_CONFIG_FILES(Makefile:template/Makefile.in, [ ], [ echo 'distclean-local::; @$(RM) GNUmakefile uncommon.mk' ]) + + echo; echo '$(srcdir)/$(CONFIGURE):RUBY_M4_INCLUDED \ + $(empty)' } > $tmpmk && AS_IF([! grep '^ruby:' $tmpmk > /dev/null], [ AS_IF([test "${gnumake}" = yes], [ tmpgmk=confgmk$$.tmp @@ -4505,7 +4713,6 @@ AC_SUBST(DESTDIR) AC_OUTPUT } -} AS_IF([test "$silent" = yes], [], [ AS_IF([${FOLD+:} false], [], [ @@ -4542,6 +4749,7 @@ config_summary "target OS" "$target_os" config_summary "compiler" "$CC" config_summary "with thread" "$THREAD_MODEL" config_summary "with coroutine" "$coroutine_type" +config_summary "with shared GC" "$with_shared_gc" config_summary "enable shared libs" "$ENABLE_SHARED" config_summary "dynamic library ext" "$DLEXT" config_summary "CFLAGS" "$cflags" @@ -4551,10 +4759,11 @@ config_summary "DLDFLAGS" "$DLDFLAGS" config_summary "optflags" "$optflags" config_summary "debugflags" "$debugflags" config_summary "warnflags" "$warnflags" +config_summary "hardenflags" "$hardenflags" config_summary "strip command" "$STRIP" config_summary "install doc" "$DOCTARGETS" -config_summary "MJIT support" "$MJIT_SUPPORT" config_summary "YJIT support" "$YJIT_SUPPORT" +config_summary "RJIT support" "$RJIT_SUPPORT" config_summary "man page type" "$MANTYPE" config_summary "search path" "$search_path" config_summary "static-linked-ext" ${EXTSTATIC:+"yes"} |