X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Makefile.rules;h=6c7ec02d15481dfcecfcbf66a308536c207a6f1c;hb=b54a0ac20ac76f845026eab8fca112d1d40927de;hp=ed7e0e904788fc060c0b89546aa4ebb5a6b2b4f2;hpb=8d4021c83142bfaf65b234b625ea2897a1e06e03;p=oota-llvm.git diff --git a/Makefile.rules b/Makefile.rules index ed7e0e90478..6c7ec02d154 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -274,7 +274,7 @@ CPP.Defines := ifeq ($(ENABLE_OPTIMIZED),1) BuildMode := Release # Don't use -fomit-frame-pointer on Darwin or FreeBSD. - ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin FreeBSD GNU/kFreeBSD)) + ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD)) OmitFramePointer := -fomit-frame-pointer endif @@ -550,9 +550,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 @@ -608,6 +608,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 @@ -776,8 +794,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 +834,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 #--------------------------------------------------------- @@ -1290,7 +1319,7 @@ LD.Flags += -Wl,-exported_symbol,_main endif endif -ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD GNU/kFreeBSD GNU)) +ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU)) ifneq ($(ARCH), Mips) LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map endif @@ -1432,6 +1461,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 +1478,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 +1506,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