From 7589d713a14a1efbb0cbb7caa9fdbad2b081cf18 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Tue, 24 Jan 2023 01:34:44 -0800 Subject: [PATCH] gh-101060: conditionally add `-fno-reorder-blocks-and-partition` (gh-101061) --- ...-01-15-11-22-15.gh-issue-101060.0mYk9E.rst | 3 ++ configure | 41 ++++++++++++++++++- configure.ac | 7 +++- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2023-01-15-11-22-15.gh-issue-101060.0mYk9E.rst diff --git a/Misc/NEWS.d/next/Build/2023-01-15-11-22-15.gh-issue-101060.0mYk9E.rst b/Misc/NEWS.d/next/Build/2023-01-15-11-22-15.gh-issue-101060.0mYk9E.rst new file mode 100644 index 00000000000000..bebbf8c898d547 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-01-15-11-22-15.gh-issue-101060.0mYk9E.rst @@ -0,0 +1,3 @@ +Conditionally add ``-fno-reorder-blocks-and-partition`` in configure. +Effectively fixes ``--enable-bolt`` when using Clang, as this appears to be +a GCC-only flag. diff --git a/configure b/configure index e4ec5c40fd7a36..709913dee8314d 100755 --- a/configure +++ b/configure @@ -7914,8 +7914,47 @@ if test "$Py_BOLT" = 'true' ; then DEF_MAKE_ALL_RULE="bolt-opt" DEF_MAKE_RULE="build_all" + # -fno-reorder-blocks-and-partition is required for bolt to work. + # Possibly GCC only. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fno-reorder-blocks-and-partition" >&5 +$as_echo_n "checking whether C compiler accepts -fno-reorder-blocks-and-partition... " >&6; } +if ${ax_cv_check_cflags___fno_reorder_blocks_and_partition+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -fno-reorder-blocks-and-partition" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___fno_reorder_blocks_and_partition=yes +else + ax_cv_check_cflags___fno_reorder_blocks_and_partition=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fno_reorder_blocks_and_partition" >&5 +$as_echo "$ax_cv_check_cflags___fno_reorder_blocks_and_partition" >&6; } +if test "x$ax_cv_check_cflags___fno_reorder_blocks_and_partition" = xyes; then : + + CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" + +else + : +fi + + # These flags are required for bolt to work: - CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" # These flags are required to get good performance from bolt: diff --git a/configure.ac b/configure.ac index 15412054856fe4..12249b2d472900 100644 --- a/configure.ac +++ b/configure.ac @@ -1939,8 +1939,13 @@ if test "$Py_BOLT" = 'true' ; then DEF_MAKE_ALL_RULE="bolt-opt" DEF_MAKE_RULE="build_all" + # -fno-reorder-blocks-and-partition is required for bolt to work. + # Possibly GCC only. + AX_CHECK_COMPILE_FLAG([-fno-reorder-blocks-and-partition],[ + CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" + ]) + # These flags are required for bolt to work: - CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" # These flags are required to get good performance from bolt: