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

Re: [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies

From
Jeff King <peff@peff.net>
Date
Feb 2, 2013, 00:03 UTC
Message-ID
<20130202000313.GA30191@sigill.intra.peff.net>
In-Reply-To
<20130201224519.GI12368@google.com>
On Fri, Feb 01, 2013 at 02:45:19PM -0800, Jonathan Nieder wrote:
Show 9 quoted lines
> After a change in a header file, object files in a subdirectory are
> not automatically rebuilt by "make":
> 
> 	$ touch cache.h
> 	$ make builtin/add.o
> 	$
> 
> Luckily we can prevent trouble by explicitly supplying the name of the
> target to ccache and gcc, using the -MQ option.  Do so.

Thanks, I missed the original thread last year, but this does look like the same problem. The fixed version of ccache is a few years old, but the OP did mention RHEL5, so that makes sense.

>  missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
>  dep_file = $(dir $@).depend/$(notdir $@).d
> -dep_args = -MF $(dep_file) -MMD -MP
> +dep_args = -MF $(dep_file) -MQ $@ -MMD -MP

This looks like a nice simple solution. The only downside would be if -MQ is not supported by some gcc versions (in which case we would do better to improve the "can we use computed dependencies" check, and punish people on old ccache, not people on old gcc who otherwise could work without -MQ).

As far as I can tell, though, -MQ came along with the other dependency generation options in 2001:

  http://gcc.gnu.org/news/dependencies.html

which means it's not a problem to rely on. So the patch looks good to me.

-Peff
Previous: Jonathan Nieder
Message 4 of 4 in “Re: Re: Re: Re: Segmentation fault with latest git (070c57df)”
  1. Jongman HeoFeb 1, 2013
  2. Jonathan NiederFeb 1, 2013
  3. Makefile: explicitly set target name for autogenerated dependenciesJonathan Nieder, Feb 1, 2013
  4. Jeff KingFeb 2, 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.