From: Brian Norris <computersforpeace@gmail.com>
To: <linux-mtd@lists.infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>,
Mike Frysinger <vapier@gentoo.org>,
David Woodhouse <David.Woodhouse@intel.com>
Subject: [PATCH mtd-utils] autogenerated dependency files are not being utilized properly
Date: Thu, 27 Aug 2015 15:48:22 -0700 [thread overview]
Message-ID: <1440715702-66843-1-git-send-email-computersforpeace@gmail.com> (raw)
TL;DR
=====
Auto-generated dependency rules are not being written correctly, so
changes to dependent files (e.g., headers) do not actually trigger
rebuilds.
The problem
===========
It appears that when a dependency generation flag is passed directly to
the preprocessor (with '-Wp,...'), it loses information about the output
path. So, it just makes up the output name as $(basename).o, with no
path information. This yields .*.c.dep files that look like this:
flash_lock.o: flash_lock.c /usr/include/stdc-predef.h flash_unlock.c \
(...)
and
nanddump.o: nanddump.c /usr/include/stdc-predef.h /usr/include/ctype.h \
(...)
include/libmtd.h
This is the case for both in-tree *and* out-of-tree builds. Naturally,
this is a problem for out-of-tree builds. But it is also a problem for
in-tree builds, because we use rules like this for builds:
$(BUILDDIR)/%.o: %.c
and make doesn't recognize $(BUILDDIR)/%.o as the same as %.o even when
$(BUILDDIR) == $(PWD).
Example failures
================
## Rebuilding after touching common header doesn't recompile anything
$ make
(...)
$ touch include/libmtd.h
$ make
CHK include/version.h
## Same for out-of-tree builds
$ BUILDDIR=test make
(...)
$ touch include/libmtd.h
$ BUILDDIR=test make
CHK include/version.h
I noticed this when seeing that flash_lock would not get rebuilt when
modifying flash_unlock.c (where 99% of the source code lies):
$ make
(...)
$ touch flash_unlock.c
$ make
CHK include/version.h
CC flash_unlock.o
LD flash_unlock
The fix
=======
Just pass -MD straight to the compiler, and make sure to specify the
output file for the dependency info with -MF.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: David Woodhouse <David.Woodhouse@intel.com>
---
common.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common.mk b/common.mk
index ba87377a00b6..7c09ab0a46d0 100644
--- a/common.mk
+++ b/common.mk
@@ -80,7 +80,7 @@ ifneq ($(BUILDDIR),$(CURDIR))
$(Q)mkdir -p $(dir $@)
endif
$(call BECHO,CC)
- $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(<F).dep
+ $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -MD -MF $(BUILDDIR)/.$(<F).dep
.SUFFIXES:
--
2.5.0.457.gab17608
next reply other threads:[~2015-08-27 22:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 22:48 Brian Norris [this message]
2015-08-27 23:56 ` [PATCH mtd-utils] autogenerated dependency files are not being utilized properly Mike Frysinger
2015-08-28 0:20 ` Brian Norris
2015-08-28 16:04 ` Brian Norris
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=1440715702-66843-1-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=David.Woodhouse@intel.com \
--cc=linux-mtd@lists.infradead.org \
--cc=vapier@gentoo.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.