git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Ramsay Jones <ramsay@ramsayjones.plus.com>,
	Denton Liu <liu.denton@gmail.com>
Subject: Re: [PATCH 0/3] Makefile: make "sparse" and "hdr-check" non-.PHONY
Date: Tue, 21 Sep 2021 22:11:26 -0400	[thread overview]
Message-ID: <YUqQzn5vFDpbF5dM@coredump.intra.peff.net> (raw)
In-Reply-To: <cover-0.3-00000000000-20210921T224944Z-avarab@gmail.com>

On Wed, Sep 22, 2021 at 12:55:12AM +0200, Ævar Arnfjörð Bjarmason wrote:

> Now that my series to only build "TAGS" when we strictly need to has
> landed in 1b8bd2243e7 (Merge branch 'ab/make-tags-cleanup',
> 2021-09-20), let's do the same for the "sparse" and "hdr-check"
> targets.
> 
> For *.c files we'll now generate corresponding empty *.sp and *.hco
> files when "sparse" and "hdr-check" are run, respectively. If either
> of those errored on the *.c file we'd fail to refresh the
> corresponding generated file.

All three seem pretty reasonable to me.

Though could we be confused in the sparse rule by a header file that
changed? The object files depend on the auto-computed dependencies or on
LIB_H, but the sparse rule doesn't. So, with your patch:

  $ echo '/* ok */' >>git-compat-util.h
  $ make sparse
  [lots of output, everything ok]

  $ echo 'not ok' >>git-compat-util.h
  $ make sparse
  [no output; nothing is run]

  $ touch git.c
  $ make sparse
  git.c: note: in included file (through builtin.h):
  git-compat-util.h:1382:1: error: 'not' has implicit type
  git-compat-util.h:1382:5: error: Expected ; at end of declaration
  [...etc...]

I think it's hard to use the computed dependencies here, because they're
written by the compiler with explicit ".o" targets. But we could either:

  1. make them all depend on LIB_H. That's overly broad, but still
     better than the status quo; or

  2. have "foo.sp" depend on "foo.o". That requires you to build things
     before doing sparse checks, but in practice most people would
     presumably _also_ be compiling anyway, I'd think.

I.e., this works for me (the second "make sparse" in my example above
rebuilds and shows the errors):

diff --git a/Makefile b/Makefile
index e44eb4a62a..a97e52eb19 100644
--- a/Makefile
+++ b/Makefile
@@ -2903,7 +2903,7 @@ check-sha1:: t/helper/test-tool$X
 
 SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
 
-$(SP_OBJ): %.sp: %.c GIT-CFLAGS
+$(SP_OBJ): %.sp: %.c %.o GIT-CFLAGS
 	$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
 		-Wsparse-error \
 		$(SPARSE_FLAGS) $(SP_EXTRA_FLAGS) $< && \

-Peff

  parent reply	other threads:[~2021-09-22  2:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 22:55 [PATCH 0/3] Makefile: make "sparse" and "hdr-check" non-.PHONY Ævar Arnfjörð Bjarmason
2021-09-21 22:55 ` [PATCH 1/3] Makefile: make the "sparse" target non-.PHONY Ævar Arnfjörð Bjarmason
2021-09-22  2:24   ` Jeff King
2021-09-21 22:55 ` [PATCH 2/3] Makefile: do one append in %.hcc rule Ævar Arnfjörð Bjarmason
2021-09-21 22:55 ` [PATCH 3/3] Makefile: make the "hdr-check" target non-.PHONY Ævar Arnfjörð Bjarmason
2021-09-22  2:11 ` Jeff King [this message]
2021-09-22 16:58   ` [PATCH 0/3] Makefile: make "sparse" and "hdr-check" non-.PHONY Ramsay Jones
2021-09-22 17:53     ` Jeff King
2021-09-22 19:17       ` Ramsay Jones
2021-09-22 23:28         ` Junio C Hamano
2021-09-23  1:07           ` Ævar Arnfjörð Bjarmason
2021-09-23  1:23             ` Junio C Hamano
2021-09-23  2:17               ` Ævar Arnfjörð Bjarmason
2021-09-22 19:24     ` Junio C Hamano
2021-09-23  0:07 ` [PATCH v2] Makefile: make the "sparse" target non-.PHONY Ævar Arnfjörð Bjarmason
2021-09-23 16:24   ` Jeff King
2021-09-23 17:06     ` Ævar Arnfjörð Bjarmason
2021-09-23 17:17       ` Jeff King
2021-09-23 17:39     ` Junio C Hamano
2021-09-23 23:28       ` Ramsay Jones
2021-09-24  1:16         ` Ævar Arnfjörð Bjarmason
2021-09-24 16:38           ` Ramsay Jones
2021-09-24  1:30       ` Ævar Arnfjörð Bjarmason
2021-09-24 19:37         ` Junio C Hamano
2021-09-28  1:15   ` [PATCH v3] Makefile: add a non-.PHONY "sparse-incr" target Ævar Arnfjörð Bjarmason
2021-09-28  1:43     ` [PATCH v4] " Ævar Arnfjörð Bjarmason
2021-09-28 17:44       ` Junio C Hamano
2021-09-28 19:45         ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YUqQzn5vFDpbF5dM@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    --cc=ramsay@ramsayjones.plus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).