install-local:: all-local
install-bytecode:: install-bytecode-local
+###############################################################################
+# LLVMC: Provide rules for compiling llvmc plugins
+###############################################################################
+
+ifdef LLVMC_PLUGIN
+
+LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
+REQUIRES_EH := 1
+
+# Build a dynamic library if the user runs `make` directly from the plugin
+# directory.
+ifndef LLVMC_BUILTIN_PLUGIN
+LOADABLE_MODULE = 1
+endif
+
+# TableGen stuff...
+ifneq ($(BUILT_SOURCES),)
+LLVMC_BUILD_AUTOGENERATED_INC=1
+endif
+
+endif # LLVMC_PLUGIN
+
###############################################################################
# VARIABLES: Set up various variables based on configuration data
###############################################################################
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)
endif
ifdef SHARED_LIBRARY
- LD.Flags += -Wl,-rpath -Wl,$(LibDir)
+ LD.Flags += $(RPATH) -Wl,$(LibDir)
endif
ifdef TOOL_VERBOSE
ifneq ($(OS),Darwin)
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)
- SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle
+ 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/')
+
+ SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle \
+ -mmacosx-version-min=$(DARWIN_VERSION)
+ CompileCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
else
- SharedLinkOptions=-shared
+ 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
#----------------------------------------------------------
# Options To Invoke Tools
#----------------------------------------------------------
-CompileCommonOpts := -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
+CompileCommonOpts += -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
-Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
ifeq ($(OS),HP-UX)
endif
UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
- Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
+ Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS)
ifdef UNIVERSAL_SDK_PATH
CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
- Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
+ Relink.Flags += -isysroot $(UNIVERSAL_SDK_PATH)
endif
# Building universal cannot compute dependencies automatically.
DISABLE_AUTO_DEPENDENCIES=1
+else
+ ifeq ($(OS),Darwin)
+ ifeq ($(ARCH),x86_64)
+ CompileCommonOpts += -m64
+ else
+ ifeq ($(ARCH),x86)
+ CompileCommonOpts += -m32
+ endif
+ endif
+ endif
endif
ifeq ($(OS),SunOS)
$(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
$(LibName.O): $(ObjectsO) $(LibDir)/.dir
$(Echo) Linking $(BuildMode) Object Library $(notdir $@)
- $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlibs -nostartfiles -o $@ $(ObjectsO)
+ $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
clean-local::
ifneq ($(strip $(LibName.O)),)
ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
endif
+#---------------------------------------------------------
+# Prune Exports
+#---------------------------------------------------------
+
+# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
+# not exporting all of the weak symbols from the binary. This reduces dyld
+# startup time by 4x on darwin in some cases.
+ifdef TOOL_NO_EXPORTS
+ifeq ($(OS),Darwin)
+LD.Flags += -Wl,-exported_symbol -Wl,_main
+endif
+
+ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
+LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
+endif
+endif
+
+
#---------------------------------------------------------
# Provide targets for building the tools
#---------------------------------------------------------
###############################################################################
ifdef TARGET
+TABLEGEN_INC_FILES_COMMON = 1
+endif
+
+ifdef LLVMC_BUILD_AUTOGENERATED_INC
+TABLEGEN_INC_FILES_COMMON = 1
+endif
+
+ifdef TABLEGEN_INC_FILES_COMMON
-TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
- $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
- $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
- $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
- $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
- $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
- $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
INCFiles := $(filter %.inc,$(BUILT_SOURCES))
INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
.PRECIOUS: $(INCTMPFiles) $(INCFiles)
$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
$(Verb) $(CMP) -s $@ $< || $(CP) $< $@
+endif # TABLEGEN_INC_FILES_COMMON
+
+ifdef TARGET
+
+TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
+ $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
+ $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
+ $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
+ $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
+ $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
+ $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
+
$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
$(Echo) "Building $(<F) register names with tblgen"
clean-local::
-$(Verb) $(RM) -f $(INCFiles)
-endif
+endif # TARGET
+
+ifdef LLVMC_BUILD_AUTOGENERATED_INC
+
+LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
+
+TDFiles := $(LLVMCPluginSrc) \
+ $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
+
+$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
+ $(TBLGEN) $(TD_COMMON)
+ $(Echo) "Building LLVMC configuration library with tblgen"
+ $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
+
+endif # LLVMC_BUILD_AUTOGENERATED_INC
+
###############################################################################
# OTHER RULES: Other rules needed
###
# 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 $*)))