From d512b296a978f723db79b4730713be3cd04cceeb Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Wed, 21 Oct 2026 14:54:28 -0700 Subject: [PATCH 1/2] gh-128884: Update BOLT optimization option to prevent crash --- ...-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst | 3 + configure | 56 ++++++++++++++++++- configure.ac | 15 ++++- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst diff --git a/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst b/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst new file mode 100644 index 00000000000000..38d62d9799ebea --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst @@ -0,0 +1,3 @@ +Fix ``--enable-bolt`` build failures on AArch64 with recent LLVM: pass +``-frame-opt=hot`` only on x86 and link with ``-mno-fix-cortex-a53-843419`` +when supported. Patch by Donghee Na. diff --git a/configure b/configure index 38fd8575530e8a..59502e544760c3 100755 --- a/configure +++ b/configure @@ -9495,6 +9495,53 @@ esac fi + # BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers, + # see https://github.com/llvm/llvm-project/pull/187955 + # GCC only: Clang neither accepts the flag nor adds the workaround on Linux. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mno-fix-cortex-a53-843419" >&5 +printf %s "checking whether C compiler accepts -mno-fix-cortex-a53-843419... " >&6; } +if test ${ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror -mno-fix-cortex-a53-843419" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419=yes +else case e in #( + e) ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$ax_check_save_flags ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419" >&5 +printf "%s\n" "$ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419" >&6; } +if test "x$ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419" = xyes +then : + + LDFLAGS_NODIST="$LDFLAGS_NODIST -mno-fix-cortex-a53-843419" + +else case e in #( + e) : ;; +esac +fi + + # These flags are required for bolt to work: LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" @@ -9780,7 +9827,14 @@ printf "%s\n" "$BOLT_INSTRUMENT_FLAGS" >&6; } printf %s "checking BOLT_APPLY_FLAGS... " >&6; } if test -z "${BOLT_APPLY_FLAGS}" then - BOLT_APPLY_FLAGS=" ${BOLT_COMMON_FLAGS} -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions -icf=0 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot " + case $host_cpu in #( + x86_64) : + bolt_frame_opt_flags="-frame-opt=hot" ;; #( + *) : + bolt_frame_opt_flags="" + ;; +esac + BOLT_APPLY_FLAGS=" ${BOLT_COMMON_FLAGS} -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions -icf=0 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack ${bolt_frame_opt_flags} " fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BOLT_APPLY_FLAGS" >&5 diff --git a/configure.ac b/configure.ac index 777ced94454594..07767461a52028 100644 --- a/configure.ac +++ b/configure.ac @@ -2212,6 +2212,13 @@ if test "$Py_BOLT" = 'true' ; then CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" ]) + # BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers, + # see https://github.com/llvm/llvm-project/pull/187955 + # GCC only: Clang neither accepts the flag nor adds the workaround on Linux. + AX_CHECK_COMPILE_FLAG([-mno-fix-cortex-a53-843419],[ + LDFLAGS_NODIST="$LDFLAGS_NODIST -mno-fix-cortex-a53-843419" + ], [], [-Werror]) + # These flags are required for bolt to work: LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" @@ -2288,6 +2295,12 @@ AC_ARG_VAR( AC_MSG_CHECKING([BOLT_APPLY_FLAGS]) if test -z "${BOLT_APPLY_FLAGS}" then + dnl The frame optimizer is only implemented for x86. BOLT 22 and newer + dnl refuse to run it on other architectures. + AS_CASE([$host_cpu], + [x86_64], [bolt_frame_opt_flags="-frame-opt=hot"], + [bolt_frame_opt_flags=""] + ) AS_VAR_SET( [BOLT_APPLY_FLAGS], [m4_normalize(" @@ -2305,7 +2318,7 @@ then -indirect-call-promotion=all -dyno-stats -use-gnu-stack - -frame-opt=hot + ${bolt_frame_opt_flags} ")] ) fi From 30016d18a6f575f32845fe6198573c0bb8c4b929 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Wed, 21 Oct 2026 17:12:33 -0700 Subject: [PATCH 2/2] Update --- ...-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst | 3 +- configure | 47 ------------------- configure.ac | 7 --- 3 files changed, 1 insertion(+), 56 deletions(-) diff --git a/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst b/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst index 38d62d9799ebea..53233d06c5053a 100644 --- a/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst +++ b/Misc/NEWS.d/next/Build/2026-10-21-14-52-56.gh-issue-128884.Xs5jK-.rst @@ -1,3 +1,2 @@ Fix ``--enable-bolt`` build failures on AArch64 with recent LLVM: pass -``-frame-opt=hot`` only on x86 and link with ``-mno-fix-cortex-a53-843419`` -when supported. Patch by Donghee Na. +``-frame-opt=hot`` only on x86. Patch by Donghee Na. diff --git a/configure b/configure index 59502e544760c3..a0682ff03422e1 100755 --- a/configure +++ b/configure @@ -9495,53 +9495,6 @@ esac fi - # BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers, - # see https://github.com/llvm/llvm-project/pull/187955 - # GCC only: Clang neither accepts the flag nor adds the workaround on Linux. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mno-fix-cortex-a53-843419" >&5 -printf %s "checking whether C compiler accepts -mno-fix-cortex-a53-843419... " >&6; } -if test ${ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -Werror -mno-fix-cortex-a53-843419" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419=yes -else case e in #( - e) ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS=$ax_check_save_flags ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419" >&5 -printf "%s\n" "$ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419" >&6; } -if test "x$ax_cv_check_cflags__Werror__mno_fix_cortex_a53_843419" = xyes -then : - - LDFLAGS_NODIST="$LDFLAGS_NODIST -mno-fix-cortex-a53-843419" - -else case e in #( - e) : ;; -esac -fi - - # These flags are required for bolt to work: LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" diff --git a/configure.ac b/configure.ac index 07767461a52028..90eae31482d2e7 100644 --- a/configure.ac +++ b/configure.ac @@ -2212,13 +2212,6 @@ if test "$Py_BOLT" = 'true' ; then CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" ]) - # BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers, - # see https://github.com/llvm/llvm-project/pull/187955 - # GCC only: Clang neither accepts the flag nor adds the workaround on Linux. - AX_CHECK_COMPILE_FLAG([-mno-fix-cortex-a53-843419],[ - LDFLAGS_NODIST="$LDFLAGS_NODIST -mno-fix-cortex-a53-843419" - ], [], [-Werror]) - # These flags are required for bolt to work: LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs"