[Python-checkins] gh-101060: conditionally add `-fno-reorder-blocks-and-partition` (gh-101061)

corona10 webhook-mailer at python.org
Tue Jan 24 04:34:50 EST 2023


https://github.com/python/cpython/commit/7589d713a14a1efbb0cbb7caa9fdbad2b081cf18
commit: 7589d713a14a1efbb0cbb7caa9fdbad2b081cf18
branch: main
author: Gregory Szorc <gregory.szorc at gmail.com>
committer: corona10 <donghee.na92 at gmail.com>
date: 2023-01-24T18:34:44+09:00
summary:

gh-101060: conditionally add `-fno-reorder-blocks-and-partition` (gh-101061)

files:
A Misc/NEWS.d/next/Build/2023-01-15-11-22-15.gh-issue-101060.0mYk9E.rst
M configure
M configure.ac

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 000000000000..bebbf8c898d5
--- /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 e4ec5c40fd7a..709913dee831 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 15412054856f..12249b2d4729 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:



More information about the Python-checkins mailing list