[llvm-branch-commits] [cfe-branch] r151567 - in /cfe/branches/Apple/palisade-IB: ClangBNI.mk Makefile order-files/ order-files/README.txt order-files/commands.py order-files/gen-clang-order-data order-files/gen-order-file order-files/inputs/ order-files/inputs/Cocoa_Prefix.h order-files/inputs/trivial-input.c order-files/inputs/trivial-input.cpp order-files/inputs/trivial-input.m

Daniel Dunbar daniel at zuster.org
Mon Feb 27 13:11:01 PST 2012


Author: ddunbar
Date: Mon Feb 27 15:11:01 2012
New Revision: 151567

URL: http://llvm.org/viewvc/llvm-project?rev=151567&view=rev
Log:
build: Update integration branch files to match our current process for building
Clang, including automatic generation of an order file.

Added:
    cfe/branches/Apple/palisade-IB/order-files/
    cfe/branches/Apple/palisade-IB/order-files/README.txt
    cfe/branches/Apple/palisade-IB/order-files/commands.py
    cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data   (with props)
    cfe/branches/Apple/palisade-IB/order-files/gen-order-file   (with props)
    cfe/branches/Apple/palisade-IB/order-files/inputs/
    cfe/branches/Apple/palisade-IB/order-files/inputs/Cocoa_Prefix.h
    cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.c
    cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.cpp
    cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.m
Modified:
    cfe/branches/Apple/palisade-IB/ClangBNI.mk
    cfe/branches/Apple/palisade-IB/Makefile

Modified: cfe/branches/Apple/palisade-IB/ClangBNI.mk
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/ClangBNI.mk?rev=151567&r1=151566&r2=151567&view=diff
==============================================================================
--- cfe/branches/Apple/palisade-IB/ClangBNI.mk (original)
+++ cfe/branches/Apple/palisade-IB/ClangBNI.mk Mon Feb 27 15:11:01 2012
@@ -15,20 +15,19 @@
 #   Clang_Driver_Mode := {Production, Development}
 #     Enable/disable the "production" driver mode.
 #
-#   Clang_Enable_CXX := {0, 1}
-#     When in production driver mode, enable C++ support.
-#
 #   Clang_Extra_Options := ...
 #     Additional options to pass to make.
 #
 #   Clang_Optimize_Option := ...
 #     The optimization flags to use.
+#
+#   Clang_Linker_Options := ...
+#     The linker flags to use.
 
 # This makefile currently supports the following build targets:
 #
 #   install-clang	 - Build the Clang compiler.
 #   install-cross	 - Build the Clang compiler, for ARM.
-#   install-libclang	 - Build the libclang dylib.
 #   install-clang-links	 - Install links from a platforms subdirectory to the
 #                          root clang.
 #
@@ -41,8 +40,10 @@
 ##
 # Variable defaults.
 
-# Install to /Developer by default.
-Default_Install_Root := /Developer
+# Install to $DT_TOOLCHAIN_DIR if it is set, otherwise $DEVELOPER_DIR.
+DEVELOPER_DIR ?= /Developer
+DT_TOOLCHAIN_DIR ?= $(DEVELOPER_DIR)
+Default_Install_Root := $(DT_TOOLCHAIN_DIR)
 # Don't install root links or license.
 Post_Install_RootLinks := 0
 Post_Install_OpenSourceLicense := 0
@@ -69,19 +70,6 @@
 # Never bootstrap.
 Clang_Enable_Bootstrap := 0
 
-else ifeq ($(MAKECMDGOALS),install-libclang)
-
-# Install to 'clang-ide' subdirectory.
-Install_Path_Suffix := usr/clang-ide
-# Only include x86 backend.
-LLVM_Backends := x86
-# Don't build compiler-rt.
-Extra_Make_Variables += CLANG_NO_RUNTIME=1
-# Use install-clang-c install target.
-LLVM_Install_Target := install-clang-c
-# Never bootstrap.
-Clang_Enable_Bootstrap := 0
-
 else ifeq ($(MAKECMDGOALS),install-clang-links)
 
 # Dummy project which only installs compiler links from the INSTALL_LOCATION to
@@ -93,35 +81,19 @@
 
 # Install root links and license when no install location is set.
 ifeq ($(INSTALL_LOCATION),)
-Post_Install_RootLinks := 1
 Post_Install_OpenSourceLicense := 1
 endif
 
+ifneq ($(Clang_Extra_Backends),)
+LLVM_Backends := $(LLVM_Backends),$(Clang_Extra_Backends)
+endif
+
 endif
 
 ##
 # B&I Build Logic
 ##
 
-# Require Train_Name to be set.
-ifeq ($(Train_Name),)
-$(error "invalid setting for train name: '$(Train_Name)'")
-endif
-
-# Require Source_To_Draw_From to be set to a known value.
-ifeq ($(Source_To_Draw_From),trunk)
-Draw_LLVM_From_Trunk := 1
-Draw_Clang_From_Trunk := 1
-else ifeq ($(Source_To_Draw_From),branch)
-Draw_LLVM_From_Trunk := 0
-Draw_Clang_From_Trunk := 0
-else ifeq ($(Source_To_Draw_From),branch-llvm-only)
-Draw_LLVM_From_Trunk := 0
-Draw_Clang_From_Trunk := 1
-else
-$(error "invalid setting for source to draw from: '$(Source_To_Draw_From)'")
-endif
-
 # Require Clang_Version to be set.
 ifeq ($(Clang_Version),)
 $(error "invalid setting for clang version: '$(Clang_Version)'")
@@ -132,14 +104,31 @@
 ifeq ($(MAKECMDGOALS),installsrc)
 else ifeq ($(MAKECMDGOALS),clean)
 else
-RC_ProjectSourceVersion := 99999.99
-$(warning "setting dummy RC_ProjectSourceVersion: '$(RC_ProjectSourceVersion)'")
+$(error "B&I build variable RC_ProjectSourceVersion must be set")
+endif
+endif
+
+# Set the Clang_Tag based on RC_ProjectNameAndSourceVersion.
+ifeq ($(RC_ProjectNameAndSourceVersion),)
+RC_ProjectNameAndSourceVersion := "clang-$(RC_ProjectSourceVersion)"
 endif
+Clang_Tag := "tags/Apple/$(RC_ProjectNameAndSourceVersion)"
+
+# Select optimized mode.
+ifeq ($(Clang_Use_Optimized), 1)
+Optimized_Configure_Flag :=  --enable-optimized
+Build_Mode := Release
+else ifeq ($(Clang_Use_Optimized), 0)
+Optimized_Configure_Flag :=  --disable-optimized
+Build_Mode := Debug
+else
+$(error "invalid setting for clang optimized: '$(Clang_Use_Optimized)'")
 endif
 
 # Select assertions mode.
 ifeq ($(Clang_Use_Assertions), 1)
 Assertions_Configure_Flag :=  --enable-assertions
+Build_Mode := $(BuildMode)+Asserts
 else ifeq ($(Clang_Use_Assertions), 0)
 Assertions_Configure_Flag :=  --disable-assertions
 else
@@ -160,18 +149,10 @@
                         CLANG_VENDOR=Apple \
                         CLANG_VENDOR_UTI=com.apple.compilers.llvm.clang
 Clang_Make_Variables += CLANG_VERSION=$(Clang_Version)
-Clang_Make_Variables += CLANG_ORDER_FILE=$(SRCROOT)/clang.order
+Clang_Make_Variables += CLANG_REPOSITORY_STRING=$(Clang_Tag)
 ifeq ($(Clang_Driver_Mode), Production)
 Clang_Make_Variables += CLANG_IS_PRODUCTION=1
 
-ifeq ($(Clang_Enable_CXX), 1)
-Clang_Make_Variables += CLANGXX_IS_PRODUCTION=1
-else ifeq ($(Clang_Enable_CXX), 0)
-# ... this is the default ...
-else
-$(error "invalid setting for clang enable C++: '$(Clang_Enable_CXX)'")
-endif
-
 # Set LLVM_VERSION_INFO make variable. We do this here because setting it in the
 # CC options for configure ends up breaking tests that can't be bothered to
 # quote things properly, and that is too hard to fix.
@@ -227,39 +208,30 @@
 # Set configure flags.
 Common_Configure_Flags = \
 		  --enable-targets=$(LLVM_Backends) \
-		  --enable-optimized \
 		  --disable-timestamps \
 		  $(Assertions_Configure_Flag) \
+		  $(Optimized_Configure_Flag) \
                   --with-optimize-option="$(Clang_Optimize_Option)" \
+                  --with-extra-ld-option="$(Clang_Linker_Options)" \
 		  --without-llvmgcc --without-llvmgxx \
 		  --disable-bindings \
-		  --disable-doxygen
+		  --disable-doxygen \
+		  --with-bug-report-url="http://developer.apple.com/bugreporter/"
 Stage1_Configure_Flags = $(Common_Configure_Flags) \
                   --with-extra-options="$(Extra_Options)"
 Configure_Flags = $(Common_Configure_Flags) \
+                  --with-internal-prefix="$(Install_Prefix)/local" \
                   --with-extra-options="$(Extra_Options) $(Clang_Final_Extra_Options)"
 
-# Determine the /Developer/usr/bin/clang major build version number
-SysClangMajorBuildVersion := \
-  $(shell /Developer/usr/bin/clang -v 2>&1 | \
-	head -1 | \
-	sed -e "s at .*\(clang-[0-9]*\).*@\1@" \
-	    -e "s@\$$@-@" | \
-	cut -d- -f2 | \
-	cut -d. -f1)
-ifneq (x$(SysClangMajorBuildVersion),x)
-ifeq ($(shell test $(SysClangMajorBuildVersion) -ge 115 && echo OK),OK)
-CC := /Developer/usr/bin/clang
-CXX := /Developer/usr/bin/clang++
-endif
-endif
+CC := $(shell xcrun -find clang)
+CXX := $(shell xcrun -find clang++)
 
 # Set stage1 compiler.
 Stage1_CC := $(CC)
 Stage1_CXX := $(CXX)
 
 # Set up any additional Clang install targets.
-Extra_Clang_Install_Targets := install-lto-h
+Extra_Clang_Install_Targets := install-lto-h install-clang-diagnostic
 
 # Install /usr/... symlinks?
 ifeq ($(Post_Install_RootLinks),1)
@@ -301,138 +273,6 @@
 
 all: install
 
-###
-# Utility targets for managing the integration branch.
-
-# Determine if we are running an SVN utility target.
-SVN_UTILITY_TARGETS := \
-	test-svn update-sources update-sources-from-tag \
-	rebranch-llvm-from-tag rebranch-clang-from-tag \
-	rebranch-clang-from-revision \
-	tag-clang retag-clang
-ifneq ($(strip $(foreach i,$(SVN_UTILITY_TARGETS), $(filter $(i),$(MAKECMDGOALS)))),)
-SVN_UTILITY_MODE := 1
-$(warning NOTE: Running SVN utility target. Be careful!)
-$(warning )
-endif
-
-ifeq ($(SVN_UTILITY_MODE),1)
-SVN_BASE := $(shell svn info | sed -n 's/^URL: //; s,/llvm-project/.*$$,/llvm-project,p')
-SVN_CLANG := $(shell svn info | sed -n 's/^URL: //p')
-SVN_TAGS := $(SVN_BASE)/cfe/tags/Apple
-
-$(warning Using SVN base     : $(SVN_BASE))
-$(warning Using Clang SVN    : $(SVN_CLANG))
-$(warning Using SVN tag dir  : $(SVN_TAGS))
-$(warning )
-
-# Validate that we match the expected branch name, as a safety/sanity check.
-ifneq ($(SVN_CLANG),$(SVN_BASE)/cfe/branches/Apple/$(Train_Name)-IB)
-$(error Unable to recognize SVN layout, conservatively refusing to do anything.)
-endif
-
-# Define the upstream paths.
-LLVM_Branch_Path := $(SVN_BASE)/llvm/branches/Apple/$(Train_Name)
-Clang_Branch_Path := $(SVN_BASE)/cfe/branches/Apple/$(Train_Name)
-
-ifeq ($(Draw_LLVM_From_Trunk),1)
-LLVM_Upstream := $(SVN_BASE)/llvm/trunk
-else
-LLVM_Upstream := $(LLVM_Branch_Path)
-endif
-
-ifeq ($(Draw_Clang_From_Trunk),1)
-Clang_Upstream := $(SVN_BASE)/cfe/trunk
-else
-Clang_Upstream := $(Clang_Branch_Path)
-endif
-
-CompilerRT_Upstream := $(SVN_BASE)/compiler-rt/trunk
-
-# Print information on the upstream sources.
-$(warning LLVM Upstream      : $(LLVM_Upstream))
-$(warning Clang Upstream     : $(Clang_Upstream))
-$(warning CompilerRT Upstream: $(CompilerRT_Upstream))
-$(warning )
-
-# Only actually do anything when EXECUTE=1
-ifeq ($(EXECUTE), 1)
-SVN_COMMAND := svn
-else
-$(warning Not in commit mode, only echoing commands (use EXECUTE=1 to execute).)
-$(warning )
-SVN_COMMAND := @echo svn
-endif
-
-else
-SVN_COMMAND := @echo "NOT IN SVN COMMAND MODE!!!"
-endif
-
-test-svn:
-	@echo "*** TESTING SVN UTILITY MODE ***"
-	$(SVN_COMMAND) info $(SVN_BASE)
-
-update-sources:
-	@if ! [ -n "$(REVISION)" ]; then \
-	  echo Usage: make $@ REVISION=102052; \
-	  false; \
-	fi
-	$(SVN_COMMAND) rm -m 'Update.' $(SVN_CLANG)/src
-	$(SVN_COMMAND) cp -m 'Update.' $(LLVM_Upstream)@$(REVISION) $(SVN_CLANG)/src
-	$(SVN_COMMAND) cp -m 'Update.' $(Clang_Upstream)@$(REVISION) $(SVN_CLANG)/src/tools/clang
-	$(SVN_COMMAND) cp -m 'Update.' $(CompilerRT_Upstream)@$(REVISION) $(SVN_CLANG)/src/projects/compiler-rt
-	$(SVN_COMMAND) up
-
-update-sources-from-tag:
-	@if ! [ -n "$(VERSION)" ]; then \
-	  echo Usage: make $@ VERSION=122; \
-	  false; \
-	fi
-	$(SVN_COMMAND) rm -m 'Update.' $(SVN_CLANG)/src
-	$(SVN_COMMAND) cp -m 'Update from clang-$(VERSION).' $(SVN_TAGS)/clang-$(VERSION)/src $(SVN_CLANG)/src
-	$(SVN_COMMAND) up
-
-rebranch-llvm-from-tag:
-	@if ! [ -n "$(VERSION)" ]; then \
-	  echo Usage: make $@ VERSION=65; \
-	  false; \
-	fi
-	$(SVN_COMMAND) rm -m 'Remove for branch of LLVM.' $(LLVM_Branch_Path)
-	$(SVN_COMMAND) cp -m 'Rebranch LLVM from clang-$(VERSION).' $(SVN_TAGS)/clang-$(VERSION)/src $(LLVM_Branch_Path)
-	$(SVN_COMMAND) rm -m 'Rebranch LLVM from clang-$(VERSION) (cleanup 1/2)' $(LLVM_Branch_Path)/tools/clang
-	$(SVN_COMMAND) rm -m 'Rebranch LLVM from clang-$(VERSION) (cleanup 2/2)' $(LLVM_Branch_Path)/projects/compiler-rt
-
-rebranch-clang-from-tag:
-	@if ! [ -n "$(VERSION)" ]; then \
-	  echo Usage: make $@ VERSION=65; \
-	  false; \
-	fi
-	$(SVN_COMMAND) rm -m 'Remove for branch of Clang.' $(Clang_Branch_Path)
-	$(SVN_COMMAND) cp -m 'Rebranch Clang from clang-$(VERSION).' $(SVN_TAGS)/clang-$(VERSION)/src/tools/clang $(Clang_Branch_Path)
-
-rebranch-clang-from-revision:
-	@if ! [ -n "$(REVISION)" ]; then \
-	  echo Usage: make $@ REVISION=100000; \
-	  false; \
-	fi
-	$(SVN_COMMAND) rm -m 'Remove for branch of Clang.' $(Clang_Branch_Path)
-	$(SVN_COMMAND) cp -m 'Rebranch Clang from clang trunk at r$(REVISION).' $(SVN_BASE)/cfe/trunk@$(REVISION) $(Clang_Branch_Path)
-
-tag-clang:
-	@if ! [ -n "$(VERSION)" ]; then \
-	  echo Usage: make $@ VERSION=25; \
-	  false; \
-	fi
-	$(SVN_COMMAND) cp -m 'Tag.' $(SVN_CLANG) $(SVN_TAGS)/clang-$(VERSION)
-
-retag-clang:
-	@if ! [ -n "$(VERSION)" ]; then \
-	  echo Usage: make $@ VERSION=25; \
-	  false; \
-	fi
-	$(SVN_COMMAND) rm -m 'Retag.' $(SVN_TAGS)/clang-$(VERSION)
-	$(SVN_COMMAND) cp -m 'Retag.' $(SVN_CLANG) $(SVN_TAGS)/clang-$(VERSION)
-
 ##
 # Additional Tool Paths
 
@@ -464,8 +304,8 @@
 Configure	= $(Sources)/configure
 Install_Flags	= DESTDIR=$(OBJROOT)/install-$$arch ONLY_MAN_DOCS=1
 
-OSV		= $(DSTROOT)/usr/local/OpenSourceVersions
-OSL		= $(DSTROOT)/usr/local/OpenSourceLicenses
+OSV		= $(DSTROOT)/$(Install_Prefix)/local/OpenSourceVersions
+OSL		= $(DSTROOT)/$(Install_Prefix)/local/OpenSourceLicenses
 
 ##
 # Cross-builds need wrapper scripts on the path, so have a local directory
@@ -489,25 +329,42 @@
 	@echo "Installing source..."
 	$(_v) $(MKDIR) "$(SRCROOT)"
 	$(_v) $(PAX) -rw . "$(SRCROOT)"
+	$(_v) if [ ! -z "$(LLVM_SEPARATE_SOURCES)" ]; then \
+		$(MKDIR) "$(SRCROOT)/src"; \
+		rsync -ar "$(LLVM_SEPARATE_SOURCES)/" "$(SRCROOT)/src/"; \
+	fi
+	$(_v) if [ ! -z "$(CLANG_SEPARATE_SOURCES)" ]; then \
+		$(MKDIR) "$(SRCROOT)/src/tools/clang"; \
+		rsync -ar "$(CLANG_SEPARATE_SOURCES)/" "$(SRCROOT)/src/tools/clang/"; \
+	fi
+	$(_v) if [ ! -z "$(COMPILERRT_SEPARATE_SOURCES)" ]; then \
+		$(MKDIR) "$(SRCROOT)/src/projects/compiler-rt"; \
+		rsync -ar "$(COMPILERRT_SEPARATE_SOURCES)/" "$(SRCROOT)/src/projects/compiler-rt/"; \
+	fi
+	$(_v) if [ ! -z "$(LIBCXX_SEPARATE_SOURCES)" ]; then \
+		$(MKDIR) "$(SRCROOT)/src/projects/libcxx"; \
+		rsync -ar "$(LIBCXX_SEPARATE_SOURCES)/" "$(SRCROOT)/src/projects/libcxx/"; \
+	fi
+	$(_v) $(PAX) -rw . "$(SRCROOT)"
 	$(_v) $(FIND) "$(SRCROOT)" $(Find_Cruft) -depth -exec $(RMDIR) "{}" \;
 	$(_v) rm -rf "$(SRCROOT)"/src/test/*/
 	$(_v) rm -rf "$(SRCROOT)"/src/tools/clang/test/*/
+	$(_v) rm -rf "$(SRCROOT)"/src/projects/libcxx/test/*/
 
 installhdrs:
 
 ##
 # Standard Clang Build Support
 
-.PHONY: install-clang install-libclang
+.PHONY: install-clang
 .PHONY: install-clang_final build-clang build-clang_final build-clang_stage1
+.PHONY: build-clang_final_ordered
 .PHONY: configure-clang_final configure-clang_singlestage configure-clang_stage2
 .PHONY: configure-clang_stage1
 .PHONY: install-clang-rootlinks install-clang-opensourcelicense
 
 install-clang: install-clang_final $(Extra_Clang_Install_Targets)
 
-install-libclang: install-clang_final $(Extra_Clang_Install_Targets)
-
 install-clang_final: build-clang
 	$(_v) for arch in $(RC_ARCHS) ; do \
 		echo "Installing for $$arch..." && \
@@ -522,6 +379,13 @@
 		rm -rf $(OBJROOT)/install-$$arch$(Install_Prefix)/lib/clang/*/lib; \
 	done
 	./merge-lipo `for arch in $(RC_ARCHS) ; do echo $(OBJROOT)/install-$$arch ; done` $(DSTROOT)
+	$(_v) ln -sf clang $(DSTROOT)/$(Install_Prefix)/bin/cc
+	$(_v) ln -sf clang.1 $(DSTROOT)/$(Install_Prefix)/share/man/man1/cc.1
+	$(_v) if [ -f $(DSTROOT)/$(Install_Prefix)/bin/clang++ ]; then \
+	  ln -sf clang++ $(DSTROOT)/$(Install_Prefix)/bin/c++; \
+	  ln -sf clang++.1 $(DSTROOT)/$(Install_Prefix)/share/man/man1/c++.1; \
+	  ln -sf clang.1 $(DSTROOT)/$(Install_Prefix)/share/man/man1/clang++.1;\
+	fi
 	$(_v) $(FIND) $(DSTROOT) $(Find_Cruft) | $(XARGS) $(RMDIR)
 	$(_v) $(FIND) $(SYMROOT) $(Find_Cruft) | $(XARGS) $(RMDIR)
 	$(_v) $(FIND) $(DSTROOT) -perm -0111 -name '*.a' | $(XARGS) chmod a-x
@@ -531,7 +395,7 @@
 	$(_v) find $(DSTROOT) -name \*.dSYM -print | xargs rm -r
 	$(_v)- $(CHOWN) -R root:wheel $(DSTROOT) $(SYMROOT)
 
-build-clang: build-clang_final
+build-clang: build-clang_final_ordered
 
 build-clang_final: configure-clang_final
 	$(_v) for arch in $(RC_ARCHS) ; do \
@@ -539,6 +403,34 @@
 		time $(MAKE) -j$(SYSCTL) -C $(OBJROOT)/$$arch $(Build_Target) || exit 1; \
 	done
 
+# This is a special target which uses the build compiler to generate order file
+# information, and then rebuilds the compiler with the constructed order file.
+build-clang_final_ordered: build-clang_final
+	set -ex && \
+	$(_v) for arch in $(RC_ARCHS) ; do \
+		echo "Building (Final) (Ordered) for $$arch..." && \
+	        echo "Generating Order File Data for $$arch " && \
+	        $(SRCROOT)/order-files/gen-clang-order-data \
+	          --cc "$(OBJROOT)/$$arch/$(Build_Mode)/bin/clang" \
+		  --inputs "$(SRCROOT)/order-files/inputs" \
+		  --temps "$(OBJROOT)/order-data/$$arch/temps" \
+		  --outputs "$(OBJROOT)/order-data/$$arch/data"; \
+	        echo "Generating Order File for $$arch" && \
+	        $(SRCROOT)/order-files/gen-order-file \
+	          --binary "$(OBJROOT)/$$arch/$(Build_Mode)/bin/clang" \
+	          --output "$(OBJROOT)/order-data/$$arch/clang.order" \
+	          --output-unordered-symbols \
+		    "$(OBJROOT)/order-data/$$arch/unordered_symbols.txt" \
+	          --method "call_order" \
+		  "$(OBJROOT)/order-data/$$arch/"data*.log && \
+	        echo "Rebuilding With Order File" && \
+		mv "$(OBJROOT)/$$arch/$(Build_Mode)/bin/clang" \
+		  "$(OBJROOT)/$$arch/$(Build_Mode)/bin/clang.preorder" && \
+		$(MAKE) -j$(SYSCTL) \
+		  -C "$(OBJROOT)/$$arch/tools/clang/tools/driver" \
+		  "CLANG_ORDER_FILE=$(OBJROOT)/order-data/$$arch/clang.order"; \
+	done
+
 build-clang_stage1: configure-clang_stage1
 	$(_v) echo "Building (Stage 1) for $(Stage1_Compiler_Arch)..."
 	$(_v) time $(MAKE) -j$(SYSCTL) -C $(OBJROOT)/stage1-$(Stage1_Compiler_Arch) $(Build_Target_Stage1)
@@ -584,7 +476,6 @@
 	cp $(DSTROOT)/$(Install_Prefix)/share/man/man1/clang.1 $(DSTROOT)/usr/share/man/man1/
 	if [ -f $(DSTROOT)/$(Install_Prefix)/bin/clang++ ]; then \
 	  ln -sf ../../$(Install_Prefix)/bin/clang++ $(DSTROOT)/usr/bin/clang++; \
-	  ln -sf clang.1 $(DSTROOT)/$(Install_Prefix)/share/man/man1/clang++.1; \
 	  ln -sf clang.1 $(DSTROOT)/usr/share/man/man1/clang++.1; \
 	fi
 	if [ -f $(DSTROOT)/$(Install_Prefix)/lib/libLTO.dylib ]; then \
@@ -602,14 +493,16 @@
 install-clang-links:
 	$(MKDIR) -p $(DSTROOT)/$(Install_Prefix)/bin
 	ln -sf ../../../../../usr/bin/clang $(DSTROOT)/$(Install_Prefix)/bin/clang
-ifeq ($(Clang_Enable_CXX), 1)
 	ln -sf ../../../../../usr/bin/clang++ $(DSTROOT)/$(Install_Prefix)/bin/clang++
-endif
 
 install-lto-h:
 	$(MKDIR) -p $(DSTROOT)/$(Install_Prefix)/local/include/llvm-c
 	$(INSTALL_FILE) $(Sources)/include/llvm-c/lto.h $(DSTROOT)/$(Install_Prefix)/local/include/llvm-c
 
+install-clang-diagnostic:
+	$(MKDIR) -p $(DSTROOT)/$(Install_Prefix)/local/bin
+	$(INSTALL) $(Sources)/utils/clang-parse-diagnostics-file $(DSTROOT)/$(Install_Prefix)/local/bin/
+
 ##
 # Cross Compilation Build Support
 
@@ -631,6 +524,7 @@
 	./merge-lipo `for arch in $(RC_ARCHS) ; do echo $(OBJROOT)/install-$$arch ; done` $(DSTROOT)
 	$(_v) $(FIND) $(DSTROOT) $(Find_Cruft) | $(XARGS) $(RMDIR)
 	$(_v) $(FIND) $(SYMROOT) $(Find_Cruft) | $(XARGS) $(RMDIR)
+	$(_v) $(FIND) $(DSTROOT) -perm -0111 -name '*.a' | $(XARGS) chmod a-x
 	$(_v) $(FIND) $(DSTROOT) -perm -0111 -type f -print | $(XARGS) -n 1 -P $(SYSCTL) dsymutil
 	$(_v) cd $(DSTROOT) && find . -path \*.dSYM/\* -print | cpio -pdml $(SYMROOT)
 	$(_v) find $(DSTROOT) -perm -0111 -type f -print | xargs -P $(SYSCTL) strip -S
@@ -640,7 +534,7 @@
 build-cross: configure-cross
 	$(_v) for arch in $(RC_ARCHS) ; do \
 		echo "Building (Cross) for $$arch..." && \
-		$(MAKE) -j$(SYSCTL) -C $(OBJROOT)/$$arch $(Build_Target) CFLAGS="-arch $$arch $(CFLAGS)" CXXFLAGS="-arch $$arch $(CXXFLAGS)" OPTIONAL_DIRS= || exit 1; \
+		$(MAKE) -j$(SYSCTL) -C $(OBJROOT)/$$arch $(Build_Target) CFLAGS="-arch $$arch $(CFLAGS)" CXXFLAGS="-arch $$arch $(CXXFLAGS)" || exit 1; \
 	done
 
 configure-cross: setup-tools-cross
@@ -656,8 +550,7 @@
 	done
 
 # A cross-compiler configure will expect to find tools under names like
-# arm-apple-darwin10-gcc, so make sure we have them. Note that -marm
-# is added to the gcc/g++ command line due to rdar://7353031
+# arm-apple-darwin10-gcc, so make sure we have them.
 setup-tools-cross:
 	$(_v) $(MKDIR) $(OBJROOT)/bin
 	$(_v) for prog in ar nm ranlib strip lipo ld as ; do \
@@ -667,11 +560,12 @@
 	  chmod a+x $(OBJROOT)/bin/arm-apple-darwin10-$$prog || exit 1; \
 	done
 	$(_v) for prog in gcc g++ ; do \
+	  ccprog=`echo $$prog | sed -e 's/gcc/cc/' -e 's/g/c/'` && \
 	  echo '#!/bin/sh' > $(OBJROOT)/bin/arm-apple-darwin10-$$prog && \
-	  echo "ARCH='-arch armv6'" >> $(OBJROOT)/bin/arm-apple-darwin10-$$prog && \
+	  echo "ARCH='-arch armv7'" >> $(OBJROOT)/bin/arm-apple-darwin10-$$prog && \
 	  echo 'for i in $$@ ; do if [ "$$i" == "-arch" ] ; then ARCH= ; fi ; done' >> $(OBJROOT)/bin/arm-apple-darwin10-$$prog && \
-	  echo 'exec '`xcrun -find $$prog` \
-	    ' $$ARCH -isysroot '$(SDKROOT)' "$$@" -marm' \
+	  echo 'exec '`xcrun -sdk $(SDKROOT) -find $$ccprog` \
+	    ' $$ARCH -isysroot '$(SDKROOT)' "$$@"' \
 	    >> $(OBJROOT)/bin/arm-apple-darwin10-$$prog && \
 	  chmod a+x $(OBJROOT)/bin/arm-apple-darwin10-$$prog || exit 1 ; \
 	done

Modified: cfe/branches/Apple/palisade-IB/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/Makefile?rev=151567&r1=151566&r2=151567&view=diff
==============================================================================
--- cfe/branches/Apple/palisade-IB/Makefile (original)
+++ cfe/branches/Apple/palisade-IB/Makefile Mon Feb 27 15:11:01 2012
@@ -6,33 +6,26 @@
 
 # Select default assertion mode, valid values are '0' and '1'.
 Clang_Use_Assertions   := 0
+# Select default optimized mode, valid values are '0' and '1'.
+Clang_Use_Optimized    := 1
 # Select clang driver mode, valid values are 'Production' and 'Development'.
 Clang_Driver_Mode      := Production
 # Select optimization flags to use.
 Clang_Optimize_Option  := -O2
+# Select linker options to use.
+Clang_Linker_Options  := -fno-pie
 # Additional arbitrary compiler options.
 Clang_Extra_Options    := \
-	-DDISABLE_DEFAULT_STRICT_ALIASING \
-	-DDISABLE_ARM_DARWIN_USE_MOVT
+	-DDISABLE_DEFAULT_STRICT_ALIASING
 # Additional arbitrary compiler options, only passed to final configure stage.
 Clang_Final_Extra_Options := -g
-# Enable use of clang++?
-Clang_Enable_CXX       := 1
 # Build all LLVM tools; not just clang?
 Clang_Build_All        := 0
 # Set the Clang version.
-Clang_Version          := 3.0
+Clang_Version          := 3.1
 # Enable bootstrap.
 Clang_Enable_Bootstrap := 1
 
 ##
-# Source Info
-
-# The name used to identify this "train".
-Train_Name := palisade
-# Can be one of "trunk", "branch", or "branch-llvm-only".
-Source_To_Draw_From := branch
-
-##
 # Include build logic.
 include ClangBNI.mk

Added: cfe/branches/Apple/palisade-IB/order-files/README.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/README.txt?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/README.txt (added)
+++ cfe/branches/Apple/palisade-IB/order-files/README.txt Mon Feb 27 15:11:01 2012
@@ -0,0 +1 @@
+This directory contains tools for automatically generating the Clang order file.

Added: cfe/branches/Apple/palisade-IB/order-files/commands.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/commands.py?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/commands.py (added)
+++ cfe/branches/Apple/palisade-IB/order-files/commands.py Mon Feb 27 15:11:01 2012
@@ -0,0 +1,103 @@
+"""
+Miscellaneous utilities for running "scripts".
+"""
+
+import errno
+import inspect
+import os
+import sys
+
+# FIXME: Find a better place for this code.
+
+def _write_message(kind, message):
+    # Get the file/line where this message was generated.
+    f = inspect.currentframe()
+    # Step out of _write_message, and then out of wrapper.
+    f = f.f_back.f_back
+    file,line,_,_,_ = inspect.getframeinfo(f)
+    location = '%s:%d' % (os.path.basename(file), line)
+
+    print >>sys.stderr, '%s: %s: %s' % (location, kind, message)
+
+note = lambda message: _write_message('note', message)
+warning = lambda message: _write_message('warning', message)
+error = lambda message: _write_message('error', message)
+fatal = lambda message: (_write_message('fatal error', message), sys.exit(1))
+
+def rm_f(path):
+    try:
+        os.remove(path)
+    except OSError,e:
+        if e.errno != errno.ENOENT:
+            raise
+
+def mkdir_p(path):
+    """mkdir_p(path) - Make the "path" directory, if it does not exist; this
+    will also make directories for any missing parent directories."""
+    import errno
+
+    if not path or os.path.exists(path):
+        return
+
+    parent = os.path.dirname(path) 
+    if parent != path:
+        mkdir_p(parent)
+
+    try:
+        os.mkdir(path)
+    except OSError,e:
+        # Ignore EEXIST, which may occur during a race condition.
+        if e.errno != errno.EEXIST:
+            raise
+
+def capture_with_result(args, include_stderr=False, cwd=None):
+    import subprocess
+    """capture_with_result(command) -> (output, exit code)
+
+    Run the given command (or argv list) in a shell and return the standard
+    output and exit code."""
+    stderr = subprocess.PIPE
+    if include_stderr:
+        stderr = subprocess.STDOUT
+    try:
+        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=stderr,
+                             cwd=cwd)
+    except OSError,e:
+        if e.errno == errno.ENOENT:
+            fatal('no such file or directory: %r' % args[0])
+        raise
+    out,_ = p.communicate()
+    return out,p.wait()
+
+def capture(args, include_stderr=False, cwd=None):
+    import subprocess
+    """capture(command) - Run the given command (or argv list) in a shell and
+    return the standard output."""
+    return capture_with_result(args, include_stderr, cwd)[0]
+
+def which(command, paths = None):
+    """which(command, [paths]) - Look up the given command in the paths string
+    (or the PATH environment variable, if unspecified)."""
+
+    if paths is None:
+        paths = os.environ.get('PATH','')
+
+    # Check for absolute match first.
+    if os.path.exists(command):
+        return command
+
+    # Would be nice if Python had a lib function for this.
+    if not paths:
+        paths = os.defpath
+
+    # Get suffixes to search.
+    pathext = os.environ.get('PATHEXT', '').split(os.pathsep)
+
+    # Search the paths...
+    for path in paths.split(os.pathsep):
+        for ext in pathext:
+            p = os.path.join(path, command + ext)
+            if os.path.exists(p):
+                return p
+
+    return None

Added: cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data (added)
+++ cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data Mon Feb 27 15:11:01 2012
@@ -0,0 +1,181 @@
+#!/usr/bin/env python
+
+import os
+import shlex
+import subprocess
+import sys
+import time
+from optparse import OptionParser, OptionGroup
+
+import commands
+
+###
+
+def get_test_cases(opts):
+    yield (
+        'pch-gen-Cocoa', 'Cocoa_Prefix_Precompiled.h.gch', True,
+        ('-x', 'objective-c-header', 'Cocoa_Prefix.h'))
+    yield (
+        'trivial-c', None, True,
+        ('-c', 'trivial-input.c', '-O0', '-g'))
+    yield (
+        'trivial-obj-c', None, True,
+        ('-c', 'trivial-input.m', '-O0', '-g',
+         '-include', '%T/Cocoa_Prefix_Precompiled.h'))
+    yield (
+        'trivial-cxx', None, False,
+        ('-c', 'trivial-input.cpp', '-O0', '-g'))
+    yield (
+        'trivial-c-armv7', None, False,
+        ('-c', 'trivial-input.c', '-O0', '-g', '-arch', 'armv7'))
+    yield (
+        'trivial-c-Os', None, False,
+        ('-c', 'trivial-input.c', '-Os'))
+    yield (
+        'trivial-c-O3-g', None, False,
+        ('-c', 'trivial-input.c', '-O3', '-g'))
+    yield (
+        'trivial-c-i386', None, False,
+        ('-c', 'trivial-input.c', '-O0', '-g', '-arch', 'i386'))
+
+def get_cc1_command_for_args(cmd, cwd):
+    # Find the cc1 command used by the compiler. To do this we execute the
+    # compiler with '-###' to figure out what it wants to do.
+    cc_output = commands.capture(cmd + ['-###'],
+                                 include_stderr=True, cwd=cwd).strip()
+    cc_commands = []
+    for ln in cc_output.split('\n'):
+        # Filter out known garbage.
+        if (ln == 'Using built-in specs.' or
+            ln.startswith('Configured with:') or
+            ln.startswith('Target:') or
+            ln.startswith('Thread model:') or
+            ' version ' in ln):
+            continue
+        cc_commands.append(ln)
+
+    if len(cc_commands) != 1:
+        commands.fatal('unable to determine cc1 command: %r' % cc_output)
+
+    return shlex.split(cc_commands[0])
+
+def execute_dtrace_test(args, data_name, opts,
+                        suppress_stderr=False):
+    # Form the dtrace script to run.
+    if opts.use_multishot:
+        target = "pid$target:::entry"
+    else:
+        target = "oneshot$target:::entry"
+    predicate = '%s/probemod=="%s"/' % (target, os.path.basename(args[0]))
+    if opts.use_ustack:
+        action = 'ustack(1);'
+    else:
+        action = 'printf("%s\\n", probefunc);'
+    dtrace_script = "%s { %s }" % (predicate, action)
+
+    # Execute the script.
+    dtrace_args = [
+        'sudo', 'dtrace', '-xevaltime=exec', '-xmangled',
+        '-xbufsize=%dm' % (opts.buffer_size),
+        '-q', '-n', dtrace_script, 
+        '-c', ' '.join(args)]
+    commands.note("generating dtrace data for test %r: %r" % (
+            data_name, ' '.join('"%s"' % arg
+                                for arg in dtrace_args)))
+    with open("%s.test-%s-data.log" % (opts.outputs_prefix,
+                                       data_name), "w") as f:
+        if suppress_stderr:
+            stderr = subprocess.PIPE
+        else:
+            stderr = None
+        start_time = time.time()
+        subprocess.check_call(dtrace_args, stdout=f, stderr=stderr,
+                              cwd=opts.inputs_path)
+        elapsed = time.time() - start_time
+        commands.note("... data collection took %.4fs" % (elapsed,))
+
+def execute_test_case(test_case, opts):
+    cwd = opts.inputs_path
+
+    test_name,output_name,test_driver,test_args = test_case
+    if output_name is None:
+        output_name = "%s.o" % (test_name,)
+
+    # Rewrite '%T' in any arguments to be the temps path.
+    actual_args = [a.replace('%T', opts.temps_path)
+                   for a in test_args]
+    full_args = [opts.cc] + list(actual_args) + [
+        '-o', os.path.join(opts.temps_path, output_name)]
+
+    # Gather data on the driver invocation.
+    if opts.sample_driver and test_driver:
+        execute_dtrace_test(full_args + ['-###'], "%s.driver" % (test_name),
+                            opts, suppress_stderr=True)
+
+    # Extract the cc1 level command.
+    cc1_cmd = get_cc1_command_for_args(full_args, opts.inputs_path)
+
+    # We can't use dtrace's -c option if there are space in options.
+    for arg in cc1_cmd:
+        if ' ' in arg:
+            commands.fatal("unable to use dtrace on cc1 command: %r" % (
+                    cc1_cmd,))
+
+    # Gather data on the cc1 invocation.
+    execute_dtrace_test(cc1_cmd, test_name, opts)
+
+def main():
+    parser = OptionParser("%prog  [options]")
+    parser.add_option("", "--cc", dest="cc", type='str',
+                      help="Path to the compiler under test",
+                      action="store", default=None)
+    parser.add_option("", "--inputs", dest="inputs_path", type='str',
+                      help="Path to the inputs directory",
+                      action="store", metavar="PATH",
+                      default=os.path.join(os.path.dirname(__file__), 'inputs'))
+    parser.add_option("", "--temps", dest="temps_path", type='str',
+                      help="Path to a directory for temporary outputs",
+                      action="store", default="temps", metavar="PATH")
+    parser.add_option("", "--outputs", dest="outputs_prefix", type='str',
+                      help="Path (and prefix) to use for outputs",
+                      action="store", default=None, metavar="PATH")
+    parser.add_option("", "--use-multishot", dest="use_multishot",
+                      help="Record multiple function entry samples",
+                      action="store_true", default=False)
+    parser.add_option("", "--use-probefunc", dest="use_ustack",
+                      help="Record probefunc instead of ustack(1)",
+                      action="store_false", default=True)
+    parser.add_option("", "--buffer-size", dest="buffer_size",
+                      help="DTrace buffer size to use (in MB)",
+                      type=int, default=1)
+    parser.add_option("", "--without-driver", dest="sample_driver",
+                      help="Do not record driver samples",
+                      action="store_false", default=True)
+    (opts, args) = parser.parse_args()
+
+    if opts.cc is None:
+        parser.error("--cc argument is required")
+    if opts.outputs_prefix is None:
+        parser.error("--outputs argument is required")
+    if len(args) != 0:
+        parser.error("invalid number of arguments")
+
+    # Make all paths absolute.
+    opts.cc = os.path.abspath(commands.which(opts.cc))
+    opts.inputs_path = os.path.abspath(opts.inputs_path)
+    opts.temps_path = os.path.abspath(opts.temps_path)
+    opts.outputs_prefix = os.path.abspath(opts.outputs_prefix)
+
+    # Create the temps directory if it doesn't exist.
+    commands.mkdir_p(opts.temps_path)
+
+    # Create the parent of the output directory if it doesn't exist.
+    commands.mkdir_p(os.path.dirname(opts.outputs_prefix))
+
+    # Get the test cases.
+    test_cases = get_test_cases(opts)
+    for test_case in test_cases:
+        execute_test_case(test_case, opts)
+
+if __name__ == '__main__':
+    main()

Propchange: cfe/branches/Apple/palisade-IB/order-files/gen-clang-order-data
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/branches/Apple/palisade-IB/order-files/gen-order-file
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/gen-order-file?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/gen-order-file (added)
+++ cfe/branches/Apple/palisade-IB/order-files/gen-order-file Mon Feb 27 15:11:01 2012
@@ -0,0 +1,232 @@
+#!/usr/bin/env python
+
+import bisect
+import random
+import os
+import subprocess
+import sys
+import pprint
+from optparse import OptionParser, OptionGroup
+
+import commands
+
+def uniq(list):
+    seen = set()
+    for item in list:
+        if item not in seen:
+            yield item
+            seen.add(item)
+
+def form_by_call_order(symbol_lists):
+   # Simply strategy, just return symbols in order of occurrence, even across
+   # multiple runs.
+   return uniq(s
+               for symbols in symbol_lists
+               for s in symbols)
+
+def form_by_call_order_fair(symbol_lists):
+    # More complicated strategy that tries to respect the call order across all
+    # of the test cases, instead of giving a huge preference to the first test
+    # case.
+ 
+    # First, uniq all the lists.
+    uniq_lists = [list(uniq(symbols))
+                  for symbols in symbol_lists]
+ 
+    # Compute the successors for each list.
+    succs = {}
+    for symbols in uniq_lists:
+        for a,b in zip(symbols[:-1], symbols[1:]):
+            succs[a] = items = succs.get(a, [])
+            if b not in items:
+                items.append(b)
+    
+    # Emit all the symbols, but make sure to always emit all successors from any
+    # call list whenever we see a symbol.
+    #
+    # There isn't much science here, but this sometimes works better than the
+    # more naive strategy. Then again, sometimes it doesn't so more research is
+    # probably needed.
+    return uniq(s
+                for symbols in symbol_lists
+                for node in symbols
+                for s in ([node] + succs.get(node,[])))
+ 
+def form_by_frequency(symbol_lists):
+    # Form the order file by just putting the most commonly occurring symbols
+    # first. This assumes the data files didn't use the oneshot dtrace method.
+ 
+    counts = {}
+    for symbols in symbol_lists:
+        for a in symbols:
+            counts[a] = counts.get(a,0) + 1
+   
+    by_count = counts.items()
+    by_count.sort(key = lambda (_,n): -n)
+ 
+    return [s for s,n in by_count]
+ 
+def form_by_random(symbol_lists):
+    # Randomize the symbols.
+    merged_symbols = uniq(s for symbols in symbol_lists
+                          for s in symbols)
+    random.shuffle(merged_symbols)
+    return merged_symbols
+ 
+def form_by_alphabetical(symbol_lists):
+    # Alphabetize the symbols.
+    merged_symbols = list(set(s for symbols in symbol_lists
+                           for s in symbols))
+    merged_symbols.sort()
+    return merged_symbols
+ 
+###
+
+methods = dict((name[len("form_by_"):],value)
+               for name,value in locals().items()
+               if name.startswith("form_by_"))
+
+def parse_dtrace_symbol_file(path, all_symbols, all_symbols_set,
+                             missing_symbols, opts):
+    def fix_mangling(symbol):
+        if symbol[0] != '_' and symbol != 'start':
+            symbol = '_' + symbol
+        return symbol
+    def get_symbols_with_prefix(symbol):
+        start_index = bisect.bisect_left(all_symbols, symbol)
+        for s in all_symbols[start_index:]:
+            s = all_symbols[i]
+            if not s.startswith(symbol):
+                break
+            yield s
+
+    # Extract the list of symbols from the given file, which is assumed to be
+    # the output of a dtrace run logging either probefunc or ustack(1) and
+    # nothing else. The dtrace -xdemangle option needs to be used.
+    #
+    # This is particular to OS X at the moment, because of the '_' handling.
+    with open(path) as f:
+        for ln in f:
+            # Drop leading and trailing whitespace.
+            ln = ln.strip()
+            if not ln:
+                continue
+
+            # If there is a '`' in the line, assume it is a ustack(1) entry in
+            # the form of <modulename>`<modulefunc>, where <modulefunc> is never
+            # truncated (but does need the mangling patched).
+            if '`' in ln:
+                yield fix_mangling(ln.split('`',1)[1])
+                continue
+
+            # Otherwise, assume this is a probefunc printout. DTrace on OS X
+            # seems to have a bug where it prints the mangled version of symbols
+            # which aren't C++ mangled. We just add a '_' to anything but start
+            # which doesn't already have a '_'.
+            symbol = fix_mangling(ln)
+
+            # If we don't know all the symbols, or the symbol is one of them,
+            # just return it.
+            if not all_symbols_set or symbol in all_symbols_set:
+                yield symbol
+                continue
+
+            # Otherwise, we have a symbol name which isn't present in the
+            # binary. We assume it is truncated, and try to extend it.
+
+            # Get all the symbols with this prefix.
+            possible_symbols = list(get_symbols_with_prefix(symbol))
+            if not possible_symbols:
+               return
+ 
+            # If we found too many possible symbols, ignore this as a prefix.
+            if len(possible_symbols) > 100:
+               print >>sys.stderr, (
+                  "warning: ignoring symbol %r (no match and too many "
+                  "possible suffixes") % (symbol,)
+               return
+ 
+            # Report that we resolved a missing symbol.
+            if opts.show_missing_symbols and symbol not in missing_symbols:
+               print >>sys.stderr, (
+                  "warning: resolved missing symbol %r" % (symbol,))
+               missing_symbols.add(symbol)
+
+            # Otherwise, treat all the possible matches as having occurred. This
+            # is an over-approximation, but it should be ok in practice.
+            for s in possible_symbols:
+               yield s
+
+def main():
+    parser = OptionParser("%prog  [options] <dtrace data files>*]")
+    parser.add_option("", "--binary", dest="binary_path", type='str',
+                      help=("Path to the binary being ordered "
+                            "(for getting all symbols)"),
+                      action="store", default=None, metavar="PATH")
+    parser.add_option("", "--output", dest="output_path",
+                      help="path to output order file to write",
+                      default=None, metavar="PATH")
+    parser.add_option("", "--show-missing-symbols", dest="show_missing_symbols",
+                      help=("show symbols which are 'fixed up' to a valid name "
+                            "(requires --binary)"),
+                      action="store_true", default=None)
+    parser.add_option("", "--output-unordered-symbols",
+                      dest="output_unordered_symbols_path",
+                      help=("write a list of the unordered symbols to PATH "
+                            "(requires --binary)"),
+                      default=None, metavar="PATH")
+    parser.add_option("", "--method", dest="method",
+                      help="order file generation method to use",
+                      choices=methods.keys(), default='call_order')
+    (opts, args) = parser.parse_args()
+
+    if opts.output_path is None:
+       parser.error("--output is required")
+    if len(args) < 1:
+       parser.error("invalid number of arguments")
+
+    # If the user gave us a binary, get all the symbols in the binary by
+    # snarfing 'nm' output.
+    if opts.binary_path is not None:
+       output = subprocess.check_output(['nm', '-P', opts.binary_path])
+       lines = output.split("\n")
+       all_symbols = [ln.split(' ',1)[0]
+                      for ln in lines
+                      if ln.strip()]
+       commands.note("found %d symbols in binary" % (len(all_symbols),))
+       all_symbols.sort()
+    else:
+       all_symbols = []
+    all_symbols_set = set(all_symbols)
+
+    # Load all of the input files.
+    missing_symbols = set()
+    symbol_lists = [parse_dtrace_symbol_file(path, all_symbols, all_symbols_set,
+                                             missing_symbols, opts)
+                    for path in args]
+
+    # Execute the desire order file generation method.
+    method = methods.get(opts.method)
+    result = list(method(symbol_lists))
+
+    # Report to the user on what percentage of symbols are present in the order
+    # file.
+    num_ordered_symbols = len(result)
+    if all_symbols:
+       print >>sys.stderr, "note: order file contains %d/%d symbols (%.2f%%)" %(
+          num_ordered_symbols, len(all_symbols),
+          100.*num_ordered_symbols/len(all_symbols))
+
+       if opts.output_unordered_symbols_path:
+          ordered_symbols_set = set(result)
+          with open(opts.output_unordered_symbols_path, 'w') as f:
+             f.write("\n".join(s for s in all_symbols
+                               if s not in ordered_symbols_set))
+
+    # Write the order file.
+    with open(opts.output_path, 'w') as f:
+       f.write("\n".join(result))
+       f.write("\n")
+
+if __name__ == '__main__':
+   main()

Propchange: cfe/branches/Apple/palisade-IB/order-files/gen-order-file
------------------------------------------------------------------------------
    svn:executable = *

Added: cfe/branches/Apple/palisade-IB/order-files/inputs/Cocoa_Prefix.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/inputs/Cocoa_Prefix.h?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/inputs/Cocoa_Prefix.h (added)
+++ cfe/branches/Apple/palisade-IB/order-files/inputs/Cocoa_Prefix.h Mon Feb 27 15:11:01 2012
@@ -0,0 +1 @@
+#include <Cocoa/Cocoa.h>

Added: cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.c?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.c (added)
+++ cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.c Mon Feb 27 15:11:01 2012
@@ -0,0 +1 @@
+void f0(void) {}

Added: cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.cpp?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.cpp (added)
+++ cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.cpp Mon Feb 27 15:11:01 2012
@@ -0,0 +1,11 @@
+template <typename T>
+class C {
+  T data;
+
+public:
+  virtual T f0() { return data; }
+};
+
+int f0(C<int> x) {
+  return x.f0();
+}

Added: cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.m?rev=151567&view=auto
==============================================================================
--- cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.m (added)
+++ cfe/branches/Apple/palisade-IB/order-files/inputs/trivial-input.m Mon Feb 27 15:11:01 2012
@@ -0,0 +1,9 @@
+// Assumes prefix file is used.
+
+ at interface A : NSString
+-(void) f0;
+ at end
+
+ at implementation A
+-(void) f0 {}
+ at end





More information about the llvm-branch-commits mailing list