From 4719ed671a8a8e10b77c4748a0e1ee63c19dfefb Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Wed, 17 Sep 2025 11:25:49 +0000 Subject: [PATCH] 8366777: Build fails unknown pseudo-op with old AS on linux-aarch64 Reviewed-by: erikj, ihse --- make/autoconf/flags-cflags.m4 | 42 -------------------------- make/autoconf/flags-other.m4 | 56 +++++++++++++++++++++++++++++++++++ make/autoconf/flags.m4 | 1 + 3 files changed, 57 insertions(+), 42 deletions(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 6072cbc74dd..0e2825d14b0 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -934,48 +934,6 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], IF_FALSE: [$2FDLIBM_CFLAGS=""]) fi AC_SUBST($2FDLIBM_CFLAGS) - - # Check whether the compiler supports the Arm C Language Extensions (ACLE) - # for SVE. Set SVE_CFLAGS to -march=armv8-a+sve if it does. - # ACLE and this flag are required to build the aarch64 SVE related functions in - # libvectormath. Apple Silicon does not support SVE; use macOS as a proxy for - # that check. - if test "x$OPENJDK_TARGET_CPU" = "xaarch64" && test "x$OPENJDK_TARGET_OS" = "xlinux"; then - if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then - AC_LANG_PUSH(C) - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -march=armv8-a+sve" - AC_MSG_CHECKING([if Arm SVE ACLE is supported]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], - [ - svint32_t r = svdup_n_s32(1); - return 0; - ])], - [ - AC_MSG_RESULT([yes]) - $2SVE_CFLAGS="-march=armv8-a+sve" - # Switching the initialization mode with gcc from 'pattern' to 'zero' - # avoids the use of unsupported `__builtin_clear_padding` for variable - # length aggregates - if test "x$DEBUG_LEVEL" != xrelease && test "x$TOOLCHAIN_TYPE" = xgcc ; then - INIT_ZERO_FLAG="-ftrivial-auto-var-init=zero" - FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$INIT_ZERO_FLAG], - IF_TRUE: [ - $2SVE_CFLAGS="${$2SVE_CFLAGS} $INIT_ZERO_FLAG" - ] - ) - fi - ], - [ - AC_MSG_RESULT([no]) - $2SVE_CFLAGS="" - ] - ) - CFLAGS="$OLD_CFLAGS" - AC_LANG_POP(C) - fi - fi - AC_SUBST($2SVE_CFLAGS) ]) AC_DEFUN_ONCE([FLAGS_SETUP_BRANCH_PROTECTION], diff --git a/make/autoconf/flags-other.m4 b/make/autoconf/flags-other.m4 index 9d41cf04791..4570f6ede78 100644 --- a/make/autoconf/flags-other.m4 +++ b/make/autoconf/flags-other.m4 @@ -107,6 +107,62 @@ AC_DEFUN([FLAGS_SETUP_NMFLAGS], AC_SUBST(NMFLAGS) ]) +# Check whether the compiler supports the Arm C Language Extensions (ACLE) +# for SVE. Set SVE_CFLAGS to -march=armv8-a+sve if it does. +# ACLE and this flag are required to build the aarch64 SVE related functions +# in libvectormath. +AC_DEFUN([FLAGS_SETUP_SVE], +[ + AARCH64_SVE_AVAILABLE=false + # Apple Silicon does not support SVE; use macOS as a proxy for that check. + if test "x$OPENJDK_TARGET_CPU" = "xaarch64" && test "x$OPENJDK_TARGET_OS" = "xlinux"; then + if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + # check the compiler and binutils support sve or not + AC_MSG_CHECKING([if Arm SVE ACLE is supported]) + AC_LANG_PUSH([C]) + saved_cflags="$CFLAGS" + CFLAGS="$CFLAGS -march=armv8-a+sve $CFLAGS_WARNINGS_ARE_ERRORS ARG_ARGUMENT" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [ + #include + svfloat64_t a() {} + ], + [ + svint32_t r = svdup_n_s32(1) + ])], + [ + AARCH64_SVE_AVAILABLE=true + ] + ) + CFLAGS="$saved_cflags" + AC_LANG_POP([C]) + AC_MSG_RESULT([$AARCH64_SVE_AVAILABLE]) + fi + fi + + UTIL_ARG_ENABLE(NAME: aarch64-sve, DEFAULT: auto, + RESULT: AARCH64_SVE_ENABLED, + DESC: [Use SVE when compiling libsleef], + AVAILABLE: $AARCH64_SVE_AVAILABLE) + SVE_CFLAGS="" + if test "x$AARCH64_SVE_ENABLED" = xtrue; then + SVE_CFLAGS="-march=armv8-a+sve" + # Switching the initialization mode with gcc from 'pattern' to 'zero' + # avoids the use of unsupported `__builtin_clear_padding` for variable + # length aggregates + if test "x$DEBUG_LEVEL" != xrelease && test "x$TOOLCHAIN_TYPE" = xgcc ; then + AC_MSG_CHECKING([Switching the initialization mode with gcc from pattern to zero]) + INIT_ZERO_FLAG="-ftrivial-auto-var-init=zero" + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$INIT_ZERO_FLAG], + IF_TRUE: [ + SVE_CFLAGS="${SVE_CFLAGS} $INIT_ZERO_FLAG" + ] + ) + fi + fi + AC_SUBST(SVE_CFLAGS) +]) + ################################################################################ # platform independent AC_DEFUN([FLAGS_SETUP_ASFLAGS], diff --git a/make/autoconf/flags.m4 b/make/autoconf/flags.m4 index c810d15ebbc..10647305757 100644 --- a/make/autoconf/flags.m4 +++ b/make/autoconf/flags.m4 @@ -374,6 +374,7 @@ AC_DEFUN([FLAGS_SETUP_FLAGS], FLAGS_SETUP_RCFLAGS FLAGS_SETUP_NMFLAGS + FLAGS_SETUP_SVE FLAGS_SETUP_ASFLAGS FLAGS_SETUP_ASFLAGS_CPU_DEP([TARGET]) FLAGS_SETUP_ASFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])