LoopIndexSplit needs to inform the loop pass manager of the instructions it is
[oota-llvm.git] / Makefile.rules
index 9f0e58c42841ff84c9705af41b60144758a0df01..e6c266af7f408a4e0c773aa7f55df15e7d306d1f 100644 (file)
@@ -229,10 +229,12 @@ endif
 CPP.Defines :=
 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
 # this can be overridden on the make command line.
-ifneq ($(OS),MingW)
-  OPTIMIZE_OPTION := -O3
-else
+# Avoid -O3 on Darwin, there are unresolved issues with
+# -fstrict-aliasing and ipa-type-escape radr://6756684
+ifeq ($(OS), $(filter $(OS), MingW Darwin))
   OPTIMIZE_OPTION := -O2
+else
+  OPTIMIZE_OPTION := -O3
 endif
 
 ifdef ENABLE_PROFILING
@@ -282,9 +284,18 @@ ifndef REQUIRES_RTTI
 #  CXX.Flags += -fno-rtti
 endif
 
+ifdef ENABLE_COVERAGE
+  BuildMode := $(BuildMode)+Coverage
+  # These only go to .NoRelink because otherwise we will end up
+  # linking -lgcov into the .o libraries that get built.
+  CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs
+  C.Flags.NoRelink   += -ftest-coverage -fprofile-arcs
+endif
+
 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
 # then disable assertions by defining the appropriate preprocessor symbols.
 ifdef DISABLE_ASSERTIONS
+  # Indicate that assertions are turned off using a minus sign
   BuildMode := $(BuildMode)-Asserts
   CPP.Defines += -DNDEBUG
 else
@@ -313,7 +324,7 @@ ifdef SHARED_LIBRARY
 endif
 
 ifeq ($(ENABLE_PIC),1)
-  ifeq ($(LLVM_ON_WIN32),1)
+  ifeq ($(OS), $(filter $(OS), Cygwin MingW))
     # Nothing. Win32 defaults to PIC and warns when given -fPIC
   else
     ifeq ($(OS),Darwin)
@@ -420,6 +431,26 @@ endif
 # Adjust to user's request
 #--------------------------------------------------------------------
 
+ifeq ($(OS),Darwin)
+  DARWIN_VERSION := `sw_vers -productVersion`
+  # Strip a number like 10.4.7 to 10.4
+  DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
+  # Get "4" out of 10.4 for later pieces in the makefile.
+  DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
+
+  SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
+                    -dynamiclib -mmacosx-version-min=$(DARWIN_VERSION)
+  TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
+else
+  ifeq ($(OS),Cygwin)
+    SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
+                      -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
+                      -Wl,--enable-runtime-pseudo-relocs
+  else
+    SharedLinkOptions=-shared
+  endif
+endif
+
 # Adjust LD.Flags depending on the kind of library that is to be built. Note
 # that if LOADABLE_MODULE is specified then the resulting shared library can
 # be opened with dlopen.
@@ -428,7 +459,9 @@ ifdef LOADABLE_MODULE
 endif
 
 ifdef SHARED_LIBRARY
-  LD.Flags += -Wl,-rpath -Wl,$(LibDir)
+ifneq ($(DARWIN_MAJVERS),4)
+  LD.Flags += $(RPATH) -Wl,$(LibDir)
+endif
 endif
 
 ifdef TOOL_VERBOSE
@@ -456,22 +489,15 @@ endif
 
 # Adjust linker flags for building an executable
 ifneq ($(OS),Darwin)
+ifneq ($(DARWIN_MAJVERS),4)
 ifdef TOOLNAME
 ifdef EXAMPLE_TOOL
-  LD.Flags += -Wl,-rpath -Wl,$(ExmplDir) -export-dynamic
+  LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
 else
-  LD.Flags += -Wl,-rpath -Wl,$(ToolDir) -export-dynamic
+  LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
 endif
 endif
 endif
-
-ifeq ($(OS),Darwin)
-  DARWIN_VERSION := `sw_vers -productVersion`
-  SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle \
-                    -mmacosx-version-min=$(DARWIN_VERSION)
-  CompileCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
-else
-  SharedLinkOptions=-shared
 endif
 
 #----------------------------------------------------------
@@ -510,6 +536,16 @@ ifdef UNIVERSAL
 
   # Building universal cannot compute dependencies automatically.
   DISABLE_AUTO_DEPENDENCIES=1
+else
+  ifeq ($(OS),Darwin)
+    ifeq ($(ARCH),x86_64)
+      TargetCommonOpts = -m64
+    else
+      ifeq ($(ARCH),x86)
+        TargetCommonOpts = -m32
+      endif
+    endif
+  endif
 endif
 
 ifeq ($(OS),SunOS)
@@ -525,29 +561,37 @@ CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
                 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
                 $(CPP.BaseFlags)
 
- ifeq ($(BUILD_COMPONENT), 1)
-  Compile.C     = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
-  Compile.CXX   = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
-  Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
-  Link          = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
-                  $(LD.Flags) $(Strip)
-  Relink        = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
-                 $(Relink.Flags)
+ifeq ($(BUILD_COMPONENT), 1)
+  Compile.C     = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
+                  $(TargetCommonOpts) $(CompileCommonOpts) -c
+  Compile.CXX   = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(TargetCommonOpts) $(CompileCommonOpts) -c
+  Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(TargetCommonOpts) \
+                  $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
+  Link          = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
+  Relink        = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
+                  $(CompileCommonOpts) $(Relink.Flags)
 else
-  Compile.C     = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
-  Compile.CXX   = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
-  Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
-  Link          = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
-                  $(LD.Flags) $(Strip)
-  Relink        = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
-                 $(Relink.Flags)
-endif
-
-BCCompile.C   = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts)
-Preprocess.C  = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -E
+  Compile.C     = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
+                  $(TargetCommonOpts) $(CompileCommonOpts) -c
+  Compile.CXX   = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(TargetCommonOpts) $(CompileCommonOpts) -c
+  Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) \
+                  $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
+  Link          = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(TargetCommonOpts)  $(CompileCommonOpts) $(LD.Flags) $(Strip)
+  Relink        = $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
+                  $(CompileCommonOpts) $(Relink.Flags)
+endif
+
+BCCompile.C   = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) \
+                $(TargetCommonOpts) $(CompileCommonOpts)
+Preprocess.C  = $(CC) $(CPP.Flags) $(C.Flags) \
+                $(TargetCommonOpts) $(CompileCommonOpts) -E
 
 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
-                $(CompileCommonOpts)
+                $(TargetCommonOpts) $(CompileCommonOpts)
 
 ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755
 ScriptInstall = $(INSTALL) -m 0755
@@ -778,8 +822,8 @@ $(LLVM_CONFIG):
 
 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
 
-ProjLibsOptions += $(shell $(LLVM_CONFIG) --libs     $(LINK_COMPONENTS))
-ProjLibsPaths   += $(LLVM_CONFIG) \
+LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs     $(LINK_COMPONENTS))
+LLVMLibsPaths   += $(LLVM_CONFIG) \
                   $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
 endif
 endif
@@ -1097,8 +1141,12 @@ endif
 # startup time by 4x on darwin in some cases.
 ifdef TOOL_NO_EXPORTS
 ifeq ($(OS),Darwin)
+
+# Tiger tools don't support this.
+ifneq ($(DARWIN_MAJVERS),4)
 LD.Flags += -Wl,-exported_symbol -Wl,_main
 endif
+endif
 
 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
@@ -1315,15 +1363,16 @@ ifdef LLVMC_BUILD_AUTOGENERATED_INC
 TABLEGEN_INC_FILES_COMMON = 1
 endif
 
+ifdef CLANG_BUILD_DIAGNOSTICS_INC
+TABLEGEN_INC_FILES_COMMON = 1
+endif
+
 ifdef TABLEGEN_INC_FILES_COMMON
 
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
 
-# All of these files depend on tblgen and the .td files.
-$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
-
 # INCFiles rule: All of the tblgen generated files are emitted to
 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
 # us to only "touch" the real file if the contents of it change.  IOW, if
@@ -1345,6 +1394,9 @@ TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
            $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
            $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
 
+# All of these files depend on tblgen and the .td files.
+$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
+
 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
        $(Echo) "Building $(<F) register names with tblgen"
@@ -1429,6 +1481,14 @@ $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
 
 endif # LLVMC_BUILD_AUTOGENERATED_INC
 
+ifdef CLANG_BUILD_DIAGNOSTICS_INC
+
+$(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN)
+       $(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
+       $(Verb) $(MKDIR) $(@D)
+       $(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
+
+endif
 
 ###############################################################################
 # OTHER RULES: Other rules needed
@@ -1832,7 +1892,7 @@ printvars::
 ###
 # Debugging
 
-# General debugging rule, use 'make print-XXX' to print the
+# General debugging rule, use 'make dbg-print-XXX' to print the
 # definition, value and origin of XXX.
-print-%:
+make-print-%:
        $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))