]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101060: conditionally add `-fno-reorder-blocks-and-partition` (gh-101061)
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 24 Jan 2023 09:34:44 +0000 (01:34 -0800)
committerGitHub <noreply@github.com>
Tue, 24 Jan 2023 09:34:44 +0000 (18:34 +0900)
Misc/NEWS.d/next/Build/2023-01-15-11-22-15.gh-issue-101060.0mYk9E.rst [new file with mode: 0644]
configure
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 (file)
index 0000000..bebbf8c
--- /dev/null
@@ -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.
index e4ec5c40fd7a367cb524c9a387bc7712e9b4a8d7..709913dee8314d727794618a36bc85795f7b9e88 100755 (executable)
--- 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:
index 15412054856fe45439eff726f4c3ed0cf71eafaf..12249b2d472900ace127dc823af0bfa3c53d9950 100644 (file)
@@ -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: