From daniel at zuster.org Mon Jan 18 00:48:06 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:48:06 -0000 Subject: [llvm-commits] [compiler-rt] r93711 - /compiler-rt/trunk/test/Unit/trampoline_setup_test.c Message-ID: <201001180648.o0I6m7Kj020554@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:48:06 2010 New Revision: 93711 URL: http://llvm.org/viewvc/llvm-project?rev=93711&view=rev Log: Unbreak trampoline test. Modified: compiler-rt/trunk/test/Unit/trampoline_setup_test.c Modified: compiler-rt/trunk/test/Unit/trampoline_setup_test.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/Unit/trampoline_setup_test.c?rev=93711&r1=93710&r2=93711&view=diff ============================================================================== --- compiler-rt/trunk/test/Unit/trampoline_setup_test.c (original) +++ compiler-rt/trunk/test/Unit/trampoline_setup_test.c Mon Jan 18 00:48:06 2010 @@ -24,14 +24,13 @@ * Note that, nested functions are not ISO C and are not supported in Clang. */ -#ifdef __gcc__ && !__clang__ +#if !defined(__clang__) typedef int (*nested_func_t)(int x); nested_func_t proc; -int main() -{ +int main() { /* Some locals */ int c = 10; int d = 7; @@ -55,4 +54,10 @@ return 0; } -#endif /* __clang__ */ +#else + +int main() { + return 0; +} + +#endif From daniel at zuster.org Mon Jan 18 00:48:13 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:48:13 -0000 Subject: [llvm-commits] [compiler-rt] r93712 - in /compiler-rt/trunk/make: config.mk subdir.mk Message-ID: <201001180648.o0I6mEW6020579@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:48:12 2010 New Revision: 93712 URL: http://llvm.org/viewvc/llvm-project?rev=93712&view=rev Log: Rename DebugMake variable to DEBUGMAKE for consistency (variables that are designed to be overridden), and use VERBOSE=1 instead of VERBOSE!="" for controlling verbosity. Modified: compiler-rt/trunk/make/config.mk compiler-rt/trunk/make/subdir.mk Modified: compiler-rt/trunk/make/config.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/config.mk?rev=93712&r1=93711&r2=93712&view=diff ============================================================================== --- compiler-rt/trunk/make/config.mk (original) +++ compiler-rt/trunk/make/config.mk Mon Jan 18 00:48:12 2010 @@ -65,11 +65,14 @@ LIPO := lipo CP := cp +VERBOSE := 0 +DEBUGMAKE := 0 + ### # Automatic and derived variables. # Adjust settings for verbose mode -ifndef VERBOSE +ifneq ($(VERBOSE),1) Verb := @ else Verb := Modified: compiler-rt/trunk/make/subdir.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/subdir.mk?rev=93712&r1=93711&r2=93712&view=diff ============================================================================== --- compiler-rt/trunk/make/subdir.mk (original) +++ compiler-rt/trunk/make/subdir.mk Mon Jan 18 00:48:12 2010 @@ -4,7 +4,7 @@ $(error "No Dir variable defined.") endif -ifeq ($(DebugMake),1) +ifeq ($(DEBUGMAKE),1) $(info MAKE: $(Dir): Processing subdirectory) endif @@ -39,7 +39,7 @@ SubDirsList := $(SubDirs:%=$(Dir)/%) ifeq ($(SubDirsList),) else - ifeq ($(DebugMake),1) + ifeq ($(DEBUGMAKE),1) $(info MAKE: Descending into subdirs: $(SubDirsList)) endif $(foreach subdir,$(SubDirsList),$(eval include $(subdir)/Makefile.mk)) From daniel at zuster.org Mon Jan 18 00:48:20 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:48:20 -0000 Subject: [llvm-commits] [compiler-rt] r93713 - /compiler-rt/trunk/Makefile Message-ID: <201001180648.o0I6mK9f020596@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:48:19 2010 New Revision: 93713 URL: http://llvm.org/viewvc/llvm-project?rev=93713&view=rev Log: Add basic make {help,help-hidden} targets. Modified: compiler-rt/trunk/Makefile Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93713&r1=93712&r2=93713&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Mon Jan 18 00:48:19 2010 @@ -24,6 +24,27 @@ ### # Top level targets +# FIXME: Document the available subtargets. +help: + @echo "usage: make [{VARIABLE=VALUE}*] target" + @echo + @echo "User variables:" + @echo " VERBOSE=1: Use to show all commands [default=0]" + @echo + @echo "Available targets:" + @echo " clean: clean all configurations" + @echo " test: run unit tests" + @echo " all: build all configurations" + @echo + +help-hidden: help + @echo "Debugging variables:" + @echo " DEBUGMAKE=1: enable some Makefile logging [default=0]" + @echo + @echo "Debugging targets:" + @echo " make-print-FOO: print information on the variable 'FOO'" + @echo + # Provide default clean target which is extended by other templates. .PHONY: clean clean:: From daniel at zuster.org Mon Jan 18 00:48:33 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:48:33 -0000 Subject: [llvm-commits] [compiler-rt] r93714 - in /compiler-rt/trunk: Makefile lib/Makefile.mk lib/arm/Makefile.mk lib/i386/Makefile.mk lib/ppc/Makefile.mk lib/x86_64/Makefile.mk make/config.mk make/subdir.mk make/util.mk Message-ID: <201001180648.o0I6mYTl020644@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:48:33 2010 New Revision: 93714 URL: http://llvm.org/viewvc/llvm-project?rev=93714&view=rev Log: Simplify subdirectory makefiles, and be more robust by checking that they define the appropriate variables. Modified: compiler-rt/trunk/Makefile compiler-rt/trunk/lib/Makefile.mk compiler-rt/trunk/lib/arm/Makefile.mk compiler-rt/trunk/lib/i386/Makefile.mk compiler-rt/trunk/lib/ppc/Makefile.mk compiler-rt/trunk/lib/x86_64/Makefile.mk compiler-rt/trunk/make/config.mk compiler-rt/trunk/make/subdir.mk compiler-rt/trunk/make/util.mk Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Mon Jan 18 00:48:33 2010 @@ -39,7 +39,8 @@ help-hidden: help @echo "Debugging variables:" - @echo " DEBUGMAKE=1: enable some Makefile logging [default=0]" + @echo " DEBUGMAKE=1: enable some Makefile logging [default=]" + @echo " =2: enable more Makefile logging" @echo @echo "Debugging targets:" @echo " make-print-FOO: print information on the variable 'FOO'" @@ -201,7 +202,8 @@ ### # Include child makefile fragments -$(foreach subdir,$(SubDirs),$(eval include $(subdir)/Makefile.mk)) +Dir := . +include make/subdir.mk ### # Determine the actual inputs for an optimized library. @@ -223,3 +225,8 @@ $(foreach config,$(Configs), \ $(foreach arch,$(Archs), \ $(eval $(call Final_CNA_template,$(config),$(arch))))) + +ifneq ($(DEBUGMAKE),) + $(info MAKE: Done processing Makefile) + $(info ) +endif Modified: compiler-rt/trunk/lib/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/Makefile.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/lib/Makefile.mk (original) +++ compiler-rt/trunk/lib/Makefile.mk Mon Jan 18 00:48:33 2010 @@ -7,7 +7,6 @@ # #===------------------------------------------------------------------------===# -Dir := lib SubDirs := i386 ppc x86_64 arm Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) @@ -16,5 +15,3 @@ # FIXME: use automatic dependencies? Dependencies := $(wildcard $(Dir)/*.h) - -include make/subdir.mk Modified: compiler-rt/trunk/lib/arm/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/arm/Makefile.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/lib/arm/Makefile.mk (original) +++ compiler-rt/trunk/lib/arm/Makefile.mk Mon Jan 18 00:48:33 2010 @@ -7,7 +7,6 @@ # #===------------------------------------------------------------------------===# -Dir := lib/arm SubDirs := OnlyArchs := armv6 armv7 @@ -18,5 +17,3 @@ # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) - -include make/subdir.mk Modified: compiler-rt/trunk/lib/i386/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/Makefile.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/Makefile.mk (original) +++ compiler-rt/trunk/lib/i386/Makefile.mk Mon Jan 18 00:48:33 2010 @@ -7,7 +7,6 @@ # #===------------------------------------------------------------------------===# -Dir := lib/i386 SubDirs := OnlyArchs := i386 @@ -18,5 +17,3 @@ # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) - -include make/subdir.mk Modified: compiler-rt/trunk/lib/ppc/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ppc/Makefile.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/lib/ppc/Makefile.mk (original) +++ compiler-rt/trunk/lib/ppc/Makefile.mk Mon Jan 18 00:48:33 2010 @@ -7,7 +7,6 @@ # #===------------------------------------------------------------------------===# -Dir := lib/ppc SubDirs := OnlyArchs := ppc @@ -18,5 +17,3 @@ # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) - -include make/subdir.mk Modified: compiler-rt/trunk/lib/x86_64/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/Makefile.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/lib/x86_64/Makefile.mk (original) +++ compiler-rt/trunk/lib/x86_64/Makefile.mk Mon Jan 18 00:48:33 2010 @@ -7,7 +7,6 @@ # #===------------------------------------------------------------------------===# -Dir := lib/x86_64 SubDirs := OnlyArchs := x86_64 @@ -18,5 +17,3 @@ # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) - -include make/subdir.mk Modified: compiler-rt/trunk/make/config.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/config.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/make/config.mk (original) +++ compiler-rt/trunk/make/config.mk Mon Jan 18 00:48:33 2010 @@ -11,7 +11,8 @@ Configs := Debug Release Profile # The full list of architectures we support. -Archs := i386 ppc x86_64 armv6 armv7 +Archs := i386 ppc x86_64 +# armv6 armv7 # If TargetArch is defined, only build for that architecture (and don't use # -arch). @@ -66,7 +67,7 @@ CP := cp VERBOSE := 0 -DEBUGMAKE := 0 +DEBUGMAKE := ### # Automatic and derived variables. Modified: compiler-rt/trunk/make/subdir.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/subdir.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/make/subdir.mk (original) +++ compiler-rt/trunk/make/subdir.mk Mon Jan 18 00:48:33 2010 @@ -1,13 +1,20 @@ # This file is intended to be included from each subdirectory makefile. +# +# Subdirectory makefiles must define: +# SubDirs - The subdirectories to traverse. +# ObjNames - The objects available in that directory. +# Target - The library configuration the objects should go in (Generic or +# Optimized) +# Dependencies - Any dependences for the object files. +# +# Subdirectory makefiles may define: +# OnlyArchs - Only build the objects for the listed archs. +# OnlyConfigs - Only build the objects for the listed configurations. ifeq ($(Dir),) $(error "No Dir variable defined.") endif -ifeq ($(DEBUGMAKE),1) - $(info MAKE: $(Dir): Processing subdirectory) -endif - # Expand template for each configuration and architecture. # # FIXME: This level of logic should be in primary Makefile? @@ -35,13 +42,60 @@ ### # Include child makefile fragments +# The list of variables which are intended to be overridden in a subdirectory +# makefile. +RequiredSubdirVariables := SubDirs ObjNames Target Dependencies +OptionalSubdirVariables := OnlyArchs OnlyConfigs + +# Template: subdir_traverse_template subdir +define subdir_traverse_template +$(call Set,Dir,$(1)) +ifneq ($(DEBUGMAKE),) + $$(info MAKE: $(Dir): Processing subdirectory) +endif + +# Reset subdirectory specific variables to sentinel value. +$$(foreach var,$$(RequiredSubdirVariables) $$(OptionalSubdirVariables),\ + $$(call Set,$$(var),UNDEFINED)) + +# Get the subdirectory variables. +include $(1)/Makefile.mk + +ifeq ($(DEBUGMAKE),2) +$$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\ + $$(if $$(call strneq UNDEFINED,$$($$(var))), \ + $$(info MAKE: $(Dir): $$(var) is defined), \ + $$(info MAKE: $(Dir): $$(var) is undefined))) +endif + +# Check for undefined required variables, and unset sentinel value from optional +# variables. +$$(foreach var,$(RequiredSubdirVariables),\ + $$(if $$(call strneq UNDEFINED,$$($$(var))), \ + $$(error $(Dir): variable '$$(var)' was not undefined))) +$$(foreach var,$(OptionalSubdirVariables),\ + $$(if $$(call strneq UNDEFINED,$$($$(var))),, \ + $$(call Set,$$(var),))) + +# Recurse. +include make/subdir.mk + +# Restore directory variable. +$$(call Set,Dir,$(1)) + +ifneq ($(DEBUGMAKE),) + $$(info MAKE: $$(Dir): Done processing subdirectory) +endif +endef + # Evaluate this now so we do not have to worry about order of evaluation. SubDirsList := $(SubDirs:%=$(Dir)/%) ifeq ($(SubDirsList),) else - ifeq ($(DEBUGMAKE),1) + ifneq ($(DEBUGMAKE),) $(info MAKE: Descending into subdirs: $(SubDirsList)) endif - $(foreach subdir,$(SubDirsList),$(eval include $(subdir)/Makefile.mk)) -endif + $(foreach subdir,$(SubDirsList),\ + $(eval $(call subdir_traverse_template,$(subdir)))) +endif Modified: compiler-rt/trunk/make/util.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/util.mk?rev=93714&r1=93713&r2=93714&view=diff ============================================================================== --- compiler-rt/trunk/make/util.mk (original) +++ compiler-rt/trunk/make/util.mk Mon Jan 18 00:48:33 2010 @@ -3,6 +3,18 @@ ### # Utility functions +# Function: streq LHS RHS +# +# Return "true" if LHS == RHS, otherwise "". +# +# LHS == RHS <=> (LHS subst RHS is empty) and (RHS subst LHS is empty) +streq = $(if $(1),$(if $(subst $(1),,$(2))$(subst $(2),,$(1)),,true),$(if $(2),,true)) + +# Function: strneq LHS RHS +# +# Return "true" if LHS != RHS, otherwise "". +strneq = $(if $(call streq,$(1),$(2)),,true) + # Function: Set variable value # # Set the given make variable to the given value. From daniel at zuster.org Mon Jan 18 00:48:40 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:48:40 -0000 Subject: [llvm-commits] [compiler-rt] r93715 - in /compiler-rt/trunk: Makefile make/subdir.mk Message-ID: <201001180648.o0I6mf6R020694@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:48:40 2010 New Revision: 93715 URL: http://llvm.org/viewvc/llvm-project?rev=93715&view=rev Log: Change subdir traversal to primarily cache information about what is available in subdirectories. - Rest of makefiles will move to using the information after it has been computed, instead of during subdir traversal. Also, add 'make info-functions' target, which prints information on all the functions available in compiler-rt. Also, add 'make help-devel' for listing help on targets intended for compiler-rt developers or direct users. Modified: compiler-rt/trunk/Makefile compiler-rt/trunk/make/subdir.mk Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93715&r1=93714&r2=93715&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Mon Jan 18 00:48:40 2010 @@ -37,7 +37,12 @@ @echo " all: build all configurations" @echo -help-hidden: help +help-devel: help + @echo "Development targets:" + @echo " info-functions: list available compiler-rt functions" + @echo + +help-hidden: help-devel @echo "Debugging variables:" @echo " DEBUGMAKE=1: enable some Makefile logging [default=]" @echo " =2: enable more Makefile logging" @@ -46,6 +51,14 @@ @echo " make-print-FOO: print information on the variable 'FOO'" @echo +info-functions: + @echo "compiler-rt Available Functions" + @echo + @echo "All Functions: $(AvailableFunctions)" + @$(foreach fn,$(AvailableFunctions),\ + printf " %-20s - available in (%s)\n" $(fn)\ + "$(foreach key,$(AvailableIn.$(fn)),$($(key).Dir))";) + # Provide default clean target which is extended by other templates. .PHONY: clean clean:: @@ -230,3 +243,18 @@ $(info MAKE: Done processing Makefile) $(info ) endif + +### +# Function Information +# +# FIXME: Factor out. + +AvailableObjects := $(sort $(foreach key,$(SubDirKeys),\ + $($(key).ObjNames))) +AvailableFunctions := $(AvailableObjects:%.o=%) + +# Compute lists of where each function is available. +$(foreach key,$(SubDirKeys),\ + $(foreach fn,$(subst .o,,$($(key).ObjNames)),\ + $(call Append,AvailableIn.$(fn),$(key)))) + Modified: compiler-rt/trunk/make/subdir.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/subdir.mk?rev=93715&r1=93714&r2=93715&view=diff ============================================================================== --- compiler-rt/trunk/make/subdir.mk (original) +++ compiler-rt/trunk/make/subdir.mk Mon Jan 18 00:48:40 2010 @@ -54,6 +54,11 @@ $$(info MAKE: $(Dir): Processing subdirectory) endif +# Construct the variable key for this directory. +$(call Set,DirKey,SubDir.$(subst .,,$(subst /,__,$(1)))) +$(call Append,SubDirKeys,$(DirKey)) +$(call Set,$(DirKey).Dir,$(Dir)) + # Reset subdirectory specific variables to sentinel value. $$(foreach var,$$(RequiredSubdirVariables) $$(OptionalSubdirVariables),\ $$(call Set,$$(var),UNDEFINED)) @@ -63,7 +68,7 @@ ifeq ($(DEBUGMAKE),2) $$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\ - $$(if $$(call strneq UNDEFINED,$$($$(var))), \ + $$(if $$(call strneq,UNDEFINED,$$($$(var))), \ $$(info MAKE: $(Dir): $$(var) is defined), \ $$(info MAKE: $(Dir): $$(var) is undefined))) endif @@ -71,16 +76,20 @@ # Check for undefined required variables, and unset sentinel value from optional # variables. $$(foreach var,$(RequiredSubdirVariables),\ - $$(if $$(call strneq UNDEFINED,$$($$(var))), \ + $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \ $$(error $(Dir): variable '$$(var)' was not undefined))) $$(foreach var,$(OptionalSubdirVariables),\ - $$(if $$(call strneq UNDEFINED,$$($$(var))),, \ + $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \ $$(call Set,$$(var),))) +# Collect all subdirectory variables for subsequent use. +$$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\ + $$(call Set,$(DirKey).$$(var),$$($$(var)))) + # Recurse. include make/subdir.mk -# Restore directory variable. +# Restore directory variable, for cleanliness. $$(call Set,Dir,$(1)) ifneq ($(DEBUGMAKE),) From daniel at zuster.org Mon Jan 18 00:48:48 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:48:48 -0000 Subject: [llvm-commits] [compiler-rt] r93716 - in /compiler-rt/trunk/make: test/ test/test-util.mk util.mk Message-ID: <201001180648.o0I6mme6020715@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:48:48 2010 New Revision: 93716 URL: http://llvm.org/viewvc/llvm-project?rev=93716&view=rev Log: Add more make utility functions. - With tests. :) Added: compiler-rt/trunk/make/test/ compiler-rt/trunk/make/test/test-util.mk Modified: compiler-rt/trunk/make/util.mk Added: compiler-rt/trunk/make/test/test-util.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/test/test-util.mk?rev=93716&view=auto ============================================================================== --- compiler-rt/trunk/make/test/test-util.mk (added) +++ compiler-rt/trunk/make/test/test-util.mk Mon Jan 18 00:48:48 2010 @@ -0,0 +1,59 @@ +include make/util.mk + +streq_t0 = $(call streq,,) +$(call AssertEqual,streq_t0,true) +streq_t1 = $(call streq,b,) +$(call AssertEqual,streq_t1,) +streq_t2 = $(call streq,,b) +$(call AssertEqual,streq_t2,) +streq_t3 = $(call streq,b,b) +$(call AssertEqual,streq_t3,true) +streq_t4 = $(call streq,bb,b) +$(call AssertEqual,streq_t4,) +streq_t5 = $(call streq,b,bb) +$(call AssertEqual,streq_t5,) +streq_t6 = $(call streq,bb,bb) +$(call AssertEqual,streq_t6,true) + +strneq_t7 = $(call strneq,,) +$(call AssertEqual,strneq_t7,) +strneq_t8 = $(call strneq,b,) +$(call AssertEqual,strneq_t8,true) +strneq_t9 = $(call strneq,,b) +$(call AssertEqual,strneq_t9,true) +strneq_t10 = $(call strneq,b,b) +$(call AssertEqual,strneq_t10,) +strneq_t11 = $(call strneq,bb,b) +$(call AssertEqual,strneq_t11,true) +strneq_t12 = $(call strneq,b,bb) +$(call AssertEqual,strneq_t12,true) +strneq_t13 = $(call strneq,bb,bb) +$(call AssertEqual,strneq_t13,) + +contains_t0 = $(call contains,a b b c,a) +$(call AssertEqual,contains_t0,true) +contains_t1 = $(call contains,a b b c,b) +$(call AssertEqual,contains_t1,true) +contains_t2 = $(call contains,a b b c,c) +$(call AssertEqual,contains_t2,true) +contains_t3 = $(call contains,a b b c,d) +$(call AssertEqual,contains_t3,) + +isdefined_t0_defined_var := 0 +isdefined_t0 = $(call IsDefined,isdefined_t0_defined_var) +$(call AssertEqual,isdefined_t0,true) +isdefined_t1 = $(call IsDefined,isdefined_t1_never_defined_var) +$(call AssertEqual,isdefined_t1,) + +varordefault_t0_var := 1 +varordefault_t0 = $(call VarOrDefault,varordefault_t0_var.opt,$(varordefault_t0_var)) +$(call AssertEqual,varordefault_t0,1) +varordefault_t1_var := 1 +varordefault_t1_var.opt := 2 +varordefault_t1 = $(call VarOrDefault,varordefault_t1_var.opt,$(varordefault_t1_var)) +$(call AssertEqual,varordefault_t1,2) + +all: + @true +.PHONY: all + Modified: compiler-rt/trunk/make/util.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/util.mk?rev=93716&r1=93715&r2=93716&view=diff ============================================================================== --- compiler-rt/trunk/make/util.mk (original) +++ compiler-rt/trunk/make/util.mk Mon Jan 18 00:48:48 2010 @@ -1,4 +1,4 @@ -# Makefile utilities +# Generic Makefile Utilities ### # Utility functions @@ -15,6 +15,19 @@ # Return "true" if LHS != RHS, otherwise "". strneq = $(if $(call streq,$(1),$(2)),,true) +# Function: contains list item +# +# Return "true" if 'list' contains the value 'item'. +contains = $(if $(strip $(foreach i,$(1),$(if $(call streq,$(2),$(i)),T,))),true,) + +# Function: is_subset a b +# Return "true" if 'a' is a subset of 'b'. +is_subset = $(if $(strip $(set_difference $(1),$(2))),,true) + +# Function: set_difference a b +# Return a - b. +set_difference = $(foreach i,$(1),$(if $(call contains,$(2),$(i)),,$(i))) + # Function: Set variable value # # Set the given make variable to the given value. @@ -25,6 +38,47 @@ # Append the given value to the given make variable. Append = $(eval $(1) += $(2)) +# Function: IsDefined variable +# +# Check whether the given variable is defined. +IsDefined = $(call strneq,undefined,$(flavor $(1))) + +# Function: IsUndefined variable +# +# Check whether the given variable is undefined. +IsUndefined = $(call streq,undefined,$(flavor $(1))) + +# Function: VarOrDefault variable default-value +# +# Get the value of the given make variable, or the default-value if the variable +# is undefined. +VarOrDefault = $(if $(call IsDefined,$(1)),$($(1)),$(2)) + +# Function: CheckValue variable +# +# Print the name, definition, and value of a variable, for testing make +# utilities. +# +# Example: +# foo = $(call streq,a,a) +# $(call CheckValue,foo) +# Example Output: +# CHECKVALUE: foo: $(call streq,,) - true +CheckValue = $(info CHECKVALUE: $(1): $(value $(1)) - $($(1))) + +# Function: Assert value message +# +# Check that a value is true, or give an error including the given message +Assert = $(if $(1),,\ + $(error Assertion failed: $(2))) + +# Function: AssertEqual variable expected-value +# +# Check that the value of a variable is 'expected-value'. +AssertEqual = \ + $(if $(call streq,$($(1)),$(2)),,\ + $(error Assertion failed: $(1): $(value $(1)) - $($(1)) != $(2))) + ### # Clean up make behavior @@ -38,4 +92,3 @@ # and origin of XXX. make-print-%: $(error PRINT: $(value $*) = "$($*)" (from $(origin $*))) - From daniel at zuster.org Mon Jan 18 00:49:10 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:49:10 -0000 Subject: [llvm-commits] [compiler-rt] r93718 - in /compiler-rt/trunk: Makefile lib/Makefile.mk lib/arm/Makefile.mk lib/i386/Makefile.mk lib/ppc/Makefile.mk lib/x86_64/Makefile.mk make/lib_info.mk make/lib_util.mk make/subdir.mk Message-ID: <201001180649.o0I6nAR4020778@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:49:09 2010 New Revision: 93718 URL: http://llvm.org/viewvc/llvm-project?rev=93718&view=rev Log: Rename subdir 'Target' variable to 'Implementation' to be less overloaded. Modified: compiler-rt/trunk/Makefile compiler-rt/trunk/lib/Makefile.mk compiler-rt/trunk/lib/arm/Makefile.mk compiler-rt/trunk/lib/i386/Makefile.mk compiler-rt/trunk/lib/ppc/Makefile.mk compiler-rt/trunk/lib/x86_64/Makefile.mk compiler-rt/trunk/make/lib_info.mk compiler-rt/trunk/make/lib_util.mk compiler-rt/trunk/make/subdir.mk Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Mon Jan 18 00:49:09 2010 @@ -177,8 +177,8 @@ $(call Set,ActiveObjects,$(ObjNames:%=$(ActiveObjPath)/%)) # Add to the input list for the appropriate library and update the dependency. -$(call Append,$(Target).Inputs.$(ActiveConfig).$(ActiveArch),$(ActiveObjects)) -$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)/libcompiler_rt.$(Target).a: $(ActiveObjects) +$(call Append,$(Implementation).Inputs.$(ActiveConfig).$(ActiveArch),$(ActiveObjects)) +$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)/libcompiler_rt.$(Implementation).a: $(ActiveObjects) $(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.s $(Dependencies) $(ActiveObjPath)/.dir $(Summary) " ASSEMBLE: $(ActiveConfig)/$(ActiveArch): $$<" Modified: compiler-rt/trunk/lib/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/Makefile.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/lib/Makefile.mk (original) +++ compiler-rt/trunk/lib/Makefile.mk Mon Jan 18 00:49:09 2010 @@ -11,7 +11,7 @@ Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) ObjNames := $(Sources:%.c=%.o) -Target := Generic +Implementation := Generic # FIXME: use automatic dependencies? Dependencies := $(wildcard $(Dir)/*.h) Modified: compiler-rt/trunk/lib/arm/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/arm/Makefile.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/lib/arm/Makefile.mk (original) +++ compiler-rt/trunk/lib/arm/Makefile.mk Mon Jan 18 00:49:09 2010 @@ -13,7 +13,7 @@ AsmSources := $(foreach file,$(wildcard $(Dir)/*.S),$(notdir $(file))) Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) ObjNames := $(Sources:%.c=%.o) $(AsmSources:%.S=%.o) -Target := Optimized +Implementation := Optimized # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) Modified: compiler-rt/trunk/lib/i386/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/Makefile.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/Makefile.mk (original) +++ compiler-rt/trunk/lib/i386/Makefile.mk Mon Jan 18 00:49:09 2010 @@ -13,7 +13,7 @@ AsmSources := $(foreach file,$(wildcard $(Dir)/*.S),$(notdir $(file))) Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) ObjNames := $(Sources:%.c=%.o) $(AsmSources:%.S=%.o) -Target := Optimized +Implementation := Optimized # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) Modified: compiler-rt/trunk/lib/ppc/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ppc/Makefile.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/lib/ppc/Makefile.mk (original) +++ compiler-rt/trunk/lib/ppc/Makefile.mk Mon Jan 18 00:49:09 2010 @@ -13,7 +13,7 @@ AsmSources := $(foreach file,$(wildcard $(Dir)/*.S),$(notdir $(file))) Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) ObjNames := $(Sources:%.c=%.o) $(AsmSources:%.S=%.o) -Target := Optimized +Implementation := Optimized # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) Modified: compiler-rt/trunk/lib/x86_64/Makefile.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/Makefile.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/lib/x86_64/Makefile.mk (original) +++ compiler-rt/trunk/lib/x86_64/Makefile.mk Mon Jan 18 00:49:09 2010 @@ -13,7 +13,7 @@ AsmSources := $(foreach file,$(wildcard $(Dir)/*.S),$(notdir $(file))) Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) ObjNames := $(Sources:%.c=%.o) $(AsmSources:%.S=%.o) -Target := Optimized +Implementation := Optimized # FIXME: use automatic dependencies? Dependencies := $(wildcard lib/*.h $(Dir)/*.h) Modified: compiler-rt/trunk/make/lib_info.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_info.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/make/lib_info.mk (original) +++ compiler-rt/trunk/make/lib_info.mk Mon Jan 18 00:49:09 2010 @@ -42,4 +42,3 @@ $(foreach key,$(SubDirKeys),\ $(foreach fn,$(basename $($(key).ObjNames)),\ $(call Append,AvailableIn.$(fn),$(key)))) - Modified: compiler-rt/trunk/make/lib_util.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_util.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/make/lib_util.mk (original) +++ compiler-rt/trunk/make/lib_util.mk Mon Jan 18 00:49:09 2010 @@ -19,20 +19,20 @@ # defined with a certain specificity. SelectFunctionDirs_Opt_ConfigAndArch = $(strip \ $(foreach key,$(AvailableIn.$(3)),\ - $(if $(and $(call streq,Optimized,$($(key).Target)),\ + $(if $(and $(call streq,Optimized,$($(key).Implementation)),\ $(call contains,$($(key).OnlyConfigs),$(1)),\ $(call contains,$($(key).OnlyArchs),$(2))),$(key),))) SelectFunctionDirs_Opt_Config = $(strip \ $(foreach key,$(AvailableIn.$(3)),\ - $(if $(and $(call streq,Optimized,$($(key).Target)),\ + $(if $(and $(call streq,Optimized,$($(key).Implementation)),\ $(call contains,$($(key).OnlyConfigs),$(1))),$(key),))) SelectFunctionDirs_Opt_Arch = $(strip \ $(foreach key,$(AvailableIn.$(3)),\ - $(if $(and $(call streq,Optimized,$($(key).Target)),\ + $(if $(and $(call streq,Optimized,$($(key).Implementation)),\ $(call contains,$($(key).OnlyArchs),$(2))),$(key),))) SelectFunctionDirs_Gen = $(strip \ $(foreach key,$(AvailableIn.$(3)),\ - $(if $(call streq,Generic,$($(key).Target)),$(key)))) + $(if $(call streq,Generic,$($(key).Implementation)),$(key)))) # Helper function to select the right set of dirs in generic priority order. SelectFunctions_Gen = \ Modified: compiler-rt/trunk/make/subdir.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/subdir.mk?rev=93718&r1=93717&r2=93718&view=diff ============================================================================== --- compiler-rt/trunk/make/subdir.mk (original) +++ compiler-rt/trunk/make/subdir.mk Mon Jan 18 00:49:09 2010 @@ -3,8 +3,8 @@ # Subdirectory makefiles must define: # SubDirs - The subdirectories to traverse. # ObjNames - The objects available in that directory. -# Target - The library configuration the objects should go in (Generic or -# Optimized) +# Implementation - The library configuration the objects should go in (Generic or +# Optimized) # Dependencies - Any dependences for the object files. # # Subdirectory makefiles may define: @@ -44,7 +44,7 @@ # The list of variables which are intended to be overridden in a subdirectory # makefile. -RequiredSubdirVariables := SubDirs ObjNames Target Dependencies +RequiredSubdirVariables := SubDirs ObjNames Implementation Dependencies OptionalSubdirVariables := OnlyArchs OnlyConfigs # Template: subdir_traverse_template subdir From daniel at zuster.org Mon Jan 18 00:49:17 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:49:17 -0000 Subject: [llvm-commits] [compiler-rt] r93719 - in /compiler-rt/trunk: Makefile make/config.mk make/subdir.mk Message-ID: <201001180649.o0I6nHOQ020799@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:49:16 2010 New Revision: 93719 URL: http://llvm.org/viewvc/llvm-project?rev=93719&view=rev Log: Remove old build logic, this is going to be replaced by a more configurable mechanism shortly. Modified: compiler-rt/trunk/Makefile compiler-rt/trunk/make/config.mk compiler-rt/trunk/make/subdir.mk Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93719&r1=93718&r2=93719&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Mon Jan 18 00:49:16 2010 @@ -68,137 +68,6 @@ test: cd test/Unit && ./test -# Template: Config_template Config -# -# This template is used once per Config at the top-level. -define Config_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveConfig)) -$(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a) -$(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a) - -# The sublibraries to use for a generic version. -$(call Set,GenericInputs,$(foreach arch,$(TargetArchs),$(ActiveObjPath)/$(arch)/libcompiler_rt.Generic.a)) -# The sublibraries to use for an optimized version. -$(call Set,OptimizedInputs,$(foreach arch,$(TargetArchs),$(ActiveObjPath)/$(arch)/libcompiler_rt.Optimized.a)) - -# Provide top-level fat archive targets. We make sure to not try to lipo if only -# building one target arch. -$(ActiveLibGen): $(GenericInputs) $(ActiveObjPath)/.dir - $(Summary) " UNIVERSAL: $(ActiveConfig): $$@" - -$(Verb) $(RM) $$@ - $(if $(TargetArch), \ - $(Verb) $(CP) $(GenericInputs) $$@, \ - $(Verb) $(Lipo) -create -output $$@ $(GenericInputs)) -$(ActiveLibOpt): $(OptimizedInputs) $(ActiveObjPath)/.dir - $(Summary) " UNIVERSAL: $(ActiveConfig): $$@" - -$(Verb) $(RM) $$@ - $(if $(TargetArch), \ - $(Verb) $(CP) $(GenericInputs) $$@, \ - $(Verb) $(Lipo) -create -output $$@ $(OptimizedInputs)) -.PRECIOUS: $(ActiveObjPath)/.dir - -# Add to default "alias" target. -$(ActiveConfig):: $(ActiveLibGen) $(ActiveLibOpt) - -# Add to target lists. -all:: $(ActiveConfig) $(ActiveLibGen) $(ActiveLibOpt) - -# Remove entire config directory on clean. -clean:: $(ActiveObjPath)/.remove -endef - -# Template: CNA_template Config Arch -# -# This template is used once per Config/Arch at the top-level. -define CNA_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveArch,$2) -$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)) -$(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a) -$(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a) - -# Initialize inputs lists. This are extended by the CNA_subdir template. The one -# tricky bit is that we need to use these quoted, because they are not complete -# until the entire makefile has been processed. -$(call Set,GenericInputs.$(ActiveConfig).$(ActiveArch),) -$(call Set,OptimizedInputs.$(ActiveConfig).$(ActiveArch),) -# Final.Inputs is created once we have loaded all the subdirectories -# and know what the correct inputs are. - -# Provide top-level archive targets. -$(ActiveLibGen): $(ActiveObjPath)/.dir - $(Summary) " ARCHIVE: $(ActiveConfig)/$(ActiveArch): $$@" - -$(Verb) $(RM) $$@ - $(Verb) $(Archive) $$@ $$(Generic.Inputs.$(ActiveConfig).$(ActiveArch)) - $(Verb) $(Ranlib) $$@ -# FIXME: The dependency on ActiveLibGen is a hack, this picks up the -# dependencies on the generic inputs. -$(ActiveLibOpt): $(ActiveLibGen) $(ActiveObjPath)/.dir - $(Summary) " ARCHIVE: $(ActiveConfig)/$(ActiveArch): $$@" - -$(Verb) $(RM) $$@ - $(Verb) $(Archive) $$@ $$(Final.Inputs.$(ActiveConfig).$(ActiveArch)) - $(Verb) $(Ranlib) $$@ -.PRECIOUS: $(ActiveObjPath)/.dir - -# Provide some default "alias" targets. -$(ActiveConfig):: $(ActiveLibGen) $(ActiveLibOpt) -$(ActiveArch):: $(ActiveLibGen) $(ActiveLibOpt) -$(ActiveConfig)-$(ActiveArch):: $(ActiveLibGen) $(ActiveLibOpt) -endef - -$(foreach config,$(Configs), \ - $(foreach arch,$(Archs), \ - $(eval $(call CNA_template,$(config),$(arch))))) - -$(foreach config,$(Configs), \ - $(eval $(call Config_template,$(config)))) - -### -# How to build things. - -# Define rules for building on each configuration & architecture. This is not -# exactly obvious, but variables inside the template are being expanded during -# the make processing, so automatic variables must be quoted and normal -# assignment cannot be used. - -# Template: CNA_template Config Arch Dir -# Uses: GetArgs, Dependencies, ObjNames -# -# This template is used once per Config/Arch/Dir. -define CNA_subdir_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveArch,$2) -$(call Set,ActiveDir,$3) -$(call Set,ActiveSrcPath,$(ProjSrcRoot)/$(ActiveDir)) -$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveDir)/$(ActiveConfig)/$(ActiveArch)) - -$(call Set,ActiveFlags,$(call GetArgs,$(ActiveConfig),$(ActiveArch))) -$(call Set,ActiveObjects,$(ObjNames:%=$(ActiveObjPath)/%)) - -# Add to the input list for the appropriate library and update the dependency. -$(call Append,$(Implementation).Inputs.$(ActiveConfig).$(ActiveArch),$(ActiveObjects)) -$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)/libcompiler_rt.$(Implementation).a: $(ActiveObjects) - -$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.s $(Dependencies) $(ActiveObjPath)/.dir - $(Summary) " ASSEMBLE: $(ActiveConfig)/$(ActiveArch): $$<" - $(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$< -.PRECIOUS: $(ActiveObjPath)/.dir - -$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.S $(Dependencies) $(ActiveObjPath)/.dir - $(Summary) " ASSEMBLE: $(ActiveConfig)/$(ActiveArch): $$<" - $(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$< -.PRECIOUS: $(ActiveObjPath)/.dir - -$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.c $(Dependencies) $(ActiveObjPath)/.dir - $(Summary) " COMPILE: $(ActiveConfig)/$(ActiveArch): $$<" - $(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$< -.PRECIOUS: $(ActiveObjPath)/.dir - -# Remove entire config directory on clean. -clean:: $(ProjObjRoot)/$(ActiveDir)/$(ActiveConfig)/.remove -endef - ### # Directory handling magic. @@ -217,30 +86,6 @@ Dir := . include make/subdir.mk - -### -# Determine the actual inputs for an optimized library. - -# Template: Final_CNA_template Config Arch -# Uses: GetArgs, Dependencies, ObjNames -# -# This template is used once per Config/Arch. -define Final_CNA_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveArch,$2) - -$(call Set,Final.Inputs.$(ActiveConfig).$(ActiveArch),\ - $(shell make/filter-inputs \ - $(Optimized.Inputs.$(ActiveConfig).$(ActiveArch)) \ - $(Generic.Inputs.$(ActiveConfig).$(ActiveArch)))) -endef - -$(foreach config,$(Configs), \ - $(foreach arch,$(Archs), \ - $(eval $(call Final_CNA_template,$(config),$(arch))))) - -### - include make/lib_info.mk include make/lib_util.mk Modified: compiler-rt/trunk/make/config.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/config.mk?rev=93719&r1=93718&r2=93719&view=diff ============================================================================== --- compiler-rt/trunk/make/config.mk (original) +++ compiler-rt/trunk/make/config.mk Mon Jan 18 00:49:16 2010 @@ -8,48 +8,6 @@ ProjSrcRoot := $(shell pwd) ProjObjRoot := $(ProjSrcRoot) -Configs := Debug Release Profile - -# The full list of architectures we support. -Archs := i386 ppc x86_64 -# armv6 armv7 - -# If TargetArch is defined, only build for that architecture (and don't use -# -arch). -ifeq ($(OS), Darwin) - TargetArch := - TargetArchs := $(Archs) -else - TargetArch := i386 - TargetArchs := $(TargetArch) -endif - -Common.CFLAGS := -Wall -Werror - -# These names must match the configs, see GetArgs function. -Debug.CFLAGS := -g -Release.CFLAGS := -O3 -fomit-frame-pointer -Profile.CFLAGS := -pg -g - -# Function: GetArchArgs arch -# -# Return the compiler flags for the given arch. -ifeq ($(OS), Darwin) - GetArchArgs = -arch $(1) -else - # Check that we are only trying to build the target arch. - GetArchArgs = $(if $(subst $(TargetArch),,$(1)), \ - $(error "Invalid configuration, no -arch support: $(1)"), \ - ) -endif - -# Function: GetArgs config arch -# -# Return the compiler flags for the given config & arch. -GetArgs = $(if $($(1).CFLAGS), \ - $(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \ - $(error "Invalid configuration: $(1)")) - ### # Tool configuration variables. Modified: compiler-rt/trunk/make/subdir.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/subdir.mk?rev=93719&r1=93718&r2=93719&view=diff ============================================================================== --- compiler-rt/trunk/make/subdir.mk (original) +++ compiler-rt/trunk/make/subdir.mk Mon Jan 18 00:49:16 2010 @@ -15,30 +15,6 @@ $(error "No Dir variable defined.") endif -# Expand template for each configuration and architecture. -# -# FIXME: This level of logic should be in primary Makefile? -ifeq ($(OnlyConfigs),) - ConfigsToTraverse := $(Configs) -else - ConfigsToTraverse := $(OnlyConfigs) -endif - -ifeq ($(OnlyArchs),) - ArchsToTraverse := $(Archs) -else - ArchsToTraverse := $(OnlyArchs) -endif - -# If we are only targetting a single arch, only traverse that. -ifneq ($(TargetArch),) - ArchsToTraverse := $(filter $(TargetArch), $(ArchsToTraverse)) -endif - -$(foreach config,$(ConfigsToTraverse), \ - $(foreach arch,$(ArchsToTraverse), \ - $(eval $(call CNA_subdir_template,$(config),$(arch),$(Dir))))) - ### # Include child makefile fragments From daniel at zuster.org Mon Jan 18 00:49:34 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 Jan 2010 06:49:34 -0000 Subject: [llvm-commits] [compiler-rt] r93720 - in /compiler-rt/trunk: Makefile make/config.mk make/lib_info.mk make/lib_platforms.mk make/lib_util.mk make/options.mk make/platform/ make/platform/darwin_fat.mk make/platform/multi_arch.mk make/subdir.mk make/test/test-util.mk make/util.mk test/Unit/test test/timing/time Message-ID: <201001180649.o0I6nYB1020863@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Jan 18 00:49:33 2010 New Revision: 93720 URL: http://llvm.org/viewvc/llvm-project?rev=93720&view=rev Log: Add support for "platform" configurations, which define a suite of compiler-rt libraries to generate. - Each library may be built with different flags and for different architectures, and there is support for building Darwin style fat archives. - Uses an ambituous amount of make programming, but should be hidden to users and developers. Added: compiler-rt/trunk/make/lib_platforms.mk compiler-rt/trunk/make/options.mk compiler-rt/trunk/make/platform/ compiler-rt/trunk/make/platform/darwin_fat.mk compiler-rt/trunk/make/platform/multi_arch.mk Modified: compiler-rt/trunk/Makefile compiler-rt/trunk/make/config.mk compiler-rt/trunk/make/lib_info.mk compiler-rt/trunk/make/lib_util.mk compiler-rt/trunk/make/subdir.mk compiler-rt/trunk/make/test/test-util.mk compiler-rt/trunk/make/util.mk compiler-rt/trunk/test/Unit/test compiler-rt/trunk/test/timing/time Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93720&r1=93719&r2=93720&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Mon Jan 18 00:49:33 2010 @@ -1,7 +1,7 @@ SubDirs := lib # Set default rule before anything else. -all:: +all: help include make/config.mk include make/util.mk @@ -32,14 +32,22 @@ @echo " VERBOSE=1: Use to show all commands [default=0]" @echo @echo "Available targets:" - @echo " clean: clean all configurations" - @echo " test: run unit tests" - @echo " all: build all configurations" + @echo " : build the libraries for 'platform'" + @echo " clean: clean all configurations" + @echo " test: run unit tests" + @echo + @echo " info-platforms: list available platforms" + @echo " help-devel: print additional help for developers" @echo help-devel: help @echo "Development targets:" + @echo " -:" + @echo " build the libraries for a single platform config" + @echo " --:" + @echo " build the libraries for a single config and arch" @echo " info-functions: list available compiler-rt functions" + @echo " help-hidden: print help for Makefile debugging" @echo help-hidden: help-devel @@ -59,6 +67,15 @@ printf " %-20s - available in (%s)\n" $(fn)\ "$(foreach key,$(AvailableIn.$(fn)),$($(key).Dir))";) +info-platforms: + @echo "compiler-rt Available Platforms" + @echo + @echo "Platforms:" + @$(foreach key,$(PlatformKeys),\ + printf " %s - from '%s'\n" $($(key).Name) $($(key).Path);\ + printf " %s\n" "$($(key).Description)";\ + printf " Configurations: %s\n\n" "$($(key).Configs)";) + # Provide default clean target which is extended by other templates. .PHONY: clean clean:: @@ -88,6 +105,128 @@ include make/subdir.mk include make/lib_info.mk include make/lib_util.mk +include make/lib_platforms.mk + +### +# Define Platform Rules + +define PerPlatform_template +$(call Set,Tmp.Key,$(1)) +$(call Set,Tmp.Name,$($(Tmp.Key).Name)) +$(call Set,Tmp.Configs,$($(Tmp.Key).Configs)) +$(call Set,Tmp.ObjPath,$(ProjObjRoot)/$(Tmp.Name)) + +# Top-Level Platform Target +$(Tmp.Name):: $(Tmp.Configs:%=$(Tmp.ObjPath)/%/libcompiler_rt.a) +.PHONY: $(Tmp.Name) + +clean:: + $(Verb) rm -rf $(Tmp.ObjPath) + +# Per-Config Libraries +$(foreach config,$(Tmp.Configs),\ + $(call PerPlatformConfig_template,$(config))) +endef + +define PerPlatformConfig_template +$(call Set,Tmp.Config,$(1)) +$(call Set,Tmp.ObjPath,$(ProjObjRoot)/$(Tmp.Name)/$(Tmp.Config)) + +# Compute the archs to build, depending on whether this is a universal build or +# not. +$(call Set,Tmp.ArchsToBuild,\ + $(if $(call IsDefined,$(Tmp.Key).UniversalArchs),\ + $($(Tmp.Key).UniversalArchs),\ + $(call VarOrDefault,$(Tmp.Key).Arch.$(Tmp.Config),$($(Tmp.Key).Arch)))) + +# Copy or lipo to create the per-config library. +$(call Set,Tmp.Inputs,$(Tmp.ArchsToBuild:%=$(Tmp.ObjPath)/%/libcompiler_rt.a)) +$(Tmp.ObjPath)/libcompiler_rt.a: $(Tmp.Inputs) $(Tmp.ObjPath)/.dir + $(Summary) " FINAL-ARCHIVE: $(Tmp.Name)/$(Tmp.Config): $$@" + -$(Verb) $(RM) $$@ + $(if $(call streq,1,$(words $(Tmp.ArchsToBuild))), \ + $(Verb) $(CP) $(Tmp.Inputs) $$@, \ + $(Verb) $(LIPO) -create -output $$@ $(Tmp.Inputs)) +.PRECIOUS: $(Tmp.ObjPath)/.dir + +# Per-Config Targets +$(Tmp.Name)-$(Tmp.Config):: $(Tmp.ObjPath)/libcompiler_rt.a +.PHONY: $(Tmp.Name)-$(Tmp.Config) + +# Per-Config-Arch Libraries +$(foreach arch,$(Tmp.ArchsToBuild),\ + $(call PerPlatformConfigArch_template,$(arch))) +endef + +define PerPlatformConfigArch_template +$(call Set,Tmp.Arch,$(1)) +$(call Set,Tmp.ObjPath,$(ProjObjRoot)/$(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch)) +$(call Set,Tmp.Functions,$(strip \ + $(call GetCNAVar,FUNCTIONS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.Optimized,$(strip \ + $(call GetCNAVar,OPTIMIZED,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.AR,$(strip \ + $(call GetCNAVar,AR,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.ARFLAGS,$(strip \ + $(call GetCNAVar,ARFLAGS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.RANLIB,$(strip \ + $(call GetCNAVar,RANLIB,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.RANLIBFLAGS,$(strip \ + $(call GetCNAVar,RANLIBFLAGS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) + +# Compute the object inputs for this library. +$(call Set,Tmp.Inputs,\ + $(foreach fn,$(sort $(Tmp.Functions)),\ + $(call Set,Tmp.FnDir,\ + $(call SelectFunctionDir,$(Tmp.Config),$(Tmp.Arch),$(fn),$(Tmp.Optimized)))\ + $(Tmp.ObjPath)/$(Tmp.FnDir)/$(fn).o)) +$(Tmp.ObjPath)/libcompiler_rt.a: $(Tmp.Inputs) $(Tmp.ObjPath)/.dir + $(Summary) " ARCHIVE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$@" + -$(Verb) $(RM) $$@ + $(Verb) $(Tmp.AR) $(Tmp.ARFLAGS) $$@ $(Tmp.Inputs) + $(Verb) $(Tmp.RANLIB) $(Tmp.RANLIBFLAGS) $$@ +.PRECIOUS: $(Tmp.ObjPath)/.dir + +# Per-Config-Arch Targets +$(Tmp.Name)-$(Tmp.Config)-$(Tmp.Arch):: $(Tmp.ObjPath)/libcompiler_rt.a +.PHONY: $(Tmp.Name)-$(Tmp.Config)-$(Tmp.Arch) + +# Per-Config-Arch-SubDir Objects +$(foreach key,$(SubDirKeys),\ + $(call PerPlatformConfigArchSubDir_template,$(key))) +endef + +define PerPlatformConfigArchSubDir_template +$(call Set,Tmp.SubDirKey,$(1)) +$(call Set,Tmp.SubDir,$($(Tmp.SubDirKey).Dir)) +$(call Set,Tmp.SrcPath,$(ProjSrcRoot)/$(Tmp.SubDir)) +$(call Set,Tmp.ObjPath,$(ProjObjRoot)/$(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch)/$(Tmp.SubDirKey)) +$(call Set,Tmp.Dependencies,$($(Tmp.SubDirKey).Dependencies)) +$(call Set,Tmp.CC,$(strip \ + $(call GetCNAVar,CC,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.CFLAGS,$(strip \ + $(call GetCNAVar,CFLAGS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch)))) +$(call Set,Tmp.ArchFlag,$(strip \ + $(if $(call IsDefined,$(Tmp.Key).UniversalArchs),-arch $(Tmp.Arch),))) + +$(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.s $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir + $(Summary) " ASSEMBLE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<" + $(Verb) $(Tmp.CC) $(Tmp.ArchFlag) $(Tmp.CFLAGS) -c -o $$@ $$< +$(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.S $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir + $(Summary) " ASSEMBLE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<" + $(Verb) $(Tmp.CC) $(Tmp.ArchFlag) $(Tmp.CFLAGS) -c -o $$@ $$< +$(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.c $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir + $(Summary) " COMPILE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<" + $(Verb) $(Tmp.CC) $(Tmp.ArchFlag) $(Tmp.CFLAGS) -c -o $$@ $$< +.PRECIOUS: $(Tmp.ObjPath)/.dir + +endef + +# Run templates. +$(foreach key,$(PlatformKeys),\ + $(eval $(call PerPlatform_template,$(key)))) + +### ifneq ($(DEBUGMAKE),) $(info MAKE: Done processing Makefile) Modified: compiler-rt/trunk/make/config.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/config.mk?rev=93720&r1=93719&r2=93720&view=diff ============================================================================== --- compiler-rt/trunk/make/config.mk (original) +++ compiler-rt/trunk/make/config.mk Mon Jan 18 00:49:33 2010 @@ -11,16 +11,9 @@ ### # Tool configuration variables. -CC := gcc # FIXME: LLVM uses autoconf/mkinstalldirs ? MKDIR := mkdir -p DATE := date -AR := ar -# FIXME: Remove these pipes once ranlib errors are fixed. -AR.Flags := cru 2> /dev/null -RANLIB := ranlib -# FIXME: Remove these pipes once ranlib errors are fixed. -RANLIB.Flags := 2> /dev/null LIPO := lipo CP := cp @@ -38,9 +31,6 @@ endif Echo := @echo -Archive := $(AR) $(AR.Flags) -Ranlib := $(RANLIB) $(RANLIB.Flags) -Lipo := $(LIPO) ifndef Summary - Summary = $(Echo) + Summary = $(Echo) endif Modified: compiler-rt/trunk/make/lib_info.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_info.mk?rev=93720&r1=93719&r2=93720&view=diff ============================================================================== --- compiler-rt/trunk/make/lib_info.mk (original) +++ compiler-rt/trunk/make/lib_info.mk Mon Jan 18 00:49:33 2010 @@ -42,3 +42,8 @@ $(foreach key,$(SubDirKeys),\ $(foreach fn,$(basename $($(key).ObjNames)),\ $(call Append,AvailableIn.$(fn),$(key)))) + +# The names of all the available options. +AvailableOptions := AR ARFLAGS \ + CC CFLAGS FUNCTIONS OPTIMIZED \ + RANLIB RANLIBFLAGS Added: compiler-rt/trunk/make/lib_platforms.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_platforms.mk?rev=93720&view=auto ============================================================================== --- compiler-rt/trunk/make/lib_platforms.mk (added) +++ compiler-rt/trunk/make/lib_platforms.mk Mon Jan 18 00:49:33 2010 @@ -0,0 +1,82 @@ +# compiler-rt Configuration Support +# +# This should be included following 'lib_util.mk'. + +# The simple variables configurations can define. +PlainConfigVariables := Configs UniversalArchs Description +PerConfigVariables := Arch $(AvailableOptions) +RequiredConfigVariables := Configs Description + +### +# Load Platforms + +# Template: subdir_traverse_template subdir +define load_platform_template +$(call Set,PlatformName,$(basename $(notdir $(1)))) +ifneq ($(DEBUGMAKE),) + $$(info MAKE: $(PlatformName): Loading platform) +endif + +# Construct the variable key for this directory. +$(call Set,PlatformKey,Platform.$(PlatformName)) +$(call Append,PlatformKeys,$(PlatformKey)) +$(call Set,$(PlatformKey).Name,$(PlatformName)) +$(call Set,$(PlatformKey).Path,$(1)) + +# Reset platform specific variables to sentinel value. +$$(foreach var,$(PlainConfigVariables) $(PerConfigVariables),\ + $$(call Set,$$(var),UNDEFINED)) +$$(foreach var,$(PerConfigVariables),\ + $$(foreach config,$$(Configs),\ + $$(call Set,$$(var).$$(config),UNDEFINED))) +$$(foreach var,$(PerConfigVariables),\ + $$(foreach arch,$(AvailableArchs),\ + $$(call Set,$$(var).$$(arch),UNDEFINED))) + +# Get the platform variables. +include make/options.mk +include $(1) + +# Check for undefined required variables. +$$(foreach var,$(RequiredConfigVariables),\ + $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \ + $$(error $(Dir): variable '$$(var)' was not undefined))) + +# Check that exactly one of UniversalArchs or Arch was defined. +$$(if $$(and $$(call strneq,UNDEFINED,$$(UniversalArchs)),\ + $$(call strneq,UNDEFINED,$$(Arch))),\ + $$(error '$(1)': cannot define both 'UniversalArchs' and 'Arch')) +$$(if $$(or $$(call strneq,UNDEFINED,$$(UniversalArchs)),\ + $$(call strneq,UNDEFINED,$$(Arch))),,\ + $$(error '$(1)': must define one of 'UniversalArchs' and 'Arch')) + +# Collect all the platform variables for subsequent use. +$$(foreach var,$(PlainConfigVariables) $(PerConfigVariables),\ + $$(if $$(call strneq,UNDEFINED,$$($$(var))),\ + $$(call CopyVariable,$$(var),$(PlatformKey).$$(var)))) +$$(foreach var,$(PerConfigVariables),\ + $$(foreach config,$$(Configs),\ + $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(config))),\ + $$(call CopyVariable,$$(var).$$(config),$(PlatformKey).$$(var).$$(config))))\ + $$(foreach arch,$(AvailableArchs),\ + $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(arch))),\ + $$(call CopyVariable,$$(var).$$(arch),$(PlatformKey).$$(var).$$(arch))))\ + $$(foreach config,$$(Configs),\ + $$(foreach arch,$(AvailableArchs),\ + $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(config).$$(arch))),\ + $$(call CopyVariable,$$(var).$$(config).$$(arch),\ + $(PlatformKey).$$(var).$$(config).$$(arch)))))) + +ifneq ($(DEBUGMAKE),) + $$(info MAKE: $(PlatformName): Done loading platform) +endif +endef + +# Evaluate this now so we do not have to worry about order of evaluation. +PlatformFiles := $(wildcard make/platform/*.mk) +ifneq ($(DEBUGMAKE),) + $(info MAKE: Loading platforms: $(PlatformFiles)) +endif + +$(foreach file,$(PlatformFiles),\ + $(eval $(call load_platform_template,$(file)))) Modified: compiler-rt/trunk/make/lib_util.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_util.mk?rev=93720&r1=93719&r2=93720&view=diff ============================================================================== --- compiler-rt/trunk/make/lib_util.mk (original) +++ compiler-rt/trunk/make/lib_util.mk Mon Jan 18 00:49:33 2010 @@ -2,6 +2,15 @@ # # This should be included following 'lib_info.mk'. +# Function: GetCNAVar variable-name platform-key config arch +# +# Get a per-config-and-arch variable value. +GetCNAVar = $(strip \ + $(or $($(2).$(1).$(3).$(4)), \ + $($(2).$(1).$(3)), \ + $($(2).$(1).$(4)), \ + $($(2).$(1)))) + # Function: SelectFunctionDir config arch function-name optimized # # Choose the appropriate implementation directory to use for 'function-name' in Added: compiler-rt/trunk/make/options.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/options.mk?rev=93720&view=auto ============================================================================== --- compiler-rt/trunk/make/options.mk (added) +++ compiler-rt/trunk/make/options.mk Mon Jan 18 00:49:33 2010 @@ -0,0 +1,25 @@ +# Options which may be overriden for platforms, etc. +# +# This list of such variables should be kept up to date with AvailableOptions in +# 'make/lib_info.mk'. + +# The compiler to use. +CC := gcc + +# The compiler flags to use. +CFLAGS := -Wall -Werror + +# The list of functions to include in the library. +FUNCTIONS := + +# Whether optimized function implementations should be used. +OPTIMIZED := 1 + +# Miscellaneous tools. + +AR := ar +# FIXME: Remove these pipes once ranlib errors are fixed. +ARFLAGS := cru 2> /dev/null +RANLIB := ranlib +# FIXME: Remove these pipes once ranlib errors are fixed. +RANLIBFLAGS := 2> /dev/null Added: compiler-rt/trunk/make/platform/darwin_fat.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/darwin_fat.mk?rev=93720&view=auto ============================================================================== --- compiler-rt/trunk/make/platform/darwin_fat.mk (added) +++ compiler-rt/trunk/make/platform/darwin_fat.mk Mon Jan 18 00:49:33 2010 @@ -0,0 +1,53 @@ +# Configurations to build +# +# This section must define: +# Description - A description of this target. +# Configs - The names of each configuration to build; this is used to build +# multiple libraries inside a single configuration file (for +# example, Debug and Release builds, or builds with and without +# software floating point). +# +# This section must define one of: +# UniveralArchs - A list of architectures to build for, when using universal build +# support (e.g., on Darwin). This should only be used to build fat +# libraries, simply building multiple libraries for different +# architectures should do so using distinct configs, with the +# appropriate choices for CC and CFLAGS. +# +# Arch - The target architecture; this must match the compiler-rt name for the +# architecture and is used to find the appropriate function +# implementations. +# +# When not universal builds, this section may define: +# Arch. - Set the target architecture on a per-config basis. + +Description := Target for building universal libraries for Darwin. + +Configs := Debug Release Profile +UniversalArchs := i386 ppc x86_64 + +# Platform Options +# +# This section may override any of the variables in make/options.mk, using: +#