tools/build/Build.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
From: David Woodhouse <dwmw@amazon.co.uk>
When a header file is removed, stale .d dependency files still reference
it, causing the build to fail with 'No rule to make target'. This
requires a manual clean of the build directory to recover.
Add -Wp,-MP to the C, C++, and host compiler flags. This causes gcc to
emit a phony target for each dependency, so that removed headers do not
break incremental builds.
Fixes: c819e2cf2eb6 ("tools build: Add new build support")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
tools/build/Build.include | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/build/Build.include b/tools/build/Build.include
index cd0baa7a168d..be0c41a429fc 100644
--- a/tools/build/Build.include
+++ b/tools/build/Build.include
@@ -93,10 +93,10 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
# - per target C flags
# - per object C flags
# - BUILD_STR macro to allow '-D"$(variable)"' constructs
-c_flags_1 = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
+c_flags_1 = -Wp,-MD,$(depfile) -Wp,-MT,$@ -Wp,-MP $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
c_flags = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
-cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
+cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ -Wp,-MP $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
###
# Rust flags to be used on rule definition, includes:
@@ -110,7 +110,7 @@ rust_flags = $(filter-out $(RUST_FLAGS_REMOVE_$(obj)), $(rust_flags_2))
###
## HOSTCC C flags
-host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj))
+host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ -Wp,-MP $(HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj))
# output directory for tests below
TMPOUT = .tmp_$$$$
--
2.50.1
© 2016 - 2026 Red Hat, Inc.