]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix autoprofiledbootstrap build
authorEugene Rozenfeld <erozen@microsoft.com>
Mon, 21 Nov 2022 21:33:38 +0000 (13:33 -0800)
committerEugene Rozenfeld <erozen@microsoft.com>
Fri, 28 Apr 2023 20:15:33 +0000 (13:15 -0700)
1. Fix gcov version
2. Merge perf data collected when compiling the compiler and runtime libraries
3. Fix documentation typo

Tested on x86_64-pc-linux-gnu.

ChangeLog:

* Makefile.in: Define PROFILE_MERGER
* Makefile.tpl: Define PROFILE_MERGER

gcc/c/ChangeLog:

* Make-lang.in: Merge perf data collected when compiling cc1 and runtime libraries

gcc/cp/ChangeLog:

* Make-lang.in: Merge perf data collected when compiling cc1plus and runtime libraries

gcc/lto/ChangeLog:

* Make-lang.in: Merge perf data collected when compiling lto1 and runtime libraries

gcc/ChangeLog:

* doc/install.texi: Fix documentation typo

Makefile.in
Makefile.tpl
gcc/c/Make-lang.in
gcc/cp/Make-lang.in
gcc/doc/install.texi
gcc/lto/Make-lang.in

index 06a9398e172212a21a7ec540a0cf196dbd268cc7..33f3c8625577172209dab458e06b54dd4012d672 100644 (file)
@@ -491,6 +491,7 @@ PGO-TRAINING-TARGETS = binutils gas gdb ld sim
 PGO_BUILD_TRAINING = $(addprefix maybe-check-,$(PGO-TRAINING-TARGETS))
 
 CREATE_GCOV = create_gcov
+PROFILE_MERGER = profile_merger
 
 TFLAGS =
 
@@ -971,7 +972,8 @@ EXTRA_HOST_FLAGS = \
        'STRIP=$(STRIP)' \
        'WINDRES=$(WINDRES)' \
        'WINDMC=$(WINDMC)' \
-       'CREATE_GCOV=$(CREATE_GCOV)'
+       'CREATE_GCOV=$(CREATE_GCOV)' \
+       'PROFILE_MERGER=$(PROFILE_MERGER)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
 
index dfbd74b68f8df71f0ea80ce173411b9b297ba10e..9d8ef9cf678485480eabdeddd7a426a9476ef53a 100644 (file)
@@ -494,6 +494,7 @@ PGO-TRAINING-TARGETS = binutils gas gdb ld sim
 PGO_BUILD_TRAINING = $(addprefix maybe-check-,$(PGO-TRAINING-TARGETS))
 
 CREATE_GCOV = create_gcov
+PROFILE_MERGER = profile_merger
 
 TFLAGS =
 
@@ -728,7 +729,8 @@ EXTRA_HOST_FLAGS = \
        'STRIP=$(STRIP)' \
        'WINDRES=$(WINDRES)' \
        'WINDMC=$(WINDMC)' \
-       'CREATE_GCOV=$(CREATE_GCOV)'
+       'CREATE_GCOV=$(CREATE_GCOV)' \
+       'PROFILE_MERGER=$(PROFILE_MERGER)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
 
index b3b12dcffee6e2d1402e6a891c4be83200c1641e..20840aceab611fb7bb8936ec5a0316a7a4a5c34e 100644 (file)
@@ -88,9 +88,34 @@ cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
          cc1-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
        @$(call LINK_PROGRESS,$(INDEX.c),end)
 
-cc1.fda: ../stage1-gcc/cc1$(exeext) ../prev-gcc/$(PERF_DATA)
-       $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov cc1.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
-
+components_in_prev = "bfd opcodes binutils fixincludes gas gcc gmp mpfr mpc isl gold intl ld libbacktrace libcpp libcody libdecnumber libiberty libiberty-linker-plugin libiconv zlib lto-plugin libctf libsframe"
+components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace libphobos zlib libgomp libatomic"
+
+.PHONY: create_fdas_for_cc1
+
+cc1.fda: create_fdas_for_cc1
+       $(PROFILE_MERGER) $(shell ls -ha cc1_*.fda) --output_file cc1.fda -gcov_version 2
+
+create_fdas_for_cc1: ../stage1-gcc/cc1$(exeext) ../prev-gcc/$(PERF_DATA)
+       for component_in_prev in "$(components_in_prev)"; do \
+         perf_path=../prev-$$component_in_prev/$(PERF_DATA); \
+         echo "Perf path:"; \
+         echo $$perf_path; \
+         if [ -f $$perf_path ]; then \
+           profile_name=cc1_$$component_in_prev.fda; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
+         fi; \
+       done;
+
+       for component_in_prev_target in "$(components_in_prev_target)"; do \
+         perf_path=../prev-$(TARGET_SUBDIR)/$$component_in_prev_target/$(PERF_DATA); \
+         echo "Perf path:"; \
+         echo $$perf_path; \
+         if [ -f $$perf_path ]; then \
+           profile_name=cc1_$$component_in_prev_target.fda; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
+         fi; \
+       done;
 #\f
 # Build hooks:
 
@@ -181,6 +206,7 @@ c.mostlyclean:
        -rm -f c/*$(objext)
        -rm -f c/*$(coverageexts)
        -rm -f cc1.fda
+       -rm -f cc1_*.fda
 c.clean:
 c.distclean:
        -rm -f c/config.status c/Makefile
index 4ee26fad93d646afd7c1bb2d47472ba80da9fae7..c08ee91447e62e7b82fa575a6b6d6ba12258227e 100644 (file)
@@ -186,9 +186,34 @@ endif
 # This is the file that depends on the generated header file.
 cp/name-lookup.o: $(srcdir)/cp/std-name-hint.h
 
-cc1plus.fda: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
-       $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov cc1plus.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
-
+components_in_prev = "bfd opcodes binutils fixincludes gas gcc gmp mpfr mpc isl gold intl ld libbacktrace libcpp libcody libdecnumber libiberty libiberty-linker-plugin libiconv zlib lto-plugin libctf libsframe"
+components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace libphobos zlib libgomp libatomic"
+
+.PHONY: create_fdas_for_cc1plus
+
+cc1plus.fda: create_fdas_for_cc1plus
+       $(PROFILE_MERGER) $(shell ls -ha cc1plus_*.fda) --output_file cc1plus.fda -gcov_version 2
+
+create_fdas_for_cc1plus: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
+       for component_in_prev in "$(components_in_prev)"; do \
+         perf_path=../prev-$$component_in_prev/$(PERF_DATA); \
+         echo "Perf path:"; \
+         echo $$perf_path; \
+         if [ -f $$perf_path ]; then \
+           profile_name=cc1plus_$$component_in_prev.fda; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
+         fi; \
+       done;
+
+       for component_in_prev_target in "$(components_in_prev_target)"; do \
+         perf_path=../prev-$(TARGET_SUBDIR)/$$component_in_prev_target/$(PERF_DATA); \
+         echo "Perf path:"; \
+         echo $$perf_path; \
+         if [ -f $$perf_path ]; then \
+           profile_name=cc1plus_$$component_in_prev_target.fda; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
+         fi; \
+       done;
 #\f
 # Build hooks:
 
@@ -335,7 +360,7 @@ c++.mostlyclean:
        -rm -f doc/g++.1
        -rm -f cp/*$(objext)
        -rm -f cp/*$(coverageexts)
-       -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus.fda
+       -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus*.fda
 c++.clean:
 c++.distclean:
        -rm -f cp/config.status cp/Makefile
index 928fc6b6d4b0d24de3bb2d94a0aa7e74b406685f..fa91ce1953d4323ace6e90e954f41b3feab459b1 100644 (file)
@@ -3119,7 +3119,7 @@ It is recommended to only use GCC for this.
 
 On Linux/x86_64 hosts with some restrictions (no virtualization) it is
 also possible to do autofdo build with @samp{make
-autoprofiledback}. This uses Linux perf to sample branches in the
+autoprofiledbootstrap}. This uses Linux perf to sample branches in the
 binary and then rebuild it with feedback derived from the profile.
 Linux perf and the @code{autofdo} toolkit needs to be installed for
 this.
index b3b965e44f792a4eb09d41c8d39544faa15bfbf6..4f6025100a3e9d68db8f6a98624822f704364605 100644 (file)
@@ -74,7 +74,7 @@ lto.srcinfo:
 lto.install-plugin:
 
 lto.mostlyclean:
-       rm -f $(LTO_OBJS) $(LTO_EXE) lto1.fda $(LTO_DUMP_OBJS) $(LTO_DUMP_EXE) lto-dump.fda
+       rm -f $(LTO_OBJS) $(LTO_EXE) lto1*.fda $(LTO_DUMP_OBJS) $(LTO_DUMP_EXE) lto-dump.fda
 
 lto.clean:
 lto.distclean:
@@ -105,8 +105,34 @@ $(LTO_DUMP_EXE): $(LTO_DUMP_OBJS) $(BACKEND) $(LIBDEPS) $(lto2.prev)
 
 lto/lto-dump.o: $(LTO_OBJS)
 
-lto1.fda: ../prev-gcc/lto1$(exeext) ../prev-gcc/$(PERF_DATA)
-       $(CREATE_GCOV) -binary ../prev-gcc/lto1$(exeext) -gcov lto1.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
+components_in_prev = "bfd opcodes binutils fixincludes gas gcc gmp mpfr mpc isl gold intl ld libbacktrace libcpp libcody libdecnumber libiberty libiberty-linker-plugin libiconv zlib lto-plugin libctf libsframe"
+components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace libphobos zlib libgomp libatomic"
+
+.PHONY: create_fdas_for_lto1
+
+lto1.fda: create_fdas_for_lto1
+       $(PROFILE_MERGER) $(shell ls -ha lto1_*.fda) --output_file lto1.fda -gcov_version 2
+
+create_fdas_for_lto1: ../stage1-gcc/lto1$(exeext) ../prev-gcc/$(PERF_DATA)
+       for component_in_prev in "$(components_in_prev)"; do \
+         perf_path=../prev-$$component_in_prev/$(PERF_DATA); \
+         echo "Perf path:"; \
+         echo $$perf_path; \
+         if [ -f $$perf_path ]; then \
+           profile_name=lto1_$$component_in_prev.fda; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
+         fi; \
+       done;
+
+       for component_in_prev_target in "$(components_in_prev_target)"; do \
+         perf_path=../prev-$(TARGET_SUBDIR)/$$component_in_prev_target/$(PERF_DATA); \
+         echo "Perf path:"; \
+         echo $$perf_path; \
+         if [ -f $$perf_path ]; then \
+           profile_name=lto1_$$component_in_prev_target.fda; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
+         fi; \
+       done;
 
 # LTO testing is done as part of C/C++/Fortran etc. testing.
 check-lto: