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

Re: Segmentation fault with latest git (070c57df)

From
Jeff King <peff@peff.net>
Date
Feb 4, 2013, 09:45 UTC
Message-ID
<20130204094526.GB32095@sigill.intra.peff.net>
In-Reply-To
<7vobg04ebe.fsf@alter.siamese.dyndns.org>
On Mon, Feb 04, 2013 at 01:29:41AM -0800, Junio C Hamano wrote:
Show 28 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > As I understand how the current set-up works:
> >
> >  * Initially, we do not have foo.o but foo.c.  We automatically
> >    build foo.o because it depends on foo.c via the "%.o : %.c" rule,
> >    and as a side effect, we also build .depend/foo.o.d file;
> >
> >  * Then, if any real dependency used to build the existing foo.o
> >    that is recorded in .depend/foo.o.d file changes, foo.o gets
> >    rebuilt, which would update .depend/foo.o.d again for the next
> >    invocation.
> 
> This is unrelated to the case you mentioned, but I wonder what
> happens if you did this:
> 
>  * You are on branch 'next', where foo.c includes (perhaps
>    indirectly) frotz.h.  Compile and you get foo.o and also the
>    dependency recorded for it, "foo.o: foo.c frotz.h", in the
>    .depend/foo.o.d file.
> 
>  * You check out branch 'master', where foo.c does not include
>    frotz.h.  Indeed, the include file does not even exist on the
>    branch.
> 
> Do we get confused, because Makefile includes the depend file from
> the previous build, finds that you need foo.c and frotz.h up to date
> in order to get foo.o, but there is no rule to generate frotz.h?
No, because the .d files look like this:
  foo.o: frotz.h
  frotz.h:

So make sees that it can build frotz.h, which of course does nothing. But that's OK, because foo.c doesn't actually include it anymore, and when we recompile it (as we must, since it is different between the two branches), we will rewrite the .d file without frotz.h.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 6 of 13 in “Re: Re: Segmentation fault with latest git (070c57df)”
  1. Jongman HeoFeb 4, 2013
  2. Junio C HamanoFeb 4, 2013
  3. Jeff KingFeb 4, 2013
  4. Junio C HamanoFeb 4, 2013
  5. Junio C HamanoFeb 4, 2013
  6. Jeff KingFeb 4, 2013
  7. Jeff KingFeb 4, 2013
  8. Junio C HamanoFeb 4, 2013
  9. Jonathan NiederFeb 4, 2013
  10. samMay 15, 2013
  11. samMay 15, 2013
  12. Ramkumar RamachandraMay 16, 2013
  13. Ramkumar RamachandraMay 16, 2013

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.