Refactor dependency generation for .ll files.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 12 May 2009 06:35:50 +0000 (06:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 12 May 2009 06:35:50 +0000 (06:35 +0000)
 - This matches the normal dependency generation code.

 - This also fixes the problem that when building a normal and bitcode
   archive from the same source, the dependency files would overwrite
   one another. Which was bad.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71542 91177308-0d34-0410-b5e6-96231b3b80d8

Makefile.rules

index fc22d980682e35b115063c1fbf574c076a7aba2e..bcaed80f2db744c5338100bc3221e424a7581587 100644 (file)
@@ -1227,8 +1227,8 @@ ifndef DISABLE_AUTO_DEPENDENCIES
 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
          -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
 
-# If the build succeeded, move the dependency file over.  If it failed, put an
-# empty file there.
+# If the build succeeded, move the dependency file over, otherwise
+# remove it.
 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
                   else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
 
@@ -1251,26 +1251,31 @@ $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
 #---------------------------------------------------------
 
+BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
+       -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
+
+# If the build succeeded, move the dependency file over, otherwise
+# remove it.
+BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
+                     else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
+
 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
        $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
-       $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
-                              $< -o $@ -S -emit-llvm ; \
-       then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
+       $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
+                              $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
+               $(BC_DEPEND_MOVEFILE)
 
 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
        $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
-       $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
-                              $< -o $@ -S -emit-llvm ; \
-       then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
+       $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
+                              $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
+               $(BC_DEPEND_MOVEFILE)
 
 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
        $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
-       $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
-                            $< -o $@ -S -emit-llvm ; \
-       then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
+       $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
+                              $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
+               $(BC_DEPEND_MOVEFILE)
 
 # Provide alternate rule sets if dependencies are disabled
 else
@@ -1521,8 +1526,13 @@ ifndef DISABLE_AUTO_DEPENDENCIES
 ifndef IS_CLEANING_TARGET
 
 # Get the list of dependency files
-DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
-DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
+DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
+DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
+
+# Include bitcode dependency files if using bitcode libraries
+ifdef BYTECODE_LIBRARY
+DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
+endif
 
 -include $(DependFiles) ""