summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-11-13 06:11:41 -0800
committerH.J. Lu <hjl.tools@gmail.com>2021-12-15 14:20:49 -0800
commit4a5e71f2348adcc49939804889d9f1a64d97005a (patch)
tree6c16473f5b0033713a80c1f62e241cd0fd0d91b1 /configure
parentbf8cdd35117dea2049abbeebcdf14de11b323ef7 (diff)
Sync with binutils: Support the PGO build for binutils+gdb
Sync with binutils for building binutils with LTO: 1dbde357be3 Add missing changes to Makefile.tpl af019bfde9b Support the PGO build for binutils+gdb Add the --enable-pgo-build[=lto] configure option. When binutils+gdb is not built together with GCC, --enable-pgo-build enables the PGO build: 1. First build with -fprofile-generate. 2. Use "make maybe-check-*" to generate profiling data and pass -i to make to ignore errors when generating profiling data. 3. Use "make clean" to remove the previous build. 4. Rebuild with -fprofile-use. With --enable-pgo-build=lto, -flto=jobserver -ffat-lto-objects are used together with -fprofile-generate and -fprofile-use. Add '+' to the command line for recursive make to support -flto=jobserver -ffat-lto-objects. NB: --enable-pgo-build=lto enables the PGO build with LTO while --enable-lto enables LTO support in toolchain. BZ binutils/26766 * Makefile.tpl (BUILD_CFLAGS): New. (CFLAGS): Append $(BUILD_CFLAGS). (CXXFLAGS): Likewise. (PGO_BUILD_GEN_FLAGS_TO_PASS): New. (PGO_BUILD_TRAINING_CFLAGS): Likewise. (PGO_BUILD_TRAINING_CXXFLAGS): Likewise. (PGO_BUILD_TRAINING_FLAGS_TO_PASS): Likewise. (PGO_BUILD_TRAINING_MFLAGS): Likewise. (PGO_BUILD_USE_FLAGS_TO_PASS): Likewise. (PGO-TRAINING-TARGETS): Likewise. (PGO_BUILD_TRAINING): Likewise. (all): Add '+' to the command line for recursive make. Support the PGO build. * configure.ac: Add --enable-pgo-build[=lto]. AC_SUBST PGO_BUILD_GEN_CFLAGS, PGO_BUILD_USE_CFLAGS and PGO_BUILD_LTO_CFLAGS. Enable the PGO build in Makefile. * Makefile.in: Regenerated. * configure: Likewise.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure100
1 files changed, 98 insertions, 2 deletions
diff --git a/configure b/configure
index c569b28dc6c..97d2a554019 100755
--- a/configure
+++ b/configure
@@ -702,6 +702,9 @@ extra_mpc_gmp_configure_flags
extra_mpfr_configure_flags
gmpinc
gmplibs
+PGO_BUILD_LTO_CFLAGS
+PGO_BUILD_USE_CFLAGS
+PGO_BUILD_GEN_CFLAGS
HAVE_CXX11_FOR_BUILD
HAVE_CXX11
do_compare
@@ -806,6 +809,7 @@ enable_libssp
enable_libstdcxx
enable_liboffloadmic
enable_bootstrap
+enable_pgo_build
with_mpc
with_mpc_include
with_mpc_lib
@@ -1546,6 +1550,8 @@ Optional Features:
--enable-liboffloadmic=ARG
build liboffloadmic [ARG={no,host,target}]
--enable-bootstrap enable bootstrapping [yes if native build]
+ --enable-pgo-build[=lto]
+ enable the PGO build
--disable-isl-version-check
disable check for isl version
--enable-lto enable link time optimization support
@@ -7812,6 +7818,91 @@ $as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h
fi
fi
+# Check whether --enable-pgo-build was given.
+if test "${enable_pgo_build+set}" = set; then :
+ enableval=$enable_pgo_build; enable_pgo_build=$enableval
+else
+ enable_pgo_build=no
+fi
+
+
+# Issue errors and warnings for invalid/strange PGO build combinations.
+case "$have_compiler:$host:$target:$enable_pgo_build" in
+ *:*:*:no) ;;
+
+ # Allow the PGO build only if we aren't building a compiler and
+ # we are in a native configuration.
+ no:$build:$build:yes | no:$build:$build:lto) ;;
+
+ # Disallow the PGO bootstrap if we are building a compiler.
+ yes:*:*:yes | yes:*:*:lto)
+ as_fn_error $? "cannot perform the PGO bootstrap when building a compiler" "$LINENO" 5 ;;
+
+ *)
+ as_fn_error $? "invalid option for --enable-pgo-build" "$LINENO" 5
+ ;;
+esac
+
+if test "$enable_pgo_build" != "no"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fprofile-generate" >&5
+$as_echo_n "checking whether the compiler supports -fprofile-generate... " >&6; }
+ old_CFLAGS="$CFLAGS"
+ PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
+ CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ PGO_BUILD_GEN_CFLAGS=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$old_CFLAGS"
+ if test -n "$PGO_BUILD_GEN_CFLAGS"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PGO_BUILD_USE_CFLAGS="-fprofile-use"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "cannot perform the PGO build without -fprofile-generate" "$LINENO" 5
+ fi
+
+ if test "$enable_pgo_build" = "lto"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -flto=jobserver -ffat-lto-objects" >&5
+$as_echo_n "checking whether the compiler supports -flto=jobserver -ffat-lto-objects... " >&6; }
+ old_CFLAGS="$CFLAGS"
+ PGO_BUILD_LTO_CFLAGS="-flto=jobserver -ffat-lto-objects"
+ CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ PGO_BUILD_LTO_CFLAGS=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$old_CFLAGS"
+ if test -n "$PGO_BUILD_LTO_CFLAGS"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: LTO is disabled for the PGO build" >&5
+$as_echo "$as_me: WARNING: LTO is disabled for the PGO build" >&2;}
+ fi
+ fi
+fi
+
+
+
+
# Used for setting $lt_cv_objdir
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
$as_echo_n "checking for objdir... " >&6; }
@@ -8001,8 +8092,7 @@ if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
# Check for the recommended and required versions of GMP.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of gmp.h" >&5
$as_echo_n "checking for the correct version of gmp.h... " >&6; }
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include "gmp.h"
int
@@ -9780,6 +9870,12 @@ extrasub_target="$extrasub_target
/^@unless /d
/^@endunless /d"
+if test "$enable_pgo_build" != "no"; then
+ extrasub_build="$extrasub_build
+/^@if pgo-build\$/d
+/^@endif pgo-build\$/d"
+fi
+
# Create the serialization dependencies. This uses a temporary file.
# Check whether --enable-serial-configure was given.