Improve handling of SelectInst.
[oota-llvm.git] / Makefile.rules
index eee01eee60e95f7691f194441271eac0b5354512..457c7f8a27cf08258d0c4462515bd04fd8b4fddc 100644 (file)
@@ -214,13 +214,18 @@ ifdef ENABLE_PROFILING
 else
   ifdef ENABLE_OPTIMIZED
     BuildMode := Release
-    # Don't use -fomit-frame-pointer on FreeBSD
+    # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
     ifneq ($(OS),FreeBSD)
-    # Don't use -fomit-frame-pointer on Darwin, it breaks backtraces.
     ifneq ($(OS),Darwin)
       OmitFramePointer := -fomit-frame-pointer
     endif
     endif
+
+    # Darwin requires -fstrict-aliasing to be explicitly enabled.
+    ifeq ($(OS),Darwin)
+      EXTRA_OPTIONS += -fstrict-aliasing
+    endif
+
     CXX.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
     C.Flags   := $(OPTIMIZE_OPTION) $(OmitFramePointer)
     LD.Flags  := $(OPTIMIZE_OPTION)
@@ -233,6 +238,11 @@ else
   endif
 endif
 
+# IF REQUIRES_EH=1 is specified then don't disable exceptions
+ifndef REQUIRES_EH
+  CXX.Flags += -fno-exceptions
+endif
+
 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
 # then disable assertions by defining the appropriate preprocessor symbols.
 ifdef DISABLE_ASSERTIONS
@@ -244,14 +254,14 @@ else
   C.Flags   += -D_DEBUG
 endif
 
-CXX.Flags     += $(CXXFLAGS)
+CXX.Flags     += $(CXXFLAGS) -Woverloaded-virtual
 C.Flags       += $(CFLAGS)
 CPP.BaseFlags += $(CPPFLAGS)
 LD.Flags      += $(LDFLAGS)
 AR.Flags      := cru
 LibTool.Flags := --tag=CXX
 
-#Make Floating point ieee complient on alpha
+# Make Floating point IEEE compliant on Alpha.
 ifeq ($(ARCH),Alpha)
   CXX.Flags     += -mieee -fPIC
   CPP.BaseFlags += -mieee -fPIC
@@ -281,7 +291,11 @@ ifndef LLVMAS
 LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
 endif
 ifndef TBLGEN
-TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
+  ifeq ($(LLVM_CROSS_COMPILING),1)
+    TBLGEN   := $(LLVMToolDir)/tblgen$(BUILD_EXEEXT)
+  else
+    TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
+  endif
 endif
 ifndef GCCAS
 GCCAS    := $(LLVMToolDir)/gccas$(EXEEXT)
@@ -314,12 +328,17 @@ LLVMGXXWITHPATH  := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
 
 # Adjust LD.Flags and Libtool.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
+# shared library can be opened with dlopen. Also, LOADABLE_MODULE implies 
+# several other things so we force them to be defined/on.
+ifdef LOADABLE_MODULE
+  SHARED_LIBRARY := 1
+  DONT_BUILD_RELINKED := 1
+  LINK_LIBS_IN_SHARED := 1
+  LD.Flags += -module
+endif
+
 ifdef SHARED_LIBRARY
   LD.Flags += -rpath $(LibDir)
-  ifdef LOADABLE_MODULE
-    LD.Flags += -module
-  endif
 else
   LibTool.Flags += --tag=disable-shared
 endif
@@ -416,10 +435,12 @@ LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
                 $(CXX.Flags)
 Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
-Link          = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
-               $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags) $(Strip)
-Relink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
-                $(CXX.Flags) $(CompileCommonOpts) $(Relink.Flags)
+Link          = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
+               $(LD.Flags) $(Strip)
+LTLink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link)
+Relink        = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
+               $(Relink.Flags)
+LTRelink      = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink)
 LTInstall     = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
                $(Install.Flags)
 ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755 
@@ -763,15 +784,21 @@ ifdef SHARED_LIBRARY
 all-local:: $(LibName.LA)
 
 ifdef LINK_LIBS_IN_SHARED
+ifdef LOADABLE_MODULE
+SharedLibKindMessage := "Lodable Module"
+else
+SharedLibKindMessage := "Shared Library"
+endif
 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
-       $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
-       $(Verb) $(Link) -o $@ $(ObjectsLO) \
-         $(ProjLibsOptions) $(LLVMLibsOptions)
+       $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
+         $(LIBRARYNAME)$(SHLIBEXT)
+       $(Verb) $(LTLink) -o $@ $(ObjectsLO) $(ProjLibsOptions) \
+         $(LLVMLibsOptions)
        $(Verb) $(LTInstall) $@ $(LibDir)
 else
 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
        $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
-       $(Verb) $(Link) -o $@ $(ObjectsLO)
+       $(Verb) $(LTLink) -o $@ $(ObjectsLO)
        $(Verb) $(LTInstall) $@ $(LibDir)
 endif
 
@@ -875,7 +902,7 @@ all-local:: $(LibName.O)
 
 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
        $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
-       $(Verb) $(Relink) -o $@ $(ObjectsO)
+       $(Verb) $(LTRelink) -o $@ $(ObjectsO)
 
 clean-local::
 ifneq ($(strip $(LibName.O)),)
@@ -974,7 +1001,7 @@ endif
 
 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
-       $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
+       $(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
        $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
        $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
           $(StripWarnMsg) 
@@ -1288,10 +1315,14 @@ all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
 
 # Rule for building the bison based parsers...
 $(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
+ifneq ($(BISON),)
        $(Echo) "Bisoning $*.y"
        $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
        $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
        $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
+else
+       $(Echo) "Bison of $*.y SKIPPED -- bison not found"
+endif
 
 # IFF the .y file has changed since it was last checked into CVS, copy the .y
 # file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs.  We use this