{"thread":{"id":"27025","subject":"[PATCH 7/9] sparse: Fix errors due to missing target-specific variables","startedAt":"2011-04-07T18:48:14Z","lastAt":"2011-04-11T18:04:31Z","messageCount":3,"participants":["Ramsay Jones","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"165374","messageId":"4D9E06EE.9090803@ramsay1.demon.co.uk","threadId":"27025","inReplyTo":null,"subject":"[PATCH 7/9] sparse: Fix errors due to missing target-specific variables","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2011-04-07T18:48:14Z","receivedAt":"2011-04-07T18:48:14Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIn particular, sparse issues the following errors:\n\n    attr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES'\n    config.c:821:43: error: undefined identifier 'ETC_GITCONFIG'\n    exec_cmd.c:14:37: error: undefined identifier 'PREFIX'\n    exec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH'\n    builtin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH'\n    builtin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH'\n    builtin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH'\n    git.c:96:42: error: undefined identifier 'GIT_HTML_PATH'\n    git.c:241:35: error: invalid initializer\n    http.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT'\n\nwhich is caused by not passing the target-specific additions to\nthe EXTRA_CPPFLAGS variable to cgcc.\n\nIn order to fix the problem, we define a new sparse target which\ndepends on an a set of non-existent \"sparse object\" files (*.sp)\nwhich correspond to the set of C source files. In addition to the\nnew target, we also provide a new pattern rule for \"creating\" the\nsparse object files from the source files by running cgcc.  This\nallows us to add '*.sp' to the rules setting the target-specific\nEXTRA_CPPFLAGS variable, which is then included in the new pattern\nrule to run cgcc.\n\nAlso, we change the 'check' target to re-direct the user to the\nnew sparse target.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nAlso, note the use of $(C_OBJ) rather than $(GIT_OBJS) when setting\nthe $(SP_OBJ) sparse objects; this leads to some additional C source\nfiles being run through sparse. (Namely the files in the xdiff and\nvcs-svn directories)\n\n Makefile |   40 +++++++++++++++++++++++++---------------\n 1 files changed, 25 insertions(+), 15 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 2a100b7..4b03b8a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1581,6 +1581,7 @@ ifndef V\n \tQUIET_LNCP     = @echo '   ' LN/CP $@;\n \tQUIET_XGETTEXT = @echo '   ' XGETTEXT $@;\n \tQUIET_GCOV     = @echo '   ' GCOV $@;\n+\tQUIET_SP       = @echo '   ' SP $<;\n \tQUIET_SUBDIR0  = +@subdir=\n \tQUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \\\n \t\t\t $(MAKE) $(PRINT_DIR) -C $$subdir\n@@ -1676,7 +1677,7 @@ strip: $(PROGRAMS) git$X\n \t$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X\n \n git.o: common-cmds.h\n-git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n+git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n \t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"'\n \n git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n@@ -1686,7 +1687,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n help.o: common-cmds.h\n \n builtin/help.o: common-cmds.h\n-builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \\\n+builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n \t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n \t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"'\n@@ -1972,30 +1973,34 @@ $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \\\n test-svn-fe.o: vcs-svn/svndump.h\n endif\n \n-exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n+exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n \t'-DPREFIX=\"$(prefix_SQ)\"'\n \n-builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n+builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \t-DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"'\n \n-config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n+config.sp config.s config.o: EXTRA_CPPFLAGS = \\\n+\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n \n-attr.s attr.o: EXTRA_CPPFLAGS = -DETC_GITATTRIBUTES='\"$(ETC_GITATTRIBUTES_SQ)\"'\n+attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \\\n+\t-DETC_GITATTRIBUTES='\"$(ETC_GITATTRIBUTES_SQ)\"'\n \n-http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n+http.sp http.s http.o: EXTRA_CPPFLAGS = \\\n+\t-DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n \n ifdef NO_EXPAT\n-http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\n+http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\n endif\n \n ifdef NO_REGEX\n-compat/regex/regex.o: EXTRA_CPPFLAGS = -DGAWK -DNO_MBSUPPORT\n+compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \\\n+\t-DGAWK -DNO_MBSUPPORT\n endif\n \n ifdef USE_NED_ALLOCATOR\n-compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \\\n+compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \\\n \t-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR\n endif\n \n@@ -2160,14 +2165,19 @@ test-%$X: test-%.o $(GITLIBS)\n check-sha1:: test-sha1$X\n \t./test-sha1.sh\n \n+SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))\n+\n+%.sp: %.c GIT-CFLAGS FORCE\n+\t$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \\\n+\t\t$(SPARSE_FLAGS) $<\n+\n+sparse: $(SP_OBJ)\n+\n check: common-cmds.h\n \t@if sparse; \\\n \tthen \\\n-\t\tfor i in $(patsubst %.o, %.c, $(GIT_OBJS)); \\\n-\t\tdo \\\n-\t\t\techo '   ' SP $$i; \\\n-\t\t\tcgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \\\n-\t\tdone; \\\n+\t\techo 2>&1 \"Use 'make sparse' instead\"; \\\n+\t\t$(MAKE) --no-print-directory sparse; \\\n \telse \\\n \t\techo 2>&1 \"Did you mean 'make test'?\"; \\\n \t\texit 1; \\\n-- \n1.7.4\n"},{"id":"165388","messageId":"7vfwpt6474.fsf@alter.siamese.dyndns.org","threadId":"27025","inReplyTo":"4D9E06EE.9090803@ramsay1.demon.co.uk","subject":"Re: [PATCH 7/9] sparse: Fix errors due to missing target-specific variables","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-07T23:18:23Z","receivedAt":"2011-04-07T23:18:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> In particular, sparse issues the following errors:\n>\n>     attr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES'\n>     config.c:821:43: error: undefined identifier 'ETC_GITCONFIG'\n>     exec_cmd.c:14:37: error: undefined identifier 'PREFIX'\n>     exec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH'\n>     builtin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH'\n>     builtin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH'\n>     builtin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH'\n>     git.c:96:42: error: undefined identifier 'GIT_HTML_PATH'\n>     git.c:241:35: error: invalid initializer\n>     http.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT'\n>\n> which is caused by not passing the target-specific additions to\n> the EXTRA_CPPFLAGS variable to cgcc.\n>\n> In order to fix the problem, we define a new sparse target which\n> depends on an a set of non-existent \"sparse object\" files (*.sp)\n> which correspond to the set of C source files. In addition to the\n> new target, we also provide a new pattern rule for \"creating\" the\n> sparse object files from the source files by running cgcc.  This\n> allows us to add '*.sp' to the rules setting the target-specific\n> EXTRA_CPPFLAGS variable, which is then included in the new pattern\n> rule to run cgcc.\n\nHmm, shouldn't this be part of [1/9]?  I don't think I saw these with\n\"make check\" before applying that patch.\n\nAlso shouldn't you be marking .sp suffix as .PHONY?\n"},{"id":"165639","messageId":"4DA342AF.7080109@ramsay1.demon.co.uk","threadId":"27025","inReplyTo":"7vfwpt6474.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 7/9] sparse: Fix errors due to missing target-specific variables","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2011-04-11T18:04:31Z","receivedAt":"2011-04-11T18:04:31Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"[Sorry for the late reply, I'm having ISP problems and real-life is\ninsanely busy right now...]\n\nJunio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n> \n>> In particular, sparse issues the following errors:\n>>\n>>     attr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES'\n>>     config.c:821:43: error: undefined identifier 'ETC_GITCONFIG'\n>>     exec_cmd.c:14:37: error: undefined identifier 'PREFIX'\n>>     exec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH'\n>>     builtin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH'\n>>     builtin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH'\n>>     builtin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH'\n>>     git.c:96:42: error: undefined identifier 'GIT_HTML_PATH'\n>>     git.c:241:35: error: invalid initializer\n>>     http.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT'\n>>\n>> which is caused by not passing the target-specific additions to\n>> the EXTRA_CPPFLAGS variable to cgcc.\n>>\n[...]\n> \n> Hmm, shouldn't this be part of [1/9]?  I don't think I saw these with\n> \"make check\" before applying that patch.\n\nNo, these errors were not introduced by patch #1; below I have added a\ntranscript of a session on Linux which shows that these errors were\npresent prior to patch #1. I can't say I'm surprised that you didn't\nnotice these errors; as you can see below, they are swamped by the\n(for me) 4223 warnings and 161 errors.\n\nPatch #1 is really about using \"cgcc -no-compile\", rather than sparse,\nin order to fix the vast majority of warnings and errors; 4209 fewer\nwarnings and 148 fewer errors is not a bad return!\n\nPatch #2 is about fixing up the target-specific additions in the\nMakefile (ie, it's not a general sparse usage issue, but specific to\nthe git Makefile).\n\nHaving said that, I certainly don't mind squashing this in with patch #1\nif that's what you would prefer. I have to make some additions to this\npatch anyway; I forgot some \"common-cmds.h\" dependencies, thus:\n\n--- >8 ---\ndiff --git a/Makefile b/Makefile\nindex 4b03b8a..4dee43f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1684,9 +1684,9 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \\\n \t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n-help.o: common-cmds.h\n+help.sp help.o: common-cmds.h\n \n-builtin/help.o: common-cmds.h\n+builtin/help.sp builtin/help.o: common-cmds.h\n builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n \t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n@@ -2171,7 +2171,7 @@ SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))\n \t$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \\\n \t\t$(SPARSE_FLAGS) $<\n \n-sparse: $(SP_OBJ)\n+sparse: common-cmds.h $(SP_OBJ)\n \n check: common-cmds.h\n \t@if sparse; \\\n--- >8 ---\n\nNOTE: The Makefile has \"git.o: common-cmds.h\" (line 1679), but I don't\nthink git.c has depended on that header since commit 70827b15 (21-Apr-2006).\n\n> Also shouldn't you be marking .sp suffix as .PHONY?\n\nHmmm, I didn't think so ... but I could easily be wrong!\nGiven that the .sp files never actually exist, and that the pattern rule\nhas a .PHONY dependency (FORCE), I didn't think marking $(SP_OBJ) as\nphony would add anything.\nAh, well I suppose it would help if somebody did (say) \"make git.sp 2>git.sp\".\nOK, I'll add that in the re-roll.\n\nLet me know if you want me to squash this in with patch #1; I'll wait a while\nbefore I re-roll.\n\nThanks!\n\nATB,\nRamsay Jones\n\n$ git checkout 52d269da  # Stephen's \"Makefile: cover more files\" patch.\n$ make check >/dev/null 2>sp-out\n$ grep warning sp-out | wc -l\n4223\n$ grep error sp-out | wc -l\n161\n$ grep error sp-out | grep ETC_\nattr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES'\nconfig.c:813:43: error: undefined identifier 'ETC_GITCONFIG'\n$ grep error sp-out | grep PREFIX\nexec_cmd.c:14:37: error: undefined identifier 'PREFIX'\n$ grep error sp-out | grep GIT_\nexec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH'\nbuiltin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH'\nbuiltin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH'\nbuiltin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH'\ngit.c:96:42: error: undefined identifier 'GIT_HTML_PATH'\nhttp.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT'\n\n$ git checkout 0343332f  # patch #1\n$ make check >/dev/null 2>sp-out\n$ grep warning sp-out | wc -l\n14\n$ grep error sp-out | wc -l\n13\n$ grep error sp-out | grep ETC_\nattr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES'\nconfig.c:821:43: error: undefined identifier 'ETC_GITCONFIG'\n$ grep error sp-out | grep PREFIX\nexec_cmd.c:14:37: error: undefined identifier 'PREFIX'\n$ grep error sp-out | grep GIT_\nexec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH'\nbuiltin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH'\nbuiltin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH'\nbuiltin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH'\ngit.c:96:42: error: undefined identifier 'GIT_HTML_PATH'\nhttp.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT'\n\n$ git checkout 6f8a9fe3  # Patch #7\n$ make check >/dev/null 2>sp-out\n$ grep warning sp-out | wc -l\n10\n$ grep error sp-out | wc -l\n3\n$ grep error sp-out | grep ETC_\n$ grep error sp-out | grep PREFIX\n$ grep error sp-out | grep GIT_\n"}]}