llvm.org GIT mirror llvm / 3c47347
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 Chris Lattner 14 years ago
1 changed file(s) with 80 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
853853 #---------------------------------------------------------
854854 ifdef SHARED_LIBRARY
855855
856 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
856 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
857857 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
858858 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
859859 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
860860 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
861861
862 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
862 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
863863 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
864864 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
865865 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
870870 #---------------------------------------------------------
871871 else
872872
873 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
873 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
874874 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
875875 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
876876 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
877877 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
878878
879 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
879 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
880880 $(Echo) "Compiling $*.c for $(BuildMode) build"
881881 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
882882 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
887887 #---------------------------------------------------------
888888 # Create .bc files in the ObjDir directory from .cpp and .c files...
889889 #---------------------------------------------------------
890 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
890 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
891891 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
892892 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
893893 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
894894 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
895895
896 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
896 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
897897 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
898898 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
899899 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
904904
905905 ifdef SHARED_LIBRARY
906906
907 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
907 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
908908 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
909909 $(LTCompile.CXX) $< -o $@
910910
911 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
911 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
912912 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
913913 $(LTCompile.C) $< -o $@
914914
915915 else
916916
917 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
917 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
918918 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
919919 $(Compile.CXX) $< -o $@
920920
921 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
921 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
922922 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
923923 $(Compile.C) $< -o $@
924924 endif
925925
926 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
926 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
927927 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
928928 $(BCCompile.CXX) $< -o $@
929929
930 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
930 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
931931 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
932932 $(BCCompile.C) $< -o $@
933933
949949
950950 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
951951 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
952
953 $(INCFiles) : $(TBLGEN) $(TDFiles)
954
955 %GenRegisterNames.inc : %.td
952 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
953 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
954
955 # All of these files depend on tblgen and the .td files.
956 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
957
958
959 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
960 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
956961 $(Echo) "Building $(
957962 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
958963
959 %GenRegisterInfo.h.inc : %.td
964 $(TARGET:%=%GenRegisterNames.inc): \
965 %GenRegisterNames.inc : $(ObjDir)/%GenRegisterNames.inc.tmp
966 $(Verb) cmp -s $@ $< || cp $< $@
967
968 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
969 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
960970 $(Echo) "Building $(
961971 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
962972
963 %GenRegisterInfo.inc : %.td
973 $(TARGET:%=%GenRegisterInfo.h.inc): \
974 %GenRegisterInfo.h.inc : $(ObjDir)/%GenRegisterInfo.h.inc.tmp
975 $(Verb) cmp -s $@ $< || cp $< $@
976
977 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
978 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
964979 $(Echo) "Building $(
965980 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
966981
967 %GenInstrNames.inc : %.td
982 $(TARGET:%=%GenRegisterInfo.inc): \
983 %GenRegisterInfo.inc : $(ObjDir)/%GenRegisterInfo.inc.tmp
984 $(Verb) cmp -s $@ $< || cp $< $@
985
986 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
987 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
968988 $(Echo) "Building $(
969989 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
970990
971 %GenInstrInfo.inc : %.td
991 $(TARGET:%=%GenInstrNames.inc): \
992 %GenInstrNames.inc : $(ObjDir)/%GenInstrNames.inc.tmp
993 $(Verb) cmp -s $@ $< || cp $< $@
994
995 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
996 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
972997 $(Echo) "Building $(
973998 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
974999
975 %GenAsmWriter.inc : %.td
1000 $(TARGET:%=%GenInstrInfo.inc): \
1001 %GenInstrInfo.inc : $(ObjDir)/%GenInstrInfo.inc.tmp
1002 $(Verb) cmp -s $@ $< || cp $< $@
1003
1004 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1005 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
9761006 $(Echo) "Building $(
9771007 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
9781008
979 %GenATTAsmWriter.inc : %.td
1009 $(TARGET:%=%GenAsmWriter.inc): \
1010 %GenAsmWriter.inc : $(ObjDir)/%GenAsmWriter.inc.tmp
1011 $(Verb) cmp -s $@ $< || cp $< $@
1012
1013 $(TARGET:%=$(ObjDir)/%GenATTAsmWriter.inc.tmp): \
1014 $(ObjDir)/%GenATTAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
9801015 $(Echo) "Building $(
9811016 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
9821017
983 %GenIntelAsmWriter.inc : %.td
1018 $(TARGET:%=%GenATTAsmWriter.inc): \
1019 %GenATTAsmWriter.inc : $(ObjDir)/%GenATTAsmWriter.inc.tmp
1020 $(Verb) cmp -s $@ $< || cp $< $@
1021
1022 $(TARGET:%=$(ObjDir)/%GenIntelAsmWriter.inc.tmp): \
1023 $(ObjDir)/%GenIntelAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
9841024 $(Echo) "Building $(
9851025 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
9861026
987 %GenInstrSelector.inc: %.td
1027 $(TARGET:%=%GenIntelAsmWriter.inc): \
1028 %GenIntelAsmWriter.inc : $(ObjDir)/%GenIntelAsmWriter.inc.tmp
1029 $(Verb) cmp -s $@ $< || cp $< $@
1030
1031 $(TARGET:%=$(ObjDir)/%GenInstrSelector.inc.tmp): \
1032 $(ObjDir)/%GenInstrSelector.inc.tmp: %.td $(ObjDir)/.dir
9881033 $(Echo) "Building $(
9891034 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
9901035
991 %GenCodeEmitter.inc:: %.td
1036 $(TARGET:%=%GenInstrSelector.inc): \
1037 %GenInstrSelector.inc : $(ObjDir)/%GenInstrSelector.inc.tmp
1038 $(Verb) cmp -s $@ $< || cp $< $@
1039
1040 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1041 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
9921042 $(Echo) "Building $(
9931043 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1044
1045 $(TARGET:%=%GenCodeEmitter.inc): \
1046 %GenCodeEmitter.inc : $(ObjDir)/%GenCodeEmitter.inc.tmp
1047 $(Verb) cmp -s $@ $< || cp $< $@
9941048
9951049 clean-local::
9961050 -$(Verb) $(RM) -f $(INCFiles)
14041458 $(Echo) "Sources : " '$(Sources)'
14051459 $(Echo) "TDFiles : " '$(TDFiles)'
14061460 $(Echo) "INCFiles : " '$(INCFiles)'
1461 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
14071462 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
14081463 $(Echo) "Compile.C : " '$(Compile.C)'
14091464 $(Echo) "Archive : " '$(Archive)'