summaryrefslogtreecommitdiffstats
path: root/configure.ac
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.ac
parentSync with binutils: GCC: Pass --plugin to AR and RANLIB (diff)
downloadgcc-4a5e71f2348adcc49939804889d9f1a64d97005a.tar.gz
gcc-4a5e71f2348adcc49939804889d9f1a64d97005a.tar.bz2
gcc-4a5e71f2348adcc49939804889d9f1a64d97005a.tar.xz
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.ac')
-rw-r--r--configure.ac65
1 files changed, 65 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index ce1e764e872..5a8ef70444d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1466,6 +1466,65 @@ elif test "$have_compiler" = yes; then
1466 fi 1466 fi
1467fi 1467fi
1468 1468
1469AC_ARG_ENABLE([pgo-build],
1470[AS_HELP_STRING([--enable-pgo-build[[=lto]]],
1471 [enable the PGO build])],
1472[enable_pgo_build=$enableval],
1473[enable_pgo_build=no])
1474
1475# Issue errors and warnings for invalid/strange PGO build combinations.
1476case "$have_compiler:$host:$target:$enable_pgo_build" in
1477 *:*:*:no) ;;
1478
1479 # Allow the PGO build only if we aren't building a compiler and
1480 # we are in a native configuration.
1481 no:$build:$build:yes | no:$build:$build:lto) ;;
1482
1483 # Disallow the PGO bootstrap if we are building a compiler.
1484 yes:*:*:yes | yes:*:*:lto)
1485 AC_MSG_ERROR([cannot perform the PGO bootstrap when building a compiler]) ;;
1486
1487 *)
1488 AC_MSG_ERROR([invalid option for --enable-pgo-build])
1489 ;;
1490esac
1491
1492if test "$enable_pgo_build" != "no"; then
1493 AC_MSG_CHECKING([whether the compiler supports -fprofile-generate])
1494 old_CFLAGS="$CFLAGS"
1495 PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
1496 CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
1497 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
1498 [PGO_BUILD_GEN_CFLAGS=])
1499 CFLAGS="$old_CFLAGS"
1500 if test -n "$PGO_BUILD_GEN_CFLAGS"; then
1501 AC_MSG_RESULT([yes])
1502 PGO_BUILD_USE_CFLAGS="-fprofile-use"
1503 else
1504 AC_MSG_RESULT([no])
1505 AC_MSG_ERROR([cannot perform the PGO build without -fprofile-generate])
1506 fi
1507
1508 if test "$enable_pgo_build" = "lto"; then
1509 AC_MSG_CHECKING([whether the compiler supports -flto=jobserver -ffat-lto-objects])
1510 old_CFLAGS="$CFLAGS"
1511 PGO_BUILD_LTO_CFLAGS="-flto=jobserver -ffat-lto-objects"
1512 CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
1513 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
1514 [PGO_BUILD_LTO_CFLAGS=])
1515 CFLAGS="$old_CFLAGS"
1516 if test -n "$PGO_BUILD_LTO_CFLAGS"; then
1517 AC_MSG_RESULT([yes])
1518 else
1519 AC_MSG_RESULT([no])
1520 AC_MSG_WARN([LTO is disabled for the PGO build])
1521 fi
1522 fi
1523fi
1524AC_SUBST(PGO_BUILD_GEN_CFLAGS)
1525AC_SUBST(PGO_BUILD_USE_CFLAGS)
1526AC_SUBST(PGO_BUILD_LTO_CFLAGS)
1527
1469# Used for setting $lt_cv_objdir 1528# Used for setting $lt_cv_objdir
1470_LT_CHECK_OBJDIR 1529_LT_CHECK_OBJDIR
1471 1530
@@ -2997,6 +3056,12 @@ extrasub_target="$extrasub_target
2997/^@unless /d 3056/^@unless /d
2998/^@endunless /d" 3057/^@endunless /d"
2999 3058
3059if test "$enable_pgo_build" != "no"; then
3060 extrasub_build="$extrasub_build
3061/^@if pgo-build\$/d
3062/^@endif pgo-build\$/d"
3063fi
3064
3000# Create the serialization dependencies. This uses a temporary file. 3065# Create the serialization dependencies. This uses a temporary file.
3001 3066
3002AC_ARG_ENABLE([serial-configure], 3067AC_ARG_ENABLE([serial-configure],