diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-01-18 06:49:33 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-01-18 06:49:33 +0000 |
commit | 48464e0ee1c2de5bcbf0d609348f55d0c301085d (patch) | |
tree | ba4925beb5fbba97626df7306b3c452ffe52ceae /make | |
parent | ba990c4981acfa55893e809e5c72de2800e6bf0c (diff) | |
download | compiler-rt-48464e0ee1c2de5bcbf0d609348f55d0c301085d.tar.gz compiler-rt-48464e0ee1c2de5bcbf0d609348f55d0c301085d.tar.bz2 compiler-rt-48464e0ee1c2de5bcbf0d609348f55d0c301085d.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@93720 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'make')
-rw-r--r-- | make/config.mk | 12 | ||||
-rw-r--r-- | make/lib_info.mk | 5 | ||||
-rw-r--r-- | make/lib_platforms.mk | 82 | ||||
-rw-r--r-- | make/lib_util.mk | 9 | ||||
-rw-r--r-- | make/options.mk | 25 | ||||
-rw-r--r-- | make/platform/darwin_fat.mk | 53 | ||||
-rw-r--r-- | make/platform/multi_arch.mk | 16 | ||||
-rw-r--r-- | make/subdir.mk | 6 | ||||
-rw-r--r-- | make/test/test-util.mk | 7 | ||||
-rw-r--r-- | make/util.mk | 9 |
10 files changed, 212 insertions, 12 deletions
diff --git a/make/config.mk b/make/config.mk index 5dfc74ca..d96b1b43 100644 --- a/make/config.mk +++ b/make/config.mk @@ -11,16 +11,9 @@ ProjObjRoot := $(ProjSrcRoot) ### # 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 @@ else endif Echo := @echo -Archive := $(AR) $(AR.Flags) -Ranlib := $(RANLIB) $(RANLIB.Flags) -Lipo := $(LIPO) ifndef Summary - Summary = $(Echo) + Summary = $(Echo) endif diff --git a/make/lib_info.mk b/make/lib_info.mk index 1c673f36..91ee23b5 100644 --- a/make/lib_info.mk +++ b/make/lib_info.mk @@ -42,3 +42,8 @@ $(foreach arch,$(AvailableArchs),\ $(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 diff --git a/make/lib_platforms.mk b/make/lib_platforms.mk new file mode 100644 index 00000000..55573747 --- /dev/null +++ b/make/lib_platforms.mk @@ -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)))) diff --git a/make/lib_util.mk b/make/lib_util.mk index 0ff66261..089a0e2e 100644 --- a/make/lib_util.mk +++ b/make/lib_util.mk @@ -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 diff --git a/make/options.mk b/make/options.mk new file mode 100644 index 00000000..392bbdde --- /dev/null +++ b/make/options.mk @@ -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 diff --git a/make/platform/darwin_fat.mk b/make/platform/darwin_fat.mk new file mode 100644 index 00000000..cea2a51f --- /dev/null +++ b/make/platform/darwin_fat.mk @@ -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.<Config Name> - 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: +# <Option Name> := ... option value ... +# +# See make/options.mk for the available options and their meanings. Options can +# be override on a per-config, per-arch, or per-config-and-arch basis using: +# <Option Name>.<Config Name> := ... +# <Option Name>.<Arch Name> := ... +# <Option Name>.<Config Name>.<Arch Name> := ... + +CC := gcc + +CFLAGS := -Wall -Werror +CFLAGS.Debug := $(CFLAGS) -g +CFLAGS.Release := $(CFLAGS) -O3 -fomit-frame-pointer +CFLAGS.Profile := $(CFLAGS) -pg -g + +FUNCTIONS.i386 := $(CommonFunctions) $(ArchFunctions.i386) +FUNCTIONS.ppc := $(CommonFunctions) $(ArchFunctions.ppc) +FUNCTIONS.x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64) +FUNCTIONS.armv6 := $(CommonFunctions) $(ArchFunctions.armv6) +FUNCTIONS.armv7 := $(CommonFunctions) $(ArchFunctions.armv7) + +OPTIMIZED.Debug := 0 diff --git a/make/platform/multi_arch.mk b/make/platform/multi_arch.mk new file mode 100644 index 00000000..c85f3d90 --- /dev/null +++ b/make/platform/multi_arch.mk @@ -0,0 +1,16 @@ +Description := Example configuration for build two libraries for separate \ +architectures. + +Configs := m32 m64 +Arch := i386 +Arch.m64 := x86_64 + +CC := gcc +CC.m32 := clang + +CFLAGS := -Wall -Werror +CFLAGS.m32 := $(CFLAGS) -m32 -O3 +CFLAGS.m64 := $(CFLAGS) -m64 -O3 + +FUNCTIONS := moddi3 floatundixf udivdi3 +FUNCTIONS.m64 := $(FUNCTIONS) lshrdi3
\ No newline at end of file diff --git a/make/subdir.mk b/make/subdir.mk index b0981dcb..900f7e6a 100644 --- a/make/subdir.mk +++ b/make/subdir.mk @@ -74,7 +74,11 @@ endif endef # Evaluate this now so we do not have to worry about order of evaluation. -SubDirsList := $(SubDirs:%=$(Dir)/%) + +SubDirsList := $(strip \ + $(if $(call streq,.,$(Dir)),\ + $(SubDirs),\ + $(SubDirs:%=$(Dir)/%))) ifeq ($(SubDirsList),) else ifneq ($(DEBUGMAKE),) diff --git a/make/test/test-util.mk b/make/test/test-util.mk index 13e702a9..c80c28d0 100644 --- a/make/test/test-util.mk +++ b/make/test/test-util.mk @@ -53,6 +53,13 @@ varordefault_t1_var.opt := 2 varordefault_t1 = $(call VarOrDefault,varordefault_t1_var.opt,$(varordefault_t1_var)) $(call AssertEqual,varordefault_t1,2) +$(call CopyVariable,copyvariable_t0_src,copyvariable_t0_dst) +copyvariable_t0 = $(call IsUndefined,copyvariable_t0_dst) +$(call AssertEqual,copyvariable_t0,true) +copyvariable_t1_src = 1 +$(call CopyVariable,copyvariable_t1_src,copyvariable_t1) +$(call AssertEqual,copyvariable_t1,1) + all: @true .PHONY: all diff --git a/make/util.mk b/make/util.mk index 6764a91c..57ff4dae 100644 --- a/make/util.mk +++ b/make/util.mk @@ -66,6 +66,15 @@ VarOrDefault = $(if $(call IsDefined,$(1)),$($(1)),$(2)) # CHECKVALUE: foo: $(call streq,,) - true CheckValue = $(info CHECKVALUE: $(1): $(value $(1)) - $($(1))) +# Function: CopyVariable src dst +# +# Copy the value of the variable 'src' to 'dst', taking care to not define 'dst' +# if 'src' is undefined. The destination variable must be undefined. +CopyVariable = \ + $(call AssertValue,$(call IsUndefined,$(2)),destination is already defined)\ + $(if $(call IsUndefined,$(1)),,\ + $(call Set,$(2),$($(1)))) + # Function: Assert value message # # Check that a value is true, or give an error including the given message |