Revert autoconf macros defining RUBY_AARCH64_{BTI|PAC}_ENABLED

This partially reverts https://github.com/ruby/ruby/pull/10944; now that
we decided to pass CFLAGS to $(CC) when assembling .S files, we don't
need these autoconf macros that capture the state of
__ARM_FEATURE{PAC|BTI}_DEFAULT.

[Bug #20601]
This commit is contained in:
KJ Tsanaktsidis 2024-07-06 14:51:43 +10:00
parent b18701a7ae
commit b940de83de
2 changed files with 10 additions and 60 deletions

View file

@ -1006,58 +1006,6 @@ 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,