From 3c4734765e2cb4ab7cbe21657b9b71cffce1330f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 16 Dec 2004 17:28:50 +0000 Subject: [PATCH] When tblgen changes, regenerate all .inc files, but do not rebuild any .o files that USE the .inc file unless the contents of the .inc file changes. This should fix the problem where reconfiguring causes all targets to be completely rebuilt (because config.h is usually modified, causing libsystem to be rebuilt, causing tblgen to be rebuilt, causing .inc files to be rebuilt, causing .o files to be rebuilt). This patch also checks in a gross hack where .o files now explicitly depend on $(BUILT_SOURCES), to avoid problems where the .inc files are not completely generated before the .o files start to compile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18986 91177308-0d34-0410-b5e6-96231b3b80d8 --- Makefile.rules | 101 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index e4b620b1ad5..4f4fb452a12 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -854,13 +854,13 @@ ifndef DISABLE_AUTO_DEPENDENCIES #--------------------------------------------------------- ifdef SHARED_LIBRARY -$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir +$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)" $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \ then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \ else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi -$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir +$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)" $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \ then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \ @@ -871,13 +871,13 @@ $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir #--------------------------------------------------------- else -$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir +$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \ then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \ else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi -$(ObjDir)/%.o: %.c $(ObjDir)/.dir +$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.c for $(BuildMode) build" $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \ then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \ @@ -888,13 +888,13 @@ endif #--------------------------------------------------------- # Create .bc files in the ObjDir directory from .cpp and .c files... #--------------------------------------------------------- -$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) +$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)" $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \ then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \ else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi -$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) +$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)" $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \ then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \ @@ -905,30 +905,30 @@ else ifdef SHARED_LIBRARY -$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir +$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)" $(LTCompile.CXX) $< -o $@ -$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir +$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)" $(LTCompile.C) $< -o $@ else -$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir +$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(Compile.CXX) $< -o $@ -$(ObjDir)/%.o: %.c $(ObjDir)/.dir +$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(Compile.C) $< -o $@ endif -$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) +$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)" $(BCCompile.CXX) $< -o $@ -$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) +$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)" $(BCCompile.C) $< -o $@ @@ -950,49 +950,103 @@ ifdef TARGET TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td) INCFiles := $(filter %.inc,$(BUILT_SOURCES)) +INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp) +.PRECIOUS: $(INCTMPFiles) $(INCFiles) -$(INCFiles) : $(TBLGEN) $(TDFiles) +# All of these files depend on tblgen and the .td files. +$(INCTMPFiles) : $(TBLGEN) $(TDFiles) -%GenRegisterNames.inc : %.td + +$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \ +$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir $(Echo) "Building $(