Skip to content

Commit c6661bd

Browse files
authored
gh-124948: Reject explicit Cortex-A53 workaround flags with BOLT (gh-160337)
1 parent d98f2cb commit c6661bd

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

‎Doc/using/configure.rst‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,24 @@ also be used to improve performance.
763763
BOLT versions before LLVM 16 are known to crash BOLT under some scenarios.
764764
Use of LLVM 16 or newer for BOLT optimization is strongly encouraged.
765765

766+
BOLT does not preserve protection against Cortex-A53 erratum 843419. Binaries
767+
processed by BOLT must not run on processors affected by this erratum,
768+
including during the build. On AArch64, :program:`configure` reports an error
769+
if build flags explicitly request the workaround. Recent BOLT versions reject
770+
workaround veneers by default during the build, including when the workaround
771+
is enabled by compiler defaults.
772+
773+
If none of the generated executables or shared libraries will run on affected
774+
processors, disable the workaround explicitly. For GCC toolchains that enable
775+
it by default, pass ``-mno-fix-cortex-a53-843419`` through
776+
:envvar:`LDFLAGS_NODIST`::
777+
778+
LDFLAGS_NODIST="-mno-fix-cortex-a53-843419" ./configure --enable-bolt
779+
780+
Remove any explicit ``-mfix-cortex-a53-843419`` or
781+
``-Wl,--fix-cortex-a53-843419`` flags from the build configuration. The GCC
782+
option does not override explicit linker flags.
783+
766784
The :envvar:`!BOLT_INSTRUMENT_FLAGS` and :envvar:`!BOLT_APPLY_FLAGS`
767785
:program:`configure` variables can be defined to override the default set of
768786
arguments for :program:`llvm-bolt` to instrument and apply BOLT data to
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Report a configuration error when ``--enable-bolt`` is used with build flags
2+
that explicitly request the Cortex-A53 erratum 843419 workaround. Document how to
3+
disable the workaround for builds that will not run on affected processors.

‎configure‎

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,24 @@ if test "$Py_BOLT" = 'true' ; then
22122212
CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition"
22132213
])
22142214

2215+
# BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers,
2216+
# see https://github.com/llvm/llvm-project/pull/187955
2217+
# Check explicit flags here to provide a friendlier error. Recent BOLT
2218+
# versions reject workaround veneers by default, including those
2219+
# from compiler defaults, so we do not perform exhaustive detection.
2220+
AS_CASE([$host_cpu], [aarch64*], [
2221+
AS_CASE(["$CC $CFLAGS $CPPFLAGS $CFLAGS_NODIST $LDFLAGS $LDFLAGS_NODIST $LIBS"],
2222+
[*-mfix-cortex-a53-843419*|*--fix-cortex-a53-843419*], [
2223+
AC_MSG_ERROR([--enable-bolt is incompatible with the Cortex-A53 erratum 843419 workaround.
2224+
BOLT does not preserve protection against this erratum. Its output must not run
2225+
on affected Cortex-A53 processors, including during the build.
2226+
If the generated binaries will never run on affected processors, disable the
2227+
workaround explicitly. With GCC, configure with
2228+
LDFLAGS_NODIST="-mno-fix-cortex-a53-843419". Also remove any explicit
2229+
-mfix-cortex-a53-843419 or -Wl,--fix-cortex-a53-843419 flags.])
2230+
])
2231+
])
2232+
22152233
# These flags are required for bolt to work:
22162234
LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs"
22172235

0 commit comments

Comments
 (0)