Skip to content

Commit f8bb7b3

Browse files
committed
8231467: Missing make prerequisite declaration corrupts make dependency files on Windows
Reviewed-by: ihse, tbell
1 parent 6e1aa90 commit f8bb7b3

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

make/common/NativeCompilation.gmk

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -760,34 +760,6 @@ define SetupNativeCompilationBody
760760
endif
761761
endif
762762

763-
# Create a rule to collect all the individual make dependency files into a
764-
# single makefile.
765-
$1_DEPS_FILE := $$($1_OBJECT_DIR)/$1.d
766-
767-
$$($1_DEPS_FILE): $$($1_ALL_OBJS)
768-
$(RM) $$@
769-
# CD into dir to reduce risk of hitting command length limits, which
770-
# could otherwise happen if TOPDIR is a very long path.
771-
$(CD) $$($1_OBJECT_DIR) && $(CAT) *.d > $$@.tmp
772-
$(CD) $$($1_OBJECT_DIR) && $(CAT) *.d.targets | $(SORT) -u >> $$@.tmp
773-
# After generating the file, which happens after all objects have been
774-
# compiled, copy it to .old extension. On the next make invocation, this
775-
# .old file will be included by make.
776-
$(CP) $$@.tmp $$@.old
777-
$(MV) $$@.tmp $$@
778-
779-
$1 += $$($1_DEPS_FILE)
780-
781-
# The include must be on the .old file, which represents the state from the
782-
# previous invocation of make. The file being included must not have a rule
783-
# defined for it as otherwise make will think it has to run the rule before
784-
# being able to include the file, which would be wrong since we specifically
785-
# need the file as it was generated by a previous make invocation.
786-
ifneq ($$(wildcard $$($1_DEPS_FILE).old), )
787-
$1_DEPS_FILE_LOADED := true
788-
-include $$($1_DEPS_FILE).old
789-
endif
790-
791763
# Now call SetupCompileNativeFile for each source file we are going to compile.
792764
$$(foreach file, $$($1_SRCS), \
793765
$$(eval $$(call SetupCompileNativeFile, $1_$$(notdir $$(file)),\
@@ -850,6 +822,34 @@ define SetupNativeCompilationBody
850822
endif
851823
endif
852824

825+
# Create a rule to collect all the individual make dependency files into a
826+
# single makefile.
827+
$1_DEPS_FILE := $$($1_OBJECT_DIR)/$1.d
828+
829+
$$($1_DEPS_FILE): $$($1_ALL_OBJS) $$($1_RES)
830+
$(RM) $$@
831+
# CD into dir to reduce risk of hitting command length limits, which
832+
# could otherwise happen if TOPDIR is a very long path.
833+
$(CD) $$($1_OBJECT_DIR) && $(CAT) *.d > $$@.tmp
834+
$(CD) $$($1_OBJECT_DIR) && $(CAT) *.d.targets | $(SORT) -u >> $$@.tmp
835+
# After generating the file, which happens after all objects have been
836+
# compiled, copy it to .old extension. On the next make invocation, this
837+
# .old file will be included by make.
838+
$(CP) $$@.tmp $$@.old
839+
$(MV) $$@.tmp $$@
840+
841+
$1 += $$($1_DEPS_FILE)
842+
843+
# The include must be on the .old file, which represents the state from the
844+
# previous invocation of make. The file being included must not have a rule
845+
# defined for it as otherwise make will think it has to run the rule before
846+
# being able to include the file, which would be wrong since we specifically
847+
# need the file as it was generated by a previous make invocation.
848+
ifneq ($$(wildcard $$($1_DEPS_FILE).old), )
849+
$1_DEPS_FILE_LOADED := true
850+
-include $$($1_DEPS_FILE).old
851+
endif
852+
853853
ifneq ($(DISABLE_MAPFILES), true)
854854
$1_REAL_MAPFILE := $$($1_MAPFILE)
855855
ifeq ($(call isTargetOs, windows), false)

0 commit comments

Comments
 (0)