aboutsummaryrefslogtreecommitdiff
path: root/Makefile.tpl
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 /Makefile.tpl
parentbf8cdd35117dea2049abbeebcdf14de11b323ef7 (diff)
downloadgcc-4a5e71f2348adcc49939804889d9f1a64d97005a.zip
gcc-4a5e71f2348adcc49939804889d9f1a64d97005a.tar.gz
gcc-4a5e71f2348adcc49939804889d9f1a64d97005a.tar.bz2
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 'Makefile.tpl')
-rw-r--r--Makefile.tpl63
1 files changed, 61 insertions, 2 deletions
diff --git a/Makefile.tpl b/Makefile.tpl
index 736b6a6..268bbc7 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -450,6 +450,49 @@ LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
GOCFLAGS = $(CFLAGS)
GDCFLAGS = $(CFLAGS)
+# Pass additional PGO and LTO compiler options to the PGO build.
+BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)
+override CFLAGS += $(BUILD_CFLAGS)
+override CXXFLAGS += $(BUILD_CFLAGS)
+
+# Additional PGO and LTO compiler options to generate profiling data
+# for the PGO build.
+PGO_BUILD_GEN_FLAGS_TO_PASS = \
+ PGO_BUILD_CFLAGS="@PGO_BUILD_GEN_CFLAGS@" \
+ PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@"
+
+# NB: Filter out any compiler options which may fail PGO training runs.
+PGO_BUILD_TRAINING_CFLAGS:= \
+ $(filter-out -Werror=%,$(CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:=\
+ $(filter-out -Werror=%,$(CXXFLAGS))
+PGO_BUILD_TRAINING_CFLAGS:= \
+ $(filter-out -Wall,$(PGO_BUILD_TRAINING_CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:= \
+ $(filter-out -Wall,$(PGO_BUILD_TRAINING_CXXFLAGS))
+PGO_BUILD_TRAINING_CFLAGS:= \
+ $(filter-out -specs=%,$(PGO_BUILD_TRAINING_CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:= \
+ $(filter-out -specs=%,$(PGO_BUILD_TRAINING_CXXFLAGS))
+PGO_BUILD_TRAINING_FLAGS_TO_PASS = \
+ PGO_BUILD_TRAINING=yes \
+ CFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CFLAGS)" \
+ CXXFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CXXFLAGS)"
+
+# Ignore "make check" errors in PGO training runs.
+PGO_BUILD_TRAINING_MFLAGS = -i
+
+# Additional PGO and LTO compiler options to use profiling data for the
+# PGO build.
+PGO_BUILD_USE_FLAGS_TO_PASS = \
+ PGO_BUILD_CFLAGS="@PGO_BUILD_USE_CFLAGS@" \
+ PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@"
+
+# PGO training targets for the PGO build. FIXME: Add gold tests to
+# training.
+PGO-TRAINING-TARGETS = binutils gas gdb ld sim
+PGO_BUILD_TRAINING = $(addprefix maybe-check-,$(PGO-TRAINING-TARGETS))
+
CREATE_GCOV = create_gcov
TFLAGS =
@@ -784,6 +827,12 @@ configure-target: [+
# The target built for a native non-bootstrap build.
.PHONY: all
+
+# --enable-pgo-build enables the PGO build.
+# 1. First build with -fprofile-generate.
+# 2. Use "make maybe-check-*" to generate profiling data.
+# 3. Use "make clean" to remove the previous build.
+# 4. Rebuild with -fprofile-use.
all:
@if gcc-bootstrap
[ -f stage_final ] || echo stage3 > stage_final
@@ -792,7 +841,7 @@ all:
$(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble
@endif gcc-bootstrap
@: $(MAKE); $(unstage)
- @r=`${PWD_COMMAND}`; export r; \
+ +@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
@if gcc-bootstrap
if [ -f stage_last ]; then \
@@ -800,7 +849,17 @@ all:
$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
else \
@endif gcc-bootstrap
- $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target \
+ $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+ $(PGO_BUILD_GEN_FLAGS_TO_PASS) all-host all-target \
+@if pgo-build
+ && $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+ $(PGO_BUILD_TRAINING_MFLAGS) \
+ $(PGO_BUILD_TRAINING_FLAGS_TO_PASS) \
+ $(PGO_BUILD_TRAINING) \
+ && $(MAKE) $(RECURSE_FLAGS_TO_PASS) clean \
+ && $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+ $(PGO_BUILD_USE_FLAGS_TO_PASS) all-host all-target \
+@endif pgo-build
@if gcc-bootstrap
; \
fi \