summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2020-02-05 17:20:53 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-07 10:12:18 +0000
commitf42be6e2a1eefaee06ed7593373fbe6dedb3dd6c (patch)
tree1d9f8e0ae0749da30a5b948c7d92b0a698f3e996
parent596466a21da2995b9294fc354895c9a8b5b7849e (diff)
downloadchrome-ec-f42be6e2a1eefaee06ed7593373fbe6dedb3dd6c.tar.gz
Makefile: enforce target name in generated dependencies
There seems to be some odd interaction between ccache version 3.7.6 and the set of command line options passed to gcc by the EC makefile, as a result the generated dependency files are wrong, the target file name is missing the path. The -MT command line option makes sure that the correct target file name is generated. Had to make similar changes in ../../third_party/{cryptoc,tpm2} Makefiles. No need to change extra/usb_updater/Makefile as it puts .o files in the same directory where .c files are. BRANCH=all BUG=b:148943341 TEST=verified that relevant object files are rebuilt when an .h file is touched. Also, with companion changes in cryptoc and tpm2 trees verified that all generated my 'make buildall' .d files have proper target values (including path), apart froom files in extra/usb_udater, which place .o files in the same directory with .c files. Change-Id: I22dfad94c112582230a2b6b60289e029a382d822 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2039988 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--Makefile.rules19
-rw-r--r--test/tpm_test/Makefile2
2 files changed, 11 insertions, 10 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 7106091fe5..915766051a 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -86,16 +86,17 @@ cmd_fuzz_exe = $(CXX) $^ $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -o $@
cmd_run_fuzz = build/host/$*/$*.exe -seed=1 -runs=1 $(silent) \
$(silent_err) || (echo "Test $* failed!" && false)
cmd_exe = $(CC) $(ro-objs) $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -o $@
-cmd_c_to_o = $(CC) $(C_WARN) $(CFLAGS) -MMD -MP -MF $@.d -c $< -o $(@D)/$(@F)
+cmd_c_to_o = $(CC) $(C_WARN) $(CFLAGS) -MMD -MP -MF $@.d -c $< \
+ -MT $(@D)/$(@F) -o $(@D)/$(@F)
cmd_cxx_to_o = $(CXX) -std=c++11 $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $@.d -c $< \
- -o $(@D)/$(@F)
+ -MT $(@D)/$(@F) -o $(@D)/$(@F)
cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) \
$(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $(wildcard $*.c)) \
$(BUILD_LDFLAGS) \
- -MMD -MF $@.d -o $@
+ -MMD -MF $@.d -MT $@ -o $@
cmd_c_to_vif = $(BUILDCC) $(BUILD_CFLAGS) $(STANDALONE_FLAGS) \
- -MMD -MF $@.d -c $< -flto -o $@
-cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d -o $@ \
+ -MMD -MF $@.d -c $< -flto -MT $@ -o $@
+cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d -MT $@ -o $@ \
$(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $(wildcard $*.c)) $(HOST_LDFLAGS)
cmd_cxx_to_host = $(HOSTCXX) -std=c++0x $(COMMON_WARN) $(HOST_CXXFLAGS)\
-I ./$($(notdir $@)_ROOT) -o $@ $(filter %.cc,$^) $($(notdir $@)_LIBS)
@@ -119,7 +120,7 @@ cmd_sharedlib_elf = $(CC) $(libsharedobjs_deps) \
-Wl,-Map,$(out)/$(SHOBJLIB)/$(SHOBJLIB).map
cmd_c_to_taskinfo = $(BUILDCC) \
$(filter-out -DSECTION_IS_$(BLD)=$(EMPTY),$(BUILD_CFLAGS)) \
- -DSECTION_IS_$(3)=$(EMPTY) -MMD -MF $@.d -c $< -flto -o $@
+ -DSECTION_IS_$(3)=$(EMPTY) -MMD -MF $@.d -c $< -flto -MT $@ -o $@
cmd_link_taskinfo = $(BUILDCC) $(BUILD_CFLAGS) --shared -fPIC $^ \
$(BUILD_LDFLAGS) -flto -o $@
cmd_proto_to_cxx = $(PROTOC) -I. --cpp_out=$(out)/gen $^
@@ -602,21 +603,21 @@ npx-monitor-dir:
$(npcx-monitor-fw-bin):$(npcx-monitor-fw).c npx-monitor-dir
$(if $(V),,@echo ' EXTBIN ' $(subst $(out)/,,$@) ; )
$(Q)$(CC) $(CFLAGS) -MMD -MF $(out)/$(npcx-lfw).d -c $< \
- -o $(out)/$(npcx-monitor-fw).o
+ -MT $(out)/$(npcx-monitor-fw).o -o $(out)/$(npcx-monitor-fw).o
$(Q)$(CC) $(out)/$(npcx-monitor-fw).o $(LDFLAGS) \
-o $(out)/$(npcx-monitor-fw).elf -Wl,-T,$(npcx-monitor-fw).ld \
-Wl,-Map,$(out)/$(npcx-monitor-fw).map
$(Q)$(OBJCOPY) -O binary $(out)/$(npcx-monitor-fw).elf $@
$(out)/$(npcx-monitor-hdr)_ro.o:$(npcx-monitor-hdr).c npx-monitor-dir
- $(Q)$(CC) $(CFLAGS) -DSECTION_IS_RO=$(EMPTY) -MMD -c $< -o $@
+ $(Q)$(CC) $(CFLAGS) -DSECTION_IS_RO=$(EMPTY) -MMD -c $< -MT $@ -o $@
$(npcx-monitor-hdr-ro-bin):$(out)/$(npcx-monitor-hdr)_ro.o
$(if $(V),,@echo ' EXTBIN ' $(subst $(out)/,,$@) ; )
$(Q)$(OBJCOPY) -O binary $< $@
$(out)/$(npcx-monitor-hdr)_rw.o:$(npcx-monitor-hdr).c npx-monitor-dir
- $(Q)$(CC) $(CFLAGS) -MMD -c $< -o $@
+ $(Q)$(CC) $(CFLAGS) -MMD -c $< -MT $@ -o $@
$(npcx-monitor-hdr-rw-bin):$(out)/$(npcx-monitor-hdr)_rw.o
$(if $(V),,@echo ' EXTBIN ' $(subst $(out)/,,$@) ; )
diff --git a/test/tpm_test/Makefile b/test/tpm_test/Makefile
index 8b4e4c55e2..e45f32ce0b 100644
--- a/test/tpm_test/Makefile
+++ b/test/tpm_test/Makefile
@@ -59,7 +59,7 @@ $(obj)/%.o: $(obj)/%.c
$(obj)/%.o: %.c
$(call echo," CC $(notdir $@)")
- $(Q)gcc $(CFLAGS) -Wall -Werror -MMD -MF $@.d -o $@ $<
+ $(Q)gcc $(CFLAGS) -Wall -Werror -MMD -MF $@.d -MT $@ -o $@ $<
$(obj)/_$(TARGET).so: $(OBJS) $(obj)/$(TARGET).py
$(call echo," LD $(notdir $@)")