Skip to content

Commit 655c3ed

Browse files
committed
Merge branch 'tt/profile-build-fix' into maint
* tt/profile-build-fix: Makefile: fix syntax for older make Fix build problems related to profile-directed optimization
2 parents 014578e + e60ec75 commit 655c3ed

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
@@ -1771,6 +1771,26 @@ ifdef ASCIIDOC7
17711771
export ASCIIDOC7
17721772
endif
17731773

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

17761796
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
@@ -1827,7 +1847,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH
18271847

18281848
SHELL = $(SHELL_PATH)
18291849

1830-
all:: shell_compatibility_test $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
1850+
all:: shell_compatibility_test
1851+
1852+
ifeq "$(PROFILE)" "BUILD"
1853+
ifeq ($(filter all,$(MAKECMDGOALS)),all)
1854+
all:: profile-clean
1855+
$(MAKE) PROFILE=GEN all
1856+
$(MAKE) PROFILE=GEN -j1 test
1857+
endif
1858+
endif
1859+
1860+
all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
18311861
ifneq (,$X)
18321862
$(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';)
18331863
endif
@@ -2555,7 +2585,11 @@ distclean: clean
25552585
$(RM) configure
25562586
$(RM) po/git.pot
25572587

2558-
clean:
2588+
profile-clean:
2589+
$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2590+
$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2591+
2592+
clean: profile-clean
25592593
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
25602594
builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
25612595
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
@@ -2585,7 +2619,7 @@ ifndef NO_TCLTK
25852619
endif
25862620
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
25872621

2588-
.PHONY: all install clean strip
2622+
.PHONY: all install profile-clean clean strip
25892623
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
25902624
.PHONY: FORCE cscope
25912625

@@ -2695,18 +2729,3 @@ cover_db: coverage-report
26952729
cover_db_html: cover_db
26962730
cover -report html -outputdir cover_db_html cover_db
26972731

2698-
### profile feedback build
2699-
#
2700-
.PHONY: profile-all profile-clean
2701-
2702-
PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1
2703-
PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1
2704-
2705-
profile-clean:
2706-
$(RM) $(addsuffix *.gcda,$(object_dirs))
2707-
$(RM) $(addsuffix *.gcno,$(object_dirs))
2708-
2709-
profile-all: profile-clean
2710-
$(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" all
2711-
$(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" -j1 test
2712-
$(MAKE) CFLAGS="$(PROFILE_USE_CFLAGS)" all

0 commit comments

Comments
 (0)