git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] Makefile: use -Wdeclaration-after-statement if supported

From
Adam Spiers <git@adamspiers.org>
Date
Dec 17, 2012, 02:15 UTC
Message-ID
<20121217021501.GA13745@gmail.com>
In-Reply-To
<7vk3shphru.fsf@alter.siamese.dyndns.org>
On Sun, Dec 16, 2012 at 05:52:05PM -0800, Junio C Hamano wrote:
Show 32 quoted lines
> Adam Spiers <git@adamspiers.org> writes:
> 
> > If we adopt this approach,...
> > diff --git a/Makefile b/Makefile
> > index a49d1db..aae70d4 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -331,8 +331,13 @@ endif
> >  # CFLAGS and LDFLAGS are for the users to override from the command line.
> >  
> >  CFLAGS = -g -O2 -Wall
> > +GCC_DECL_AFTER_STATEMENT = \
> > +	$(shell $(CC) --help -v 2>&1 | \
> > +		grep -q -- -Wdeclaration-after-statement && \
> > +	  echo -Wdeclaration-after-statement)
> > +GCC_FLAGS = $(GCC_DECL_AFTER_STATEMENT)
> > +ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) $(GCC_FLAGS)
> >  LDFLAGS =
> > -ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
> >  ALL_LDFLAGS = $(LDFLAGS)
> 
> Please do not do this.
> 
> People cannot disable it from the command line, like:
> 
>     $ make V=1 CFLAGS='-g -O0 -Wall'
> 
> If anything, this should be part of the default CFLAGS.
> 
> More importantly, this will run the $(shell ...) struct once for
> every *.o file we produce, I think, in addition to running it twice
> for the whole build.
[snipped]

OK; I expect these issues with the implementation are all surmountable. I did not necessarily expect this to be the final implementation anyhow, as indicated by my comments below the divider line. However it's not clear to me what you think about the idea in principle, and whether other compiler flags would merit inclusion.

(And also, please don't let this discussion hold up acceptance of the two prior patches in the series. Even though they are independent, they are somewhat logically related so I grouped them into the same series, although I'm not sure if that was the right thing to do.)

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “Help newbie git developers avoid obvious pitfalls”
  1. 0/3 Help newbie git developers avoid obvious pitfallsAdam Spiers, Dec 16, 2012
  2. 1/3 SubmittingPatches: add convention of prefixing commit messagesAdam Spiers, Dec 16, 2012
  3. Junio C HamanoDec 16, 2012
  4. 2/3 Documentation: move support for old compilers to CodingGuidelinesAdam Spiers, Dec 16, 2012
  5. 3/3 Makefile: use -Wdeclaration-after-statement if supportedAdam Spiers, Dec 16, 2012
  6. Junio C HamanoDec 17, 2012
  7. Adam SpiersDec 17, 2012
  8. Junio C HamanoDec 17, 2012
  9. Adam SpiersDec 22, 2012
  10. Junio C HamanoDec 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.