X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=Makefile.rules;h=c8c971f6b2810e5aa3d7942d0c7af35de5c85c22;hp=e53598b0276e4be3b14fcbd9de94322a17f6a92d;hb=127090dd75530a4e4684cbf775f915010c422bd6;hpb=90f9b8a7bcd02b154a0c068c0589171b43ffba8d diff --git a/Makefile.rules b/Makefile.rules index e53598b0276..c8c971f6b28 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -78,6 +78,12 @@ LLVMBuildTool := $(PROJ_SRC_ROOT)/utils/llvm-build/llvm-build # The files we are going to generate using llvm-build. LLVMBuildMakeFrag := $(PROJ_OBJ_ROOT)/Makefile.llvmbuild +LLVMBuildCMakeFrag := $(PROJ_OBJ_ROOT)/LLVMBuild.cmake +LLVMBuildCMakeExportsFrag := $(PROJ_OBJ_ROOT)/cmake/modules/LLVMBuildExports.cmake +LLVMBuildMakeFrags := \ + $(LLVMBuildMakeFrag) \ + $(LLVMBuildCMakeFrag) \ + $(LLVMBuildCMakeExportsFrag) LLVMConfigLibraryDependenciesInc := \ $(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc @@ -94,18 +100,20 @@ endif # # We include a dependency on this Makefile to ensure that changes to the # generation command get picked up. -$(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \ - $(PROJ_OBJ_ROOT)/Makefile.config +$(LLVMBuildMakeFrags): $(PROJ_SRC_ROOT)/Makefile.rules \ + $(PROJ_OBJ_ROOT)/Makefile.config $(Echo) Constructing LLVMBuild project information. $(Verb)$(PYTHON) $(LLVMBuildTool) \ --native-target "$(TARGET_NATIVE_ARCH)" \ --enable-targets "$(TARGETS_TO_BUILD)" \ --enable-optional-components "$(OPTIONAL_COMPONENTS)" \ --write-library-table $(LLVMConfigLibraryDependenciesInc) \ - --write-make-fragment $(LLVMBuildMakeFrag) + --write-make-fragment $(LLVMBuildMakeFrag) \ + --write-cmake-fragment $(LLVMBuildCMakeFrag) \ + --write-cmake-exports-fragment $(LLVMBuildCMakeExportsFrag) # For completeness, let Make know how the extra files are generated. -$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrag) +$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrags) # Include the generated Makefile fragment. # @@ -120,7 +128,7 @@ LLVMBUILD_INCLUDE_DEPENDENCIES := 1 # Clean the generated makefile fragment at the top-level. clean-local:: - -$(Verb) $(RM) -f $(LLVMBuildMakeFrag) + -$(Verb) $(RM) -f $(LLVMBuildMakeFrags) endif -include $(LLVMBuildMakeFrag) @@ -311,8 +319,16 @@ ifeq ($(ENABLE_LIBCPP),1) LD.Flags += -stdlib=libc++ endif -ifeq ($(ENABLE_CXX11),1) - CXX.Flags += -std=c++11 +ifeq ($(ENABLE_CXX1Y),1) + CXX.Flags += -std=c++1y +else + ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) + # MinGW and Cygwin are a bit stricter and lack things like + # 'strdup', 'stricmp', etc in c++11 mode. + CXX.Flags += -std=gnu++11 + else + CXX.Flags += -std=c++11 + endif endif ifeq ($(ENABLE_WERROR),1) @@ -361,6 +377,7 @@ ifeq ($(ENABLE_COVERAGE),1) BuildMode := $(BuildMode)+Coverage CXX.Flags += -ftest-coverage -fprofile-arcs C.Flags += -ftest-coverage -fprofile-arcs + LD.Flags += -ftest-coverage -fprofile-arcs endif # If DISABLE_ASSERTIONS=1 is specified (make command line or configured), @@ -432,7 +449,6 @@ ifeq ($(HOST_OS),MingW) endif endif -CXX.Flags += -Woverloaded-virtual CPP.BaseFlags += $(CPP.Defines) AR.Flags := cru @@ -550,9 +566,9 @@ ifeq ($(HOST_OS),Darwin) DARWIN_VERSION := `sw_vers -productVersion` endif # Strip a number like 10.4.7 to 10.4 - DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/') + 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/') + DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/') LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress SharedLinkOptions := -dynamiclib @@ -581,6 +597,8 @@ ifdef SHARED_LIBRARY ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) ifneq ($(HOST_OS),Darwin) LD.Flags += $(RPATH) -Wl,'$$ORIGIN' +else + LD.Flags += -Wl,-install_name -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)" endif endif endif @@ -608,6 +626,24 @@ ifndef KEEP_SYMBOLS Install.StripFlag += -s endif +# By default, strip dead symbols at link time +ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) +ifneq ($(HOST_OS),Darwin) +ifneq ($(HOST_ARCH),Mips) + CXX.Flags += -ffunction-sections -fdata-sections +endif +endif +endif +ifndef NO_DEAD_STRIP + ifeq ($(HOST_OS),Darwin) + LD.Flags += -Wl,-dead_strip + else + ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) + LD.Flags += -Wl,--gc-sections + endif + endif +endif + # Adjust linker flags for building an executable ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) ifndef TOOL_NO_EXPORTS @@ -643,7 +679,7 @@ endif CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \ $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \ $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \ - $(NO_MISSING_FIELD_INITIALIZERS) + $(NO_MISSING_FIELD_INITIALIZERS) $(NO_COMMENT) # Enable cast-qual for C++; the workaround is to use const_cast. CXX.Flags += -Wcast-qual @@ -651,13 +687,13 @@ ifeq ($(HOST_OS),HP-UX) CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE endif -# If we are building a universal binary on Mac OS/X, pass extra options. This +# If we are building a universal binary on Mac OS X, pass extra options. This # is useful to people that want to link the LLVM libraries into their universal # apps. # # The following can be optionally specified: # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use. -# For Mac OS/X 10.4 Intel machines, the traditional one is: +# For Mac OS X 10.4 Intel machines, the traditional one is: # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/ # UNIVERSAL_ARCH can be optionally specified to be a list of architectures # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to @@ -690,10 +726,6 @@ ifeq ($(HOST_OS),SunOS) CPP.BaseFlags += -include llvm/Support/Solaris.h endif -ifeq ($(HOST_OS),AuroraUX) -CPP.BaseFlags += -include llvm/Support/Solaris.h -endif # !HOST_OS - AuroraUX. - # On Windows, SharedLibDir != LibDir. The order is important. ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) LD.Flags += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir) @@ -757,7 +789,7 @@ else Ranlib = ranlib endif -AliasTool = ln -s +AliasTool = ln -sf #---------------------------------------------------------- # Get the list of source files and compute object file @@ -776,8 +808,10 @@ Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES)) endif BaseNameSources := $(sort $(basename $(Sources))) +SourceDirs := $(sort $(dir $(Sources))) ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o) +ObjectDirs := $(SourceDirs:%=$(ObjDir)/%) #---------------------------------------------------------- # For Mingw MSYS bash and Python/w32: @@ -814,9 +848,18 @@ $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $ $(Verb) $(MKDIR) $* > /dev/null $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@ -.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir +.PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir +#--------------------------------------------------------- +# Collect the object directories (as there may be more +# than one if the source code is spread across +# subdirectories). +#--------------------------------------------------------- + +OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir) +.PRECIOUS: $(OBJECT_DIRS) + #--------------------------------------------------------- # Handle the DIRS options for sequential construction #--------------------------------------------------------- @@ -1016,8 +1059,9 @@ ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \ -L $(SharedLibDir) endif -LLVMLibsOptions += -lLLVM-$(LLVMVersion) -LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT) +LLVM_SO_NAME = LLVM-$(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)$(LLVM_VERSION_SUFFIX) +LLVMLibsOptions += -l$(LLVM_SO_NAME) +LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)$(LLVM_SO_NAME)$(SHLIBEXT) else ifndef NO_LLVM_CONFIG @@ -1110,15 +1154,19 @@ ifdef LIBRARYNAME # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option LIBRARYNAME := $(strip $(LIBRARYNAME)) +LIBRARYALIASNAME := $(strip $(LIBRARYALIASNAME)) ifdef LOADABLE_MODULE BaseLibName.A := $(LIBRARYNAME).a BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT) +BaseAliasName.SO := $(LIBRARYALIASNAME)$(SHLIBEXT) else BaseLibName.A := lib$(LIBRARYNAME).a BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT) +BaseAliasName.SO := $(SharedPrefix)$(LIBRARYALIASNAME)$(SHLIBEXT) endif LibName.A := $(LibDir)/$(BaseLibName.A) LibName.SO := $(SharedLibDir)/$(BaseLibName.SO) +AliasName.SO := $(SharedLibDir)/$(BaseAliasName.SO) LibName.O := $(LibDir)/$(LIBRARYNAME).o #--------------------------------------------------------- @@ -1129,7 +1177,12 @@ LibName.O := $(LibDir)/$(LIBRARYNAME).o #--------------------------------------------------------- ifdef SHARED_LIBRARY -all-local:: $(LibName.SO) +all-local:: $(AliasName.SO) + +$(AliasName.SO): $(LibName.SO) +ifdef SHARED_ALIAS + $(Verb) $(AliasTool) $(BaseLibName.SO) $(AliasName.SO) +endif ifdef EXPORTED_SYMBOL_FILE $(LibName.SO): $(NativeExportsFile) @@ -1172,16 +1225,24 @@ else DestSharedLibDir := $(DESTDIR)$(PROJ_libdir) endif DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO) +DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO) install-local:: $(DestSharedLib) $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir) $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib) $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib) +ifdef SHARED_ALIAS + $(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias) + $(Verb) $(AliasTool) $(BaseLibName.SO) $(DestSharedAlias) +endif uninstall-local:: $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib) -$(Verb) $(RM) -f $(DestSharedLib) +ifdef SHARED_ALIAS + -$(Verb) $(RM) -f $(DestSharedAlias) +endif endif endif @@ -1432,6 +1493,8 @@ ifeq ($(HOST_OS),HP-UX) DISABLE_AUTO_DEPENDENCIES=1 endif +COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE) + # Provide rule sets for when dependency generation is enabled ifndef DISABLE_AUTO_DEPENDENCIES @@ -1447,27 +1510,27 @@ DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \ DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \ else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi -$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE) +$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS) $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG) $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \ $(DEPEND_MOVEFILE) -$(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE) +$(ObjDir)/%.o: %.mm $(COMPILE_DEPS) $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG) $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \ $(DEPEND_MOVEFILE) -$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE) +$(ObjDir)/%.o: %.cc $(COMPILE_DEPS) $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG) $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \ $(DEPEND_MOVEFILE) -$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE) +$(ObjDir)/%.o: %.c $(COMPILE_DEPS) $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG) $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \ $(DEPEND_MOVEFILE) -$(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE) +$(ObjDir)/%.o: %.m $(COMPILE_DEPS) $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG) $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \ $(DEPEND_MOVEFILE) @@ -1475,67 +1538,67 @@ $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE) # Provide alternate rule sets if dependencies are disabled else -$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS) $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG) $(Compile.CXX) $< -o $@ -$(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.o: %.mm $(COMPILE_DEPS) $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG) $(Compile.CXX) $< -o $@ -$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.o: %.cc $(COMPILE_DEPS) $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG) $(Compile.CXX) $< -o $@ -$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.o: %.c $(COMPILE_DEPS) $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG) $(Compile.C) $< -o $@ -$(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.o: %.m $(COMPILE_DEPS) $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG) $(Compile.C) $< -o $@ endif ## Rules for building preprocessed (.i/.ii) outputs. -$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) +$(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS) $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file" $(Verb) $(Preprocess.CXX) $< -o $@ -$(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) +$(BuildMode)/%.ii: %.mm $(COMPILE_DEPS) $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file" $(Verb) $(Preprocess.CXX) $< -o $@ -$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) +$(BuildMode)/%.ii: %.cc $(COMPILE_DEPS) $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file" $(Verb) $(Preprocess.CXX) $< -o $@ -$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES) +$(BuildMode)/%.i: %.c $(COMPILE_DEPS) $(Echo) "Compiling $*.c for $(BuildMode) build to .i file" $(Verb) $(Preprocess.C) $< -o $@ -$(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES) +$(BuildMode)/%.i: %.m $(COMPILE_DEPS) $(Echo) "Compiling $*.m for $(BuildMode) build to .i file" $(Verb) $(Preprocess.C) $< -o $@ -$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.s: %.cpp $(COMPILE_DEPS) $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG) $(Compile.CXX) $< -o $@ -S -$(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.s: %.mm $(COMPILE_DEPS) $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG) $(Compile.CXX) $< -o $@ -S -$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.s: %.cc $(COMPILE_DEPS) $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG) $(Compile.CXX) $< -o $@ -S -$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.s: %.c $(COMPILE_DEPS) $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG) $(Compile.C) $< -o $@ -S -$(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES) +$(ObjDir)/%.s: %.m $(COMPILE_DEPS) $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG) $(Compile.C) $< -o $@ -S @@ -1605,18 +1668,13 @@ $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN) $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \ $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN) $(Echo) "Building $(.td.expanded. This is useful for debugging. +$(TARGET:%=%.td.expanded): \ +%.td.expanded : %.td $(LLVM_TBLGEN) $(TDFiles) + $(Echo) "Building a fully expanded version of $(