{"thread":{"id":"29526","subject":"[PATCH, RFC] Fix build problems related to profile-directed optimization","startedAt":"2012-02-02T19:03:37Z","lastAt":"2012-02-09T18:22:38Z","messageCount":18,"participants":["Theodore Ts'o","Junio C Hamano","Ted Ts'o","Theodore Tso","Andi Kleen","Jeff King","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"183632","messageId":"1328209417-8206-1-git-send-email-tytso@mit.edu","threadId":"29526","inReplyTo":null,"subject":"[PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-02T19:03:37Z","receivedAt":"2012-02-02T19:03:37Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"There was a number of problems I ran into when trying the\nprofile-directed optimizations added by Andi Kleen in git commit\n7ddc2710b9.  (This was using gcc 4.4 found on many enterprise\ndistros.)\n\n1) The -fprofile-generate and -fprofile-use commands are incompatible\nwith ccache; the code ends up looking in the wrong place for the gcda\nfiles based on the ccache object names.\n\n2) If the makefile notices that CFLAGS are different, it will rebuild\nall of the binaries.  Hence the recipe originally specified by the\nINSTALL file (\"make profile-all\" followed by \"make install\") doesn't\nwork.  It will appear to work, but the binaries will end up getting\nbuilt with no optimization.\n\nThis patch fixes this by using an explicit set of options passed via\nPROFILE_GEN and PROFILE_USE and then using these to directly\nmanipulate CFLAGS and EXTLIBS.\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\nCc: Andi Kleen <ak@linux.intel.com>\n---\n INSTALL  |    4 ++--\n Makefile |   31 +++++++++++++++++++++++--------\n 2 files changed, 25 insertions(+), 10 deletions(-)\n\ndiff --git a/INSTALL b/INSTALL\nindex 6fa83fe..978ed09 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -28,8 +28,8 @@ set up install paths (via config.mak.autogen), so you can write instead\n If you're willing to trade off (much) longer build time for a later\n faster git you can also do a profile feedback build with\n \n-\t$ make profile-all\n-\t# make prefix=... install\n+\t$ make prefix=... profile-all\n+\t# make prefix=... PROFILE_USE=t install\n \n This will run the complete test suite as training workload and then\n rebuild git with the generated profile feedback. This results in a git\ndiff --git a/Makefile b/Makefile\nindex c457c34..15d1df4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1772,6 +1772,24 @@ ifdef ASCIIDOC7\n \texport ASCIIDOC7\n endif\n \n+### profile feedback build\n+#\n+\n+# Can adjust this to be a global directory if you want to do extended\n+# data gathering\n+PROFILE_DIR := $(CURDIR)\n+\n+ifdef PROFILE_GEN\n+\tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n+\tEXTLIBS += -lgcov\n+\texport CCACHE_DISABLE=t\n+endif\n+\n+ifdef PROFILE_USE\n+\tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n+\texport CCACHE_DISABLE=t\n+endif\n+\n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n SHA1_HEADER_SQ = $(subst ','\\'',$(SHA1_HEADER))\n@@ -2701,14 +2719,11 @@ cover_db_html: cover_db\n #\n .PHONY: profile-all profile-clean\n \n-PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1\n-PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1\n-\n profile-clean:\n-\t$(RM) $(addsuffix *.gcda,$(object_dirs))\n-\t$(RM) $(addsuffix *.gcno,$(object_dirs))\n+\t$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n+\t$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n \n profile-all: profile-clean\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" all\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" -j1 test\n-\t$(MAKE) CFLAGS=\"$(PROFILE_USE_CFLAGS)\" all\n+\t$(MAKE) PROFILE_GEN=t all\n+\t$(MAKE) PROFILE_GEN=t -j1 test\n+\t$(MAKE) PROFILE_USE=t all\n-- \n1.7.8.11.gefc1f.dirty\n"},{"id":"183646","messageId":"7vvcnpuhpo.fsf@alter.siamese.dyndns.org","threadId":"29526","inReplyTo":"1328209417-8206-1-git-send-email-tytso@mit.edu","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-02T20:02:27Z","receivedAt":"2012-02-02T20:02:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Theodore Ts'o <tytso@mit.edu> writes:\n\n> diff --git a/INSTALL b/INSTALL\n> index 6fa83fe..978ed09 100644\n> --- a/INSTALL\n> +++ b/INSTALL\n> @@ -28,8 +28,8 @@ set up install paths (via config.mak.autogen), so you can write instead\n>  If you're willing to trade off (much) longer build time for a later\n>  faster git you can also do a profile feedback build with\n>  \n> -\t$ make profile-all\n> -\t# make prefix=... install\n> +\t$ make prefix=... profile-all\n> +\t# make prefix=... PROFILE_USE=t install\n\nThanks for a patch.  How does this compare with what was discussed in the\nother thread?\n\n  http://thread.gmane.org/gmane.comp.version-control.git/188992/focus=189172\n\nI would wish a solution ideally would support\n\n\tmake PROFILE_BUILD=YesPlease\n        make PROFILE_BUILD=YesPlease install\n\nor even\n\n\techo >>config.mak PROFILE_BUILD\n        make\n        su make install\n\nand I think your patch takes us in the right direction.\n"},{"id":"183653","messageId":"20120202201226.GA1032@thunk.org","threadId":"29526","inReplyTo":"7vvcnpuhpo.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Ted Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-02T20:12:26Z","receivedAt":"2012-02-02T20:12:26Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Thu, Feb 02, 2012 at 12:02:27PM -0800, Junio C Hamano wrote:\n> \n> Thanks for a patch.  How does this compare with what was discussed in the\n> other thread?\n> \n>   http://thread.gmane.org/gmane.comp.version-control.git/188992/focus=189172\n\nI wasn't aware of this other approach when I created this patch (I\nmust have missed the e-mail thread, sorry).\n\nOne of the reasons why I did it this way was for more flexibility.  I\nwanted to be able to do:\n\n$ make PROFILE_GEN=YesPlease PROFILE_DIR=/var/cache/FDO all\n# make PROFILE_GEN=YesPlease PROFILE_DIR=/var/cache/FDO install\n\nrun a bunch of git commands on various git repositories to get\nreal-life usage...\n\nThen do...\n\n$ make PROFILE_USE=YesPlease PROFILE_DIR=/var/cache/FDO all\n# make PROFILE_GEN=YesPlease PROFILE_DIR=/var/cache/FDO install\n\nBut for many people they would probably be satisfied with something\nthat builds git using a single magic recipe, even if they give up some\nfractional performance improvement (keep in mind that the feedback\ndirected optimization seems to buy you only a single digit percentage\nimprovement according according to Andi's original experiment; I just\ngot interested in this more for amusement value than any thought that\nit would save me serious amounts of time).\n\n> I would wish a solution ideally would support\n> \n> \tmake PROFILE_BUILD=YesPlease\n>         make PROFILE_BUILD=YesPlease install\n\nAt least in theory, it should be possible to have something which\nsupports both PROFILE_GEN/PROFILE_USE as well as a combined\nPROFILE_BUILD.\n\nThe hard part is that PROFILE_BUILD requires a multi-pass process; you\nneed to build with one set of CFLAGS, then run the sample workload to\nget the data for your feedback directed optimizations, and then re-run\nthe build with another set of CFLAGS.  I think what we could to check\nfor PROFILE_BUILD, and if it is set, do the first PROFILE_GEN / make\ntest commands as part of the top-level Makefile's all: rule, and then\ndo the normal build after that.\n\nIt's a little kludgy, but does that sound acceptable to you?\n\n       \t      \t      \t       \t    \t  - Ted\n"},{"id":"183654","messageId":"20120202201458.GB1032@thunk.org","threadId":"29526","inReplyTo":"20120202201226.GA1032@thunk.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Ted Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-02T20:14:58Z","receivedAt":"2012-02-02T20:14:58Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Thu, Feb 02, 2012 at 03:12:26PM -0500, Ted Ts'o wrote:\n> Then do...\n> \n> $ make PROFILE_USE=YesPlease PROFILE_DIR=/var/cache/FDO all\n> # make PROFILE_GEN=YesPlease PROFILE_DIR=/var/cache/FDO install\n\nErr, that last line should have been:\n\n# make PROFILE_USE=YesPlease PROFILE_DIR=/var/cache/FDO install\n\nof course...\n\n\t\t\t\t\t- Ted\n"},{"id":"183683","messageId":"7vvcnou40u.fsf@alter.siamese.dyndns.org","threadId":"29526","inReplyTo":"20120202201226.GA1032@thunk.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-03T00:58:09Z","receivedAt":"2012-02-03T00:58:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ted Ts'o <tytso@mit.edu> writes:\n\n> ...\n> At least in theory, it should be possible to have something which\n> supports both PROFILE_GEN/PROFILE_USE as well as a combined\n> PROFILE_BUILD.\n>\n> The hard part is that PROFILE_BUILD requires a multi-pass process; you\n> need to build with one set of CFLAGS, then run the sample workload to\n> get the data for your feedback directed optimizations, and then re-run\n> the build with another set of CFLAGS.\n\nYeah, I can see how that forces us to some kludgy solution, but I tend to\nagree that the separation between GEN/USE is a good thing.\n\n> I think what we could to check\n> for PROFILE_BUILD, and if it is set, do the first PROFILE_GEN / make\n> test commands as part of the top-level Makefile's all: rule, and then\n> do the normal build after that.\n\nYeah, something like that would emulate the \"make profile-all\" well enough\nfor people not to notice the change while giving us the flexibility of\nGEN/USE separation. I kinda like it.\n\nThanks.\n"},{"id":"183692","messageId":"20120203020743.GE1032@thunk.org","threadId":"29526","inReplyTo":"7vvcnou40u.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Ted Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-03T02:07:43Z","receivedAt":"2012-02-03T02:07:43Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"What do you think of this?  I'm still running a test build --- \"make\nPROFILE=BUILD all\" takes quite a long time, so this is still an RFC; I\nfigure there will still be some places where people will point out\nmore nits to be polished.  :-)\n\n(In particular, I just noticed I left the V=1 for debugging purposes\nin this version....)\n\n\t      \t   \t       \t      - Ted\n\n>From 4bf14e732216fd1327da2e3c8c6dfc0a3f689e1b Mon Sep 17 00:00:00 2001\nFrom: Theodore Ts'o <tytso@mit.edu>\nDate: Thu, 2 Feb 2012 13:56:22 -0500\nSubject: [PATCH] Fix build problems related to profile-directed optimization\n\nThere was a number of problems I ran into when trying the\nprofile-directed optimizations added by Andi Kleen in git commit\n7ddc2710b9.  (This was using gcc 4.4 found on many enterprise\ndistros.)\n\n1) The -fprofile-generate and -fprofile-use commands are incompatible\nwith ccache; the code ends up looking in the wrong place for the gcda\nfiles based on the ccache object names.\n\n2) If the makefile notices that CFLAGS are different, it will rebuild\nall of the binaries.  Hence the recipe originally specified by the\nINSTALL file (\"make profile-all\" followed by \"make install\") doesn't\nwork.  It will appear to work, but the binaries will end up getting\nbuilt with no optimization.\n\nThis patch fixes this by using an explicit set of options passed via\nthe PROFILE variable then using this to directly manipulate CFLAGS and\nEXTLIBS.\n\nThe developer can run \"make PROFILE=BUILD all ; make PROFILE=BUILD\ninstall\" to do an automatic two-pass build using the test suite as the\nsample workload for the purpose of profiling.\n\nAlternatively, the profiling version of binaries can be built using:\n\n\tmake PROFILE=GEN PROFILE_DIR=/var/cache/profile all\n\tmake PROFILE=GEN install\n\nand then after git has been used a number of times, the optimized\nversion of the binary can be built as follows:\n\n\tmake PROFILE=USE PROFILE_DIR=/var/cache/profile all\n\tmake PROFILE=USE install\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\nCc: Andi Kleen <ak@linux.intel.com>\n---\n INSTALL  |    4 ++--\n Makefile |   41 ++++++++++++++++++++++++++++++-----------\n 2 files changed, 32 insertions(+), 13 deletions(-)\n\ndiff --git a/INSTALL b/INSTALL\nindex 6fa83fe..73b654b 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -28,8 +28,8 @@ set up install paths (via config.mak.autogen), so you can write instead\n If you're willing to trade off (much) longer build time for a later\n faster git you can also do a profile feedback build with\n \n-\t$ make profile-all\n-\t# make prefix=... install\n+\t$ make --prefix=/usr PROFILE=BUILD all\n+\t# make --prefix=/usr PROFILE=BUILD install\n \n This will run the complete test suite as training workload and then\n rebuild git with the generated profile feedback. This results in a git\ndiff --git a/Makefile b/Makefile\nindex c457c34..7d66d5c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1772,6 +1772,24 @@ ifdef ASCIIDOC7\n \texport ASCIIDOC7\n endif\n \n+### profile feedback build\n+#\n+\n+# Can adjust this to be a global directory if you want to do extended\n+# data gathering\n+PROFILE_DIR := $(CURDIR)\n+\n+ifeq \"$(PROFILE)\" \"GEN\"\n+\tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n+\tEXTLIBS += -lgcov\n+\texport CCACHE_DISABLE=t\n+\tV=1\n+else ifneq \"$PROFILE\" \"\"\n+\tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n+\texport CCACHE_DISABLE=t\n+\tV=1\n+endif\n+\n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n SHA1_HEADER_SQ = $(subst ','\\'',$(SHA1_HEADER))\n@@ -1828,7 +1846,15 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH\n \n SHELL = $(SHELL_PATH)\n \n-all:: shell_compatibility_test $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n+all:: shell_compatibility_test\n+\n+ifeq \"$(PROFILE)\" \"BUILD\"\n+all:: profile-clean\n+\t$(MAKE) PROFILE=GEN all\n+\t$(MAKE) PROFILE=GEN -j1 test\n+endif\n+\n+all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n ifneq (,$X)\n \t$(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';)\n endif\n@@ -2699,16 +2725,9 @@ cover_db_html: cover_db\n \n ### profile feedback build\n #\n-.PHONY: profile-all profile-clean\n-\n-PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1\n-PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1\n+.PHONY: profile-clean\n \n profile-clean:\n-\t$(RM) $(addsuffix *.gcda,$(object_dirs))\n-\t$(RM) $(addsuffix *.gcno,$(object_dirs))\n+\t$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n+\t$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n \n-profile-all: profile-clean\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" all\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" -j1 test\n-\t$(MAKE) CFLAGS=\"$(PROFILE_USE_CFLAGS)\" all\n-- \n1.7.8.11.gefc1f.dirty\n"},{"id":"183697","messageId":"7vr4ycsbga.fsf@alter.siamese.dyndns.org","threadId":"29526","inReplyTo":"20120203020743.GE1032@thunk.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-03T06:00:37Z","receivedAt":"2012-02-03T06:00:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ted Ts'o <tytso@mit.edu> writes:\n\n> What do you think of this?  I'm still running a test build --- \"make\n> PROFILE=BUILD all\" takes quite a long time, so this is still an RFC; I\n> figure there will still be some places where people will point out\n> more nits to be polished.  :-)\n>\n> (In particular, I just noticed I left the V=1 for debugging purposes\n> in this version....)\n\nThanks.\n\nThree comments:\n\n * I am happy that this version handles this well:\n\n   $ make PROFILE=BUILD install\n\n   even though you did not advertise as such in INSTALL ;-).\n\n * However, I think \"clean\" target should remove *.gcda unconditionally.\n\n   $ make PROFILE=BUILD install ; make clean ; git clean -n -x | grep gcda\n\n * Running \"make PROFILE=BUILD install\" immediately after another one,\n   without \"make clean\" in between, resulted in full rebuild and test\n   before the second \"install\", which somewhat surprised me.  I however do\n   not think this is a big show-stopper problem.\n"},{"id":"183747","messageId":"BEE56B27-1C86-4C26-A584-3FF179B7A3D6@mit.edu","threadId":"29526","inReplyTo":"7vr4ycsbga.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Theodore Tso","fromEmail":"tytso@mit.edu","sentAt":"2012-02-03T18:19:34Z","receivedAt":"2012-02-03T18:19:34Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"\nOn Feb 3, 2012, at 1:00 AM, Junio C Hamano wrote:\n\n> \n> * I am happy that this version handles this well:\n> \n>   $ make PROFILE=BUILD install\n> \n>   even though you did not advertise as such in INSTALL ;-).\n\nI can mention it, although it will mean adding more verbiage about profile-directed optimization into the INSTALL.\n\nMy assumption was that people who did this would usually be installing into --prefix=/usr as root, but there certainly will be anal people like myself who want to install profile-optimized binaries into ~/bin.  :-)\n\n> * However, I think \"clean\" target should remove *.gcda unconditionally.\n> \n>   $ make PROFILE=BUILD install ; make clean ; git clean -n -x | grep gcda\n\nWill fix.\n\n> * Running \"make PROFILE=BUILD install\" immediately after another one,\n>   without \"make clean\" in between, resulted in full rebuild and test\n>   before the second \"install\", which somewhat surprised me.  I however do\n>   not think this is a big show-stopper problem.\n\nHmm… that surprises me too.  If\n\n\tmake PROFILE=BUILD all\n\tmake PROFILE=BUILD install\n\nworks correctly, I don't understand why a second \"make PROFILE=BUILD install\" issued after the above sequence would result in complete rebuild and test pass, unless something in the \"make install\" rules is modifying the build tree as a side-effect of the install pass, which I'd argue is a bug.  I'll take a look at it.\n\n-- Ted\n"},{"id":"183749","messageId":"20120203183921.GA29944@tassilo.jf.intel.com","threadId":"29526","inReplyTo":"7vr4ycsbga.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Andi Kleen","fromEmail":"ak@linux.intel.com","sentAt":"2012-02-03T18:39:21Z","receivedAt":"2012-02-03T18:39:21Z","isPatch":true,"sender":{"key":"ak@linux.intel.com","avatar":null},"body":"\nThanks everyone for improving this.\n\nI should add that any improvements will depend on your compiler version.\nI would also expect better numbers when combined with LTO in gcc 4.7,\nbut haven't tried so far.\n\nBTW it would be really nice to figure out a subset of the test suite\nthat runs faster and gives similar speedup like the full one.\n\n-Andi\n-- \nak@linux.intel.com -- Speaking for myself only\n"},{"id":"183753","messageId":"7vaa4zpu2r.fsf@alter.siamese.dyndns.org","threadId":"29526","inReplyTo":"BEE56B27-1C86-4C26-A584-3FF179B7A3D6@mit.edu","subject":"Re: [PATCH, RFC] Fix build problems related to profile-directed optimization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-03T19:58:52Z","receivedAt":"2012-02-03T19:58:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Theodore Tso <tytso@MIT.EDU> writes:\n\n> On Feb 3, 2012, at 1:00 AM, Junio C Hamano wrote:\n>\n>> \n>> * I am happy that this version handles this well:\n>> \n>>   $ make PROFILE=BUILD install\n>> \n>>   even though you did not advertise as such in INSTALL ;-).\n>\n> I can mention it, although it will mean adding more verbiage about\n> profile-directed optimization into the INSTALL.\n\nOh, sorry, I didn't mean it that way.  Please read it as: \"Something that\nis a natural thing for people to expect after reading what is in INSTALL\nworks correctly. Yay! Thanks.\"\n"},{"id":"183947","messageId":"1328489090-14178-1-git-send-email-tytso@mit.edu","threadId":"29526","inReplyTo":"7vaa4zpu2r.fsf@alter.siamese.dyndns.org","subject":"[PATCH] Fix build problems related to profile-directed optimization","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-06T00:44:50Z","receivedAt":"2012-02-06T00:44:50Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"There was a number of problems I ran into when trying the\nprofile-directed optimizations added by Andi Kleen in git commit\n7ddc2710b9.  (This was using gcc 4.4 found on many enterprise\ndistros.)\n\n1) The -fprofile-generate and -fprofile-use commands are incompatible\nwith ccache; the code ends up looking in the wrong place for the gcda\nfiles based on the ccache object names.\n\n2) If the makefile notices that CFLAGS are different, it will rebuild\nall of the binaries.  Hence the recipe originally specified by the\nINSTALL file (\"make profile-all\" followed by \"make install\") doesn't\nwork.  It will appear to work, but the binaries will end up getting\nbuilt with no optimization.\n\nThis patch fixes this by using an explicit set of options passed via\nthe PROFILE variable then using this to directly manipulate CFLAGS and\nEXTLIBS.\n\nThe developer can run \"make PROFILE=BUILD all ; sudo make\nPROFILE=BUILD install\" automatically run a two-pass build with the\ntest suite run in between as the sample workload for the purpose of\nrecording profiling information to do the profile-directed\noptimization.\n\nAlternatively, the profiling version of binaries can be built using:\n\n\tmake PROFILE=GEN PROFILE_DIR=/var/cache/profile all\n\tmake PROFILE=GEN install\n\nand then after git has been used for a while, the optimized version of\nthe binary can be built as follows:\n\n\tmake PROFILE=USE PROFILE_DIR=/var/cache/profile all\n\tmake PROFILE=USE install\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\nCc: Andi Kleen <ak@linux.intel.com>\n---\n INSTALL  |   17 +++++++++++++----\n Makefile |   53 +++++++++++++++++++++++++++++++++++------------------\n 2 files changed, 48 insertions(+), 22 deletions(-)\n\ndiff --git a/INSTALL b/INSTALL\nindex 6fa83fe..5b7eec1 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -28,16 +28,25 @@ set up install paths (via config.mak.autogen), so you can write instead\n If you're willing to trade off (much) longer build time for a later\n faster git you can also do a profile feedback build with\n \n-\t$ make profile-all\n-\t# make prefix=... install\n+\t$ make --prefix=/usr PROFILE=BUILD all\n+\t# make --prefix=/usr PROFILE=BUILD install\n \n This will run the complete test suite as training workload and then\n rebuild git with the generated profile feedback. This results in a git\n which is a few percent faster on CPU intensive workloads.  This\n may be a good tradeoff for distribution packagers.\n \n-Note that the profile feedback build stage currently generates\n-a lot of additional compiler warnings.\n+Or if you just want to install a profile-optimized version of git into\n+your home directory, you could run:\n+\n+\t$ make PROFILE=BUILD install\n+\n+As a caveat: a profile-optimized build takes a *lot* longer since it\n+is the sources have to be built twice, and in order for the profiling\n+measurements to work properly, ccache must be disabled and the test\n+suite has to be run using only a single CPU.  In addition, the profile\n+feedback build stage currently generates a lot of additional compiler\n+warnings.\n \n Issues of note:\n \ndiff --git a/Makefile b/Makefile\nindex c457c34..8cea247 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1772,6 +1772,24 @@ ifdef ASCIIDOC7\n \texport ASCIIDOC7\n endif\n \n+### profile feedback build\n+#\n+\n+# Can adjust this to be a global directory if you want to do extended\n+# data gathering\n+PROFILE_DIR := $(CURDIR)\n+\n+ifeq \"$(PROFILE)\" \"GEN\"\n+\tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n+\tEXTLIBS += -lgcov\n+\texport CCACHE_DISABLE=t\n+\tV=1\n+else ifneq \"$PROFILE\" \"\"\n+\tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n+\texport CCACHE_DISABLE=t\n+\tV=1\n+endif\n+\n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n SHA1_HEADER_SQ = $(subst ','\\'',$(SHA1_HEADER))\n@@ -1828,7 +1846,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH\n \n SHELL = $(SHELL_PATH)\n \n-all:: shell_compatibility_test $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n+all:: shell_compatibility_test\n+\n+ifeq \"$(PROFILE)\" \"BUILD\"\n+ifeq ($(filter all,$(MAKECMDGOALS)),all)\n+all:: profile-clean\n+\t$(MAKE) PROFILE=GEN all\n+\t$(MAKE) PROFILE=GEN -j1 test\n+endif\n+endif\n+\n+all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n ifneq (,$X)\n \t$(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';)\n endif\n@@ -2557,7 +2585,11 @@ distclean: clean\n \t$(RM) configure\n \t$(RM) po/git.pot\n \n-clean:\n+profile-clean:\n+\t$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n+\t$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n+\n+clean: profile-clean\n \t$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \\\n \t\tbuiltin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)\n \t$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X\n@@ -2587,7 +2619,7 @@ ifndef NO_TCLTK\n endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS\n \n-.PHONY: all install clean strip\n+.PHONY: all install profile-clean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\n .PHONY: FORCE cscope\n \n@@ -2697,18 +2729,3 @@ cover_db: coverage-report\n cover_db_html: cover_db\n \tcover -report html -outputdir cover_db_html cover_db\n \n-### profile feedback build\n-#\n-.PHONY: profile-all profile-clean\n-\n-PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1\n-PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1\n-\n-profile-clean:\n-\t$(RM) $(addsuffix *.gcda,$(object_dirs))\n-\t$(RM) $(addsuffix *.gcno,$(object_dirs))\n-\n-profile-all: profile-clean\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" all\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" -j1 test\n-\t$(MAKE) CFLAGS=\"$(PROFILE_USE_CFLAGS)\" all\n-- \n1.7.9.107.g8e04a\n"},{"id":"183961","messageId":"20120206041839.GB29365@sigill.intra.peff.net","threadId":"29526","inReplyTo":"1328489090-14178-1-git-send-email-tytso@mit.edu","subject":"Re: [PATCH] Fix build problems related to profile-directed optimization","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-02-06T04:18:39Z","receivedAt":"2012-02-06T04:18:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Feb 05, 2012 at 07:44:50PM -0500, Theodore Ts'o wrote:\n\n> diff --git a/INSTALL b/INSTALL\n> index 6fa83fe..5b7eec1 100644\n> --- a/INSTALL\n> +++ b/INSTALL\n> @@ -28,16 +28,25 @@ set up install paths (via config.mak.autogen), so you can write instead\n>  If you're willing to trade off (much) longer build time for a later\n>  faster git you can also do a profile feedback build with\n>  \n> -\t$ make profile-all\n> -\t# make prefix=... install\n> +\t$ make --prefix=/usr PROFILE=BUILD all\n> +\t# make --prefix=/usr PROFILE=BUILD install\n\nEh? --prefix?\n\n> +As a caveat: a profile-optimized build takes a *lot* longer since it\n> +is the sources have to be built twice, and in order for the profiling\n\ns/it is//\n\n> diff --git a/Makefile b/Makefile\n> index c457c34..8cea247 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1772,6 +1772,24 @@ ifdef ASCIIDOC7\n> [...]\n> +ifeq \"$(PROFILE)\" \"GEN\"\n> +\tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n> +\tEXTLIBS += -lgcov\n> +\texport CCACHE_DISABLE=t\n> +\tV=1\n> +else ifneq \"$PROFILE\" \"\"\n> +\tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n> +\texport CCACHE_DISABLE=t\n> +\tV=1\n> +endif\n\nDid you mean \"$(PROFILE)\" in the second conditional?\n\n-Peff\n"},{"id":"183979","messageId":"20120206055750.GA6615@thunk.org","threadId":"29526","inReplyTo":"20120206041839.GB29365@sigill.intra.peff.net","subject":"Re: [PATCH] Fix build problems related to profile-directed optimization","fromName":"Ted Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-06T05:57:50Z","receivedAt":"2012-02-06T05:57:50Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Sun, Feb 05, 2012 at 11:18:39PM -0500, Jeff King wrote:\n> > -\t$ make profile-all\n> > -\t# make prefix=... install\n> > +\t$ make --prefix=/usr PROFILE=BUILD all\n> > +\t# make --prefix=/usr PROFILE=BUILD install\n> \n> Eh? --prefix?\n\nOops, configure meme strikes; will fix.\n\n> > +As a caveat: a profile-optimized build takes a *lot* longer since it\n> > +is the sources have to be built twice, and in order for the profiling\n> \n> s/it is//\n\nThanks, will fix.\n\n> > +ifeq \"$(PROFILE)\" \"GEN\"\n> > +\tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n> > +\tEXTLIBS += -lgcov\n> > +\texport CCACHE_DISABLE=t\n> > +\tV=1\n> > +else ifneq \"$PROFILE\" \"\"\n> \n> Did you mean \"$(PROFILE)\" in the second conditional?\n\nYes, thanks.   Will fix.\n\n\t\t\t\t\t\t- Ted\n"},{"id":"183980","messageId":"1328508017-7277-1-git-send-email-tytso@mit.edu","threadId":"29526","inReplyTo":"20120206055750.GA6615@thunk.org","subject":"[PATCH] Fix build problems related to profile-directed optimization","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-06T06:00:17Z","receivedAt":"2012-02-06T06:00:17Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"There was a number of problems I ran into when trying the\nprofile-directed optimizations added by Andi Kleen in git commit\n7ddc2710b9.  (This was using gcc 4.4 found on many enterprise\ndistros.)\n\n1) The -fprofile-generate and -fprofile-use commands are incompatible\nwith ccache; the code ends up looking in the wrong place for the gcda\nfiles based on the ccache object names.\n\n2) If the makefile notices that CFLAGS are different, it will rebuild\nall of the binaries.  Hence the recipe originally specified by the\nINSTALL file (\"make profile-all\" followed by \"make install\") doesn't\nwork.  It will appear to work, but the binaries will end up getting\nbuilt with no optimization.\n\nThis patch fixes this by using an explicit set of options passed via\nthe PROFILE variable then using this to directly manipulate CFLAGS and\nEXTLIBS.\n\nThe developer can run \"make PROFILE=BUILD all ; sudo make\nPROFILE=BUILD install\" automatically run a two-pass build with the\ntest suite run in between as the sample workload for the purpose of\nrecording profiling information to do the profile-directed\noptimization.\n\nAlternatively, the profiling version of binaries can be built using:\n\n\tmake PROFILE=GEN PROFILE_DIR=/var/cache/profile all\n\tmake PROFILE=GEN install\n\nand then after git has been used for a while, the optimized version of\nthe binary can be built as follows:\n\n\tmake PROFILE=USE PROFILE_DIR=/var/cache/profile all\n\tmake PROFILE=USE install\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\nCc: Andi Kleen <ak@linux.intel.com>\n---\n INSTALL  |   17 +++++++++++++----\n Makefile |   53 +++++++++++++++++++++++++++++++++++------------------\n 2 files changed, 48 insertions(+), 22 deletions(-)\n\ndiff --git a/INSTALL b/INSTALL\nindex 6fa83fe..58b2b86 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -28,16 +28,25 @@ set up install paths (via config.mak.autogen), so you can write instead\n If you're willing to trade off (much) longer build time for a later\n faster git you can also do a profile feedback build with\n \n-\t$ make profile-all\n-\t# make prefix=... install\n+\t$ make prefix=/usr PROFILE=BUILD all\n+\t# make prefix=/usr PROFILE=BUILD install\n \n This will run the complete test suite as training workload and then\n rebuild git with the generated profile feedback. This results in a git\n which is a few percent faster on CPU intensive workloads.  This\n may be a good tradeoff for distribution packagers.\n \n-Note that the profile feedback build stage currently generates\n-a lot of additional compiler warnings.\n+Or if you just want to install a profile-optimized version of git into\n+your home directory, you could run:\n+\n+\t$ make PROFILE=BUILD install\n+\n+As a caveat: a profile-optimized build takes a *lot* longer since the\n+git tree must be built twice, and in order for the profiling\n+measurements to work properly, ccache must be disabled and the test\n+suite has to be run using only a single CPU.  In addition, the profile\n+feedback build stage currently generates a lot of additional compiler\n+warnings.\n \n Issues of note:\n \ndiff --git a/Makefile b/Makefile\nindex c457c34..719ffca 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1772,6 +1772,24 @@ ifdef ASCIIDOC7\n \texport ASCIIDOC7\n endif\n \n+### profile feedback build\n+#\n+\n+# Can adjust this to be a global directory if you want to do extended\n+# data gathering\n+PROFILE_DIR := $(CURDIR)\n+\n+ifeq \"$(PROFILE)\" \"GEN\"\n+\tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n+\tEXTLIBS += -lgcov\n+\texport CCACHE_DISABLE=t\n+\tV=1\n+else ifneq \"$(PROFILE)\" \"\"\n+\tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n+\texport CCACHE_DISABLE=t\n+\tV=1\n+endif\n+\n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n SHA1_HEADER_SQ = $(subst ','\\'',$(SHA1_HEADER))\n@@ -1828,7 +1846,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH\n \n SHELL = $(SHELL_PATH)\n \n-all:: shell_compatibility_test $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n+all:: shell_compatibility_test\n+\n+ifeq \"$(PROFILE)\" \"BUILD\"\n+ifeq ($(filter all,$(MAKECMDGOALS)),all)\n+all:: profile-clean\n+\t$(MAKE) PROFILE=GEN all\n+\t$(MAKE) PROFILE=GEN -j1 test\n+endif\n+endif\n+\n+all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n ifneq (,$X)\n \t$(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';)\n endif\n@@ -2557,7 +2585,11 @@ distclean: clean\n \t$(RM) configure\n \t$(RM) po/git.pot\n \n-clean:\n+profile-clean:\n+\t$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n+\t$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))\n+\n+clean: profile-clean\n \t$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \\\n \t\tbuiltin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)\n \t$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X\n@@ -2587,7 +2619,7 @@ ifndef NO_TCLTK\n endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS\n \n-.PHONY: all install clean strip\n+.PHONY: all install profile-clean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\n .PHONY: FORCE cscope\n \n@@ -2697,18 +2729,3 @@ cover_db: coverage-report\n cover_db_html: cover_db\n \tcover -report html -outputdir cover_db_html cover_db\n \n-### profile feedback build\n-#\n-.PHONY: profile-all profile-clean\n-\n-PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1\n-PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1\n-\n-profile-clean:\n-\t$(RM) $(addsuffix *.gcda,$(object_dirs))\n-\t$(RM) $(addsuffix *.gcno,$(object_dirs))\n-\n-profile-all: profile-clean\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" all\n-\t$(MAKE) CFLAGS=\"$(PROFILE_GEN_CFLAGS)\" -j1 test\n-\t$(MAKE) CFLAGS=\"$(PROFILE_USE_CFLAGS)\" all\n-- \n1.7.9.107.g8e04a\n"},{"id":"184194","messageId":"20120208185319.GB9397@thunk.org","threadId":"29526","inReplyTo":"1328508017-7277-1-git-send-email-tytso@mit.edu","subject":"Re: [PATCH] Fix build problems related to profile-directed optimization","fromName":"Ted Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2012-02-08T18:53:19Z","receivedAt":"2012-02-08T18:53:19Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"Junio, any comments on my most recent spin of this patch?  Any changes\nyou'd like to see?\n\nThanks,\n\n\t\t\t\t\t- Ted\n"},{"id":"184216","messageId":"7vty30y7ou.fsf@alter.siamese.dyndns.org","threadId":"29526","inReplyTo":"20120208185319.GB9397@thunk.org","subject":"Re: [PATCH] Fix build problems related to profile-directed optimization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-09T04:03:29Z","receivedAt":"2012-02-09T04:03:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ted Ts'o <tytso@mit.edu> writes:\n\n> Junio, any comments on my most recent spin of this patch?  Any changes\n> you'd like to see?\n\nNothing from me; all looked good.\n\nLet's cook it in 'next' for a few days to give developers a chance to play\nwith it and merge down to 'master'.\n\nThanks.\n"},{"id":"184226","messageId":"4F338242.8080907@viscovery.net","threadId":"29526","inReplyTo":"20120208185319.GB9397@thunk.org","subject":"Re: [PATCH] Fix build problems related to profile-directed optimization","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-02-09T08:22:26Z","receivedAt":"2012-02-09T08:22:26Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 2/8/2012 19:53, schrieb Ted Ts'o:\n> Junio, any comments on my most recent spin of this patch?  Any changes\n> you'd like to see?\n\nI need the following to unbreak my build on Windows.\n\n--- >8 ---\nFrom: Johannes Sixt <j6t@kdbg.org>\nSubject: [PATCH] Makefile: fix syntax for older make\n\nIt is necessary to write the else branch as a nested conditional. Also,\nwrite the conditions with parentheses because we use them throughout the\nMakefile.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n Makefile |    6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex bfc5daa..01a3c77 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1784,16 +1784,18 @@ endif\n # data gathering\n PROFILE_DIR := $(CURDIR)\n \n-ifeq \"$(PROFILE)\" \"GEN\"\n+ifeq (\"$(PROFILE)\",\"GEN\")\n \tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n \tEXTLIBS += -lgcov\n \texport CCACHE_DISABLE=t\n \tV=1\n-else ifneq \"$(PROFILE)\" \"\"\n+else\n+ifneq (\"$(PROFILE)\",\"\")\n \tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n \texport CCACHE_DISABLE=t\n \tV=1\n endif\n+endif\n \n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n-- \n1.7.9.1420.gae2d6\n"},{"id":"184246","messageId":"7vr4y3x3wx.fsf@alter.siamese.dyndns.org","threadId":"29526","inReplyTo":"4F338242.8080907@viscovery.net","subject":"Re: [PATCH] Fix build problems related to profile-directed optimization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-09T18:22:38Z","receivedAt":"2012-02-09T18:22:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Am 2/8/2012 19:53, schrieb Ted Ts'o:\n>> Junio, any comments on my most recent spin of this patch?  Any changes\n>> you'd like to see?\n>\n> I need the following to unbreak my build on Windows.\n\nThanks; will apply.\n\n> --- >8 ---\n> From: Johannes Sixt <j6t@kdbg.org>\n> Subject: [PATCH] Makefile: fix syntax for older make\n>\n> It is necessary to write the else branch as a nested conditional. Also,\n> write the conditions with parentheses because we use them throughout the\n> Makefile.\n>\n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n> ---\n>  Makefile |    6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index bfc5daa..01a3c77 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1784,16 +1784,18 @@ endif\n>  # data gathering\n>  PROFILE_DIR := $(CURDIR)\n>  \n> -ifeq \"$(PROFILE)\" \"GEN\"\n> +ifeq (\"$(PROFILE)\",\"GEN\")\n>  \tCFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1\n>  \tEXTLIBS += -lgcov\n>  \texport CCACHE_DISABLE=t\n>  \tV=1\n> -else ifneq \"$(PROFILE)\" \"\"\n> +else\n> +ifneq (\"$(PROFILE)\",\"\")\n>  \tCFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1\n>  \texport CCACHE_DISABLE=t\n>  \tV=1\n>  endif\n> +endif\n>  \n>  # Shell quote (do not use $(call) to accommodate ancient setups);\n"}]}