Skip to contentSkip to conversation

Pass -DDEFAULT_GIT_TEMPLATE_DIR only where actually used.

PATCH In review Yakov Lerner 4 participants 8 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Pass -DDEFAULT_GIT_TEMPLATE_DIR only where actually used.

Before this patch, -DDEFAULT_GIT_TEMPLATE_DIR was passed on compilation command line to all and every %c compiled. In fact the macro is used by only one .c file, and unused by all other .c files. Remove -DDEFAULT_GIT_TEMPLATE_DIR where unused. Follow the examlpe of exec_cmd.o. Pass -DDEFAULT_GIT_TEMPLATE_DIR only where actually used.

---
 Makefile |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Makefile +2 -1
index c602099..7af0937 100644
@@ -472,7 +472,6 @@ PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON
 GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
 
 ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
-ALL_CFLAGS += -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
 LIB_OBJS += $(COMPAT_OBJS)
 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 ### Build rules
@@ -548,6 +547,8 @@ git$X git.spec \
 
 exec_cmd.o: exec_cmd.c GIT-CFLAGS
 	$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
+builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
+	$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
 
 http.o: http.c GIT-CFLAGS
 	$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
Signature · 1 line
1.4.0.ga40a
#1 lore raw
Quoted 5 lines · Yakov Lerner

Before this patch, -DDEFAULT_GIT_TEMPLATE_DIR was passed on compilation command line to all and every %c compiled. In fact the macro is used by only one .c file, and unused by all other .c files. Remove -DDEFAULT_GIT_TEMPLATE_DIR where unused. Follow the examlpe of exec_cmd.o. Pass -DDEFAULT_GIT_TEMPLATE_DIR only where actually used.

Thanks.

By the way, I really started hating that we have $(GIT_VERSION) in $(TRACK_CFLAGS). Since the version string is tied to the HEAD commit object name, having it in $(TRACK_CFLAGS) means that every time I switch branches, make a new commit on top of the current branch, or checkout-compile-and-then-make-local-change sequence would force pretty much everything to be rebuilt.

Do you think of any downside if I remove it from the list of symbols in TRACK_CFLAGS?

For that matter, I do not think tracking prefix_SQ makes much sense since what matters are bindir, gitexecdir and template_dir which are already covered, and prefix is merely a convenience to set these three (four, counting GIT_PYTHON_DIR; we probably should add it to TRACK_CFLAGS).

Thoughts?

#2 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Yakov Lerner

Before this patch, -DDEFAULT_GIT_TEMPLATE_DIR was passed on compilation command line to all and every %c compiled. In fact the macro is used by only one .c file, and unused by all other .c files. Remove -DDEFAULT_GIT_TEMPLATE_DIR where unused. Follow the examlpe of exec_cmd.o. Pass -DDEFAULT_GIT_TEMPLATE_DIR only where actually used.

Quoted 8 lines

Thanks.

By the way, I really started hating that we have $(GIT_VERSION) in $(TRACK_CFLAGS). Since the version string is tied to the HEAD commit object name, having it in $(TRACK_CFLAGS) means that every time I switch branches, make a new commit on top of the current branch, or checkout-compile-and-then-make-local-change sequence would force pretty much everything to be rebuilt.

I think this already makes sure git is compiled if version changes:

# These can record GIT_VERSION

git$X git.spec \
        $(patsubst %.sh,%,$(SCRIPT_SH)) \
        $(patsubst %.perl,%,$(SCRIPT_PERL)) \
        $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
        : GIT-VERSION-FILE
$ git grep GIT_VERSION *.sh *.perl
git-send-email.perl:	my $gitversion = '@@GIT_VERSION@@';
git-send-email.perl:	if ($gitversion =~ m/..GIT_VERSION../) {

Only git-send-email and git needs to depend on GIT_VERSION.

Quoted 5 lines

For that matter, I do not think tracking prefix_SQ makes much sense since what matters are bindir, gitexecdir and template_dir which are already covered, and prefix is merely a convenience to set these three (four, counting GIT_PYTHON_DIR; we probably should add it to TRACK_CFLAGS).

Yes, only ALL_CFLAGS, bindir, gitexecdir, template_dir and GIT_PYTHON_DIR should be in TRACK_CFLAGS.

Signature · 1 line
http://onion.dynserv.net/~timo/
#3 lore raw
Quoted 9 lines · Timo Hirvonen
Quoted 6 lines · Junio C Hamano

By the way, I really started hating that we have $(GIT_VERSION) in $(TRACK_CFLAGS). Since the version string is tied to the HEAD commit object name, having it in $(TRACK_CFLAGS) means that every time I switch branches, make a new commit on top of the current branch, or checkout-compile-and-then-make-local-change sequence would force pretty much everything to be rebuilt.

...

Quoted 8 lines
Quoted 5 lines

For that matter, I do not think tracking prefix_SQ makes much sense since what matters are bindir, gitexecdir and template_dir which are already covered, and prefix is merely a convenience to set these three (four, counting GIT_PYTHON_DIR; we probably should add it to TRACK_CFLAGS).

Yes, only ALL_CFLAGS, bindir, gitexecdir, template_dir and GIT_PYTHON_DIR should be in TRACK_CFLAGS.

Exactly my thinking. Let's do it like this, then.

-- >8 --
Makefile: do not force unneeded recompilation upon GIT_VERSION changes

---

Makefile +1 -1
index 55a84d4..d45f3dc 100644
@@ -612,7 +612,7 @@ tags:
 	find . -name '*.[hcS]' -print | xargs ctags -a
 
 ### Detect prefix changes
-TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_VERSION):\
+TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_PYTHON_DIR_SQ):\
              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
 
 GIT-CFLAGS: .FORCE-GIT-CFLAGS
#4 lore raw
In reply to Junio C Hamano

Dear diary, on Thu, Jun 22, 2006 at 09:19:52AM CEST, I got a letter where Junio C Hamano <[email protected]> said that...

Quoted 5 lines

For that matter, I do not think tracking prefix_SQ makes much sense since what matters are bindir, gitexecdir and template_dir which are already covered, and prefix is merely a convenience to set these three (four, counting GIT_PYTHON_DIR; we probably should add it to TRACK_CFLAGS).

$(prefix) will be passed to perl/Makefile.PL.

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
#5 lore raw
Quoted 9 lines · Petr Baudis

Dear diary, on Thu, Jun 22, 2006 at 09:19:52AM CEST, I got a letter where Junio C Hamano <[email protected]> said that...

Quoted 5 lines

For that matter, I do not think tracking prefix_SQ makes much sense since what matters are bindir, gitexecdir and template_dir which are already covered, and prefix is merely a convenience to set these three (four, counting GIT_PYTHON_DIR; we probably should add it to TRACK_CFLAGS).

$(prefix) will be passed to perl/Makefile.PL.

Then probably it shouldn't; instead we woulld probably want to pass the moral equivalent of GIT_PYTHON_DIR.

#6 lore raw

Dear diary, on Thu, Jun 22, 2006 at 07:11:49PM CEST, I got a letter where Junio C Hamano <[email protected]> said that...

Quoted 10 lines
Quoted 8 lines · Petr Baudis

Dear diary, on Thu, Jun 22, 2006 at 09:19:52AM CEST, I got a letter where Junio C Hamano <[email protected]> said that...

Quoted 5 lines

For that matter, I do not think tracking prefix_SQ makes much sense since what matters are bindir, gitexecdir and template_dir which are already covered, and prefix is merely a convenience to set these three (four, counting GIT_PYTHON_DIR; we probably should add it to TRACK_CFLAGS).

Quoted 4 lines
Quoted 1 line

$(prefix) will be passed to perl/Makefile.PL.

Then probably it shouldn't; instead we woulld probably want to pass the moral equivalent of GIT_PYTHON_DIR.

I'm not sure about what the rationale behind GIT_PYTHON_DIR was, but it seems to be used only by a library supposedly internal to some Git commands, while the Git.pm module should be available systemwide even for non-Git applications, so it's really best to leave it to Perl where to put it.

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
#7 lore raw
Quoted 3 lines · Petr Baudis

... while the Git.pm module should be available systemwide even for non-Git applications, so it's really best to leave it to Perl where to put it.

OK, if that is the intention passing prefix might be sensible.