diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-01-19 21:12:58 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-01-19 21:12:58 +0000 |
| commit | 3779e1f49ad331c7989a655c1a1dafaf901b21f0 (patch) | |
| tree | 7717440cd0ae9d05dd64fd5affbb69cb2d88c2bc | |
| parent | bdc17f6840d1ca85275dba9c828c4f3ce735a9ff (diff) | |
| download | bcm5719-llvm-3779e1f49ad331c7989a655c1a1dafaf901b21f0.tar.gz bcm5719-llvm-3779e1f49ad331c7989a655c1a1dafaf901b21f0.zip | |
Initial cut at integrating compiler-rt (on Darwin) w/ clang build.
- compiler-rt should be checked out into $LLVM_SRC_ROOT/projects/compiler-rt.
- On Darwin, this will automatically build the runtime libraries clang needs
into $OBJROOT/lib/clang/<version>/darwin/...
- The mechanism can easily support other platforms, and can eventually support
multiple platforms once clang has some kind of configure process (for
specifying the desired targets).
- Feedback on the approach is welcome.
llvm-svn: 93910
| -rwxr-xr-x | clang/lib/Makefile | 4 | ||||
| -rw-r--r-- | clang/lib/Runtime/Makefile | 99 |
2 files changed, 101 insertions, 2 deletions
diff --git a/clang/lib/Makefile b/clang/lib/Makefile index adf9474a2ae..d499ee555a3 100755 --- a/clang/lib/Makefile +++ b/clang/lib/Makefile @@ -8,8 +8,8 @@ ##===----------------------------------------------------------------------===## LEVEL = ../../.. -PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite \ - Frontend Index Driver +PARALLEL_DIRS = Headers Runtime Basic Lex Parse AST Sema CodeGen Analysis \ + Rewrite Frontend Index Driver include $(LEVEL)/Makefile.common diff --git a/clang/lib/Runtime/Makefile b/clang/lib/Runtime/Makefile new file mode 100644 index 00000000000..a8a64138903 --- /dev/null +++ b/clang/lib/Runtime/Makefile @@ -0,0 +1,99 @@ +##===- clang/lib/Runtime/Makefile --------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +# +# This file defines support for building the Clang runtime libraries (which are +# implemented by compiler-rt) and placing them in the proper locations in the +# Clang resources directory (i.e., where the driver expects them). +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../../.. +include $(LEVEL)/Makefile.common + +CLANG_VERSION := $(shell cat $(PROJ_SRC_DIR)/../../VER) +ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION) +PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION) + +ResourceLibDir := $(ResourceDir)/lib +PROJ_resources_lib := $(PROJ_resources)/lib + +# Expect compiler-rt to be in llvm/projects/compiler-rt +COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt + +ifeq ($(shell test -d $(COMPILERRT_SRC_ROOT) && echo OK),OK) + +# Select the compiler-rt configuration to use, and install directory. +# +# FIXME: Eventually, we want some kind of configure support for this. We want to +# build/install runtime libraries for as many targets as clang was configured to +# support. +RuntimeDirs := +ifeq ($(OS),Darwin) +RuntimeDirs += darwin +RuntimeLibrary.darwin.Configs = x86_10.4 armv6 +endif + +endif + +# Rule to build the compiler-rt libraries we need. +# +# We build all the libraries in a single shot to avoid recursive make as much as +# possible. +BuildRuntimeLibraries: + $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \ + ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \ + ProjObjRoot=$(PROJ_OBJ_DIR) \ + $(RuntimeDirs:%=clang_%) +.PHONY: BuildRuntimeLibraries +CleanRuntimeLibraries: + $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \ + ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \ + ProjObjRoot=$(PROJ_OBJ_DIR) \ + clean +.PHONY: CleanRuntimeLibraries + +$(PROJ_resources_lib): + $(Verb) $(MKDIR) $@ + +# Expand rules for copying/installing each individual library. We can't use +# implicit rules here because we need to match against multiple things. +define RuntimeLibraryTemplate +$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a: BuildRuntimeLibraries + @true +.PRECIOUS: $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a + +# Rule to copy the libraries to their resource directory location. +$(ResourceLibDir)/$1/libclang_rt.%.a: \ + $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a \ + $(ResourceLibDir)/$1/.dir + $(Echo) Copying runtime library $1/$$* to build dir + $(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.a $$@ +RuntimeLibrary.$1: \ + $(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%.a) +.PHONY: RuntimeLibrary.$1 + +$(PROJ_resources_lib)/$1: $(PROJ_resources_lib) + $(Verb) $(MKDIR) $$@ + +$(PROJ_resources_lib)/$1/libclang_rt.%.a: \ + $(ResourceLibDir)/$1/libclang_rt.%.a | $(PROJ_resources_lib)/$1 + $(Echo) Installing compiler runtime library: $1/$$* + $(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1 + +# Rule to install runtime libraries. +RuntimeLibraryInstall.$1: \ + $(RuntimeLibrary.$1.Configs:%=$(PROJ_resources_lib)/$1/libclang_rt.%.a) +.PHONY: RuntimeLibraryInstall.$1 +endef +$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib)))) + +# Hook into the standard Makefile rules. +all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) +install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) +clean-local:: CleanRuntimeLibraries |

