From ca4bec7b0eab93cc3a0ccd5437e96f650c0274d5 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Wed, 5 Feb 2020 17:20:53 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2039988 Reviewed-by: Paul Fagerburg Reviewed-by: Daisuke Nojiri (cherry picked from commit f42be6e2a1eefaee06ed7593373fbe6dedb3dd6c) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2044511 Reviewed-by: Andrey Pronin --- Makefile.rules | 19 ++++++++++--------- test/tpm_test/Makefile | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index 89bd0e6285..cdbdb14b33 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -81,16 +81,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) @@ -114,7 +115,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 $^ @@ -563,21 +564,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 806dc02d42..8eefed5a3e 100644 --- a/test/tpm_test/Makefile +++ b/test/tpm_test/Makefile @@ -58,7 +58,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 $@)") -- cgit v1.2.1