Skip to content

Commit 6ff63d9

Browse files
committed
Merge branch 'tt/profile-build-fix'
* tt/profile-build-fix: Makefile: fix syntax for older make Fix build problems related to profile-directed optimization
2 parents a784482 + e60ec75 commit 6ff63d9

File tree

2 files changed

+50
-22
lines changed

2 files changed

+50
-22
lines changed

INSTALL

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,25 @@ set up install paths (via config.mak.autogen), so you can write instead
2828
If you're willing to trade off (much) longer build time for a later
2929
faster git you can also do a profile feedback build with
3030

31-
$ make profile-all
32-
# make prefix=... install
31+
$ make prefix=/usr PROFILE=BUILD all
32+
# make prefix=/usr PROFILE=BUILD install
3333

3434
This will run the complete test suite as training workload and then
3535
rebuild git with the generated profile feedback. This results in a git
3636
which is a few percent faster on CPU intensive workloads. This
3737
may be a good tradeoff for distribution packagers.
3838

39-
Note that the profile feedback build stage currently generates
40-
a lot of additional compiler warnings.
39+
Or if you just want to install a profile-optimized version of git into
40+
your home directory, you could run:
41+
42+
$ make PROFILE=BUILD install
43+
44+
As a caveat: a profile-optimized build takes a *lot* longer since the
45+
git tree must be built twice, and in order for the profiling
46+
measurements to work properly, ccache must be disabled and the test
47+
suite has to be run using only a single CPU. In addition, the profile
48+
feedback build stage currently generates a lot of additional compiler
49+
warnings.
4150

4251
Issues of note:
4352

Makefile

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,26 @@ ifdef ASCIIDOC7
17771777
export ASCIIDOC7
17781778
endif
17791779

1780+
### profile feedback build
1781+
#
1782+
1783+
# Can adjust this to be a global directory if you want to do extended
1784+
# data gathering
1785+
PROFILE_DIR := $(CURDIR)
1786+
1787+
ifeq ("$(PROFILE)","GEN")
1788+
CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
1789+
EXTLIBS += -lgcov
1790+
export CCACHE_DISABLE=t
1791+
V=1
1792+
else
1793+
ifneq ("$(PROFILE)","")
1794+
CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
1795+
export CCACHE_DISABLE=t
1796+
V=1
1797+
endif
1798+
endif
1799+
17801800
# Shell quote (do not use $(call) to accommodate ancient setups);
17811801

17821802
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
@@ -1833,7 +1853,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH
18331853

18341854
SHELL = $(SHELL_PATH)
18351855

1836-
all:: shell_compatibility_test $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
1856+
all:: shell_compatibility_test
1857+
1858+
ifeq "$(PROFILE)" "BUILD"
1859+
ifeq ($(filter all,$(MAKECMDGOALS)),all)
1860+
all:: profile-clean
1861+
$(MAKE) PROFILE=GEN all
1862+
$(MAKE) PROFILE=GEN -j1 test
1863+
endif
1864+
endif
1865+
1866+
all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
18371867
ifneq (,$X)
18381868
$(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
18391869
endif
@@ -2581,7 +2611,11 @@ distclean: clean
25812611
$(RM) configure
25822612
$(RM) po/git.pot
25832613

2584-
clean:
2614+
profile-clean:
2615+
$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2616+
$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2617+
2618+
clean: profile-clean
25852619
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
25862620
builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
25872621
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
@@ -2611,7 +2645,7 @@ ifndef NO_TCLTK
26112645
endif
26122646
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
26132647

2614-
.PHONY: all install clean strip
2648+
.PHONY: all install profile-clean clean strip
26152649
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
26162650
.PHONY: FORCE cscope
26172651

@@ -2721,18 +2755,3 @@ cover_db: coverage-report
27212755
cover_db_html: cover_db
27222756
cover -report html -outputdir cover_db_html cover_db
27232757

2724-
### profile feedback build
2725-
#
2726-
.PHONY: profile-all profile-clean
2727-
2728-
PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1
2729-
PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1
2730-
2731-
profile-clean:
2732-
$(RM) $(addsuffix *.gcda,$(object_dirs))
2733-
$(RM) $(addsuffix *.gcno,$(object_dirs))
2734-
2735-
profile-all: profile-clean
2736-
$(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" all
2737-
$(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" -j1 test
2738-
$(MAKE) CFLAGS="$(PROFILE_USE_CFLAGS)" all

0 commit comments

Comments
 (0)