head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.7
	netbsd-11-0-RC3:1.1.1.7
	netbsd-11-0-RC2:1.1.1.7
	netbsd-11-0-RC1:1.1.1.7
	perseant-exfatfs-base-20250801:1.1.1.7
	netbsd-11:1.1.1.7.0.22
	netbsd-11-base:1.1.1.7
	netbsd-10-1-RELEASE:1.1.1.7
	perseant-exfatfs-base-20240630:1.1.1.7
	perseant-exfatfs:1.1.1.7.0.20
	perseant-exfatfs-base:1.1.1.7
	netbsd-8-3-RELEASE:1.1.1.7
	netbsd-9-4-RELEASE:1.1.1.7
	netbsd-10-0-RELEASE:1.1.1.7
	netbsd-10-0-RC6:1.1.1.7
	netbsd-10-0-RC5:1.1.1.7
	netbsd-10-0-RC4:1.1.1.7
	netbsd-10-0-RC3:1.1.1.7
	netbsd-10-0-RC2:1.1.1.7
	netbsd-10-0-RC1:1.1.1.7
	netbsd-10:1.1.1.7.0.18
	netbsd-10-base:1.1.1.7
	netbsd-9-3-RELEASE:1.1.1.7
	cjep_sun2x:1.1.1.7.0.16
	cjep_sun2x-base:1.1.1.7
	cjep_staticlib_x-base1:1.1.1.7
	netbsd-9-2-RELEASE:1.1.1.7
	cjep_staticlib_x:1.1.1.7.0.14
	cjep_staticlib_x-base:1.1.1.7
	netbsd-9-1-RELEASE:1.1.1.7
	phil-wifi-20200421:1.1.1.7
	phil-wifi-20200411:1.1.1.7
	phil-wifi-20200406:1.1.1.7
	netbsd-8-2-RELEASE:1.1.1.7
	netbsd-9-0-RELEASE:1.1.1.7
	netbsd-9-0-RC2:1.1.1.7
	netbsd-9-0-RC1:1.1.1.7
	netbsd-9:1.1.1.7.0.12
	netbsd-9-base:1.1.1.7
	netbsd-8-1-RELEASE:1.1.1.7
	netbsd-8-1-RC1:1.1.1.7
	pgoyette-compat-merge-20190127:1.1.1.7
	pgoyette-compat-20190127:1.1.1.7
	pgoyette-compat-20190118:1.1.1.7
	pgoyette-compat-1226:1.1.1.7
	pgoyette-compat-1126:1.1.1.7
	pgoyette-compat-1020:1.1.1.7
	pgoyette-compat-0930:1.1.1.7
	pgoyette-compat-0906:1.1.1.7
	netbsd-7-2-RELEASE:1.1.1.4.2.1
	pgoyette-compat-0728:1.1.1.7
	netbsd-8-0-RELEASE:1.1.1.7
	pgoyette-compat-0625:1.1.1.7
	netbsd-8-0-RC2:1.1.1.7
	pgoyette-compat-0521:1.1.1.7
	pgoyette-compat-0502:1.1.1.7
	pgoyette-compat-0422:1.1.1.7
	netbsd-8-0-RC1:1.1.1.7
	pgoyette-compat-0415:1.1.1.7
	pgoyette-compat-0407:1.1.1.7
	pgoyette-compat-0330:1.1.1.7
	pgoyette-compat-0322:1.1.1.7
	pgoyette-compat-0315:1.1.1.7
	netbsd-7-1-2-RELEASE:1.1.1.4.2.1
	pgoyette-compat:1.1.1.7.0.10
	pgoyette-compat-base:1.1.1.7
	netbsd-7-1-1-RELEASE:1.1.1.4.2.1
	perseant-stdc-iso10646:1.1.1.7.0.8
	perseant-stdc-iso10646-base:1.1.1.7
	netbsd-8:1.1.1.7.0.6
	netbsd-8-base:1.1.1.7
	prg-localcount2-base3:1.1.1.7
	prg-localcount2-base2:1.1.1.7
	prg-localcount2-base1:1.1.1.7
	prg-localcount2:1.1.1.7.0.4
	prg-localcount2-base:1.1.1.7
	pgoyette-localcount-20170426:1.1.1.7
	bouyer-socketcan-base1:1.1.1.7
	pgoyette-localcount-20170320:1.1.1.7
	netbsd-7-1:1.1.1.4.2.1.0.6
	netbsd-7-1-RELEASE:1.1.1.4.2.1
	netbsd-7-1-RC2:1.1.1.4.2.1
	netbsd-7-nhusb-base-20170116:1.1.1.4.2.1
	bouyer-socketcan:1.1.1.7.0.2
	bouyer-socketcan-base:1.1.1.7
	pgoyette-localcount-20170107:1.1.1.6
	netbsd-7-1-RC1:1.1.1.4.2.1
	pgoyette-localcount-20161104:1.1.1.6
	netbsd-7-0-2-RELEASE:1.1.1.4.2.1
	localcount-20160914:1.1.1.6
	netbsd-7-nhusb:1.1.1.4.2.1.0.4
	netbsd-7-nhusb-base:1.1.1.4.2.1
	clang-280599:1.1.1.6
	pgoyette-localcount-20160806:1.1.1.6
	pgoyette-localcount-20160726:1.1.1.6
	pgoyette-localcount:1.1.1.6.0.2
	pgoyette-localcount-base:1.1.1.6
	netbsd-7-0-1-RELEASE:1.1.1.4.2.1
	clang-261930:1.1.1.6
	netbsd-7-0:1.1.1.4.2.1.0.2
	netbsd-7-0-RELEASE:1.1.1.4.2.1
	netbsd-7-0-RC3:1.1.1.4.2.1
	netbsd-7-0-RC2:1.1.1.4.2.1
	netbsd-7-0-RC1:1.1.1.4.2.1
	clang-237755:1.1.1.5
	clang-232565:1.1.1.5
	clang-227398:1.1.1.5
	tls-maxphys-base:1.1.1.4
	tls-maxphys:1.1.1.4.0.4
	netbsd-7:1.1.1.4.0.2
	netbsd-7-base:1.1.1.4
	clang-215315:1.1.1.4
	clang-209886:1.1.1.4
	yamt-pagecache:1.1.1.3.0.4
	yamt-pagecache-base9:1.1.1.3
	tls-earlyentropy:1.1.1.3.0.2
	tls-earlyentropy-base:1.1.1.4
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.3
	riastradh-drm2-base3:1.1.1.3
	clang-202566:1.1.1.3
	clang-201163:1.1.1.3
	clang-199312:1.1.1.2
	clang-198450:1.1.1.2
	clang-196603:1.1.1.1
	clang-195771:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2013.11.28.14.14.58;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	ow8OybrawrB1f3fx;

1.1.1.1
date	2013.11.28.14.14.58;	author joerg;	state Exp;
branches;
next	1.1.1.2;
commitid	ow8OybrawrB1f3fx;

1.1.1.2
date	2014.01.05.15.37.19;	author joerg;	state Exp;
branches;
next	1.1.1.3;
commitid	wh3aCSIWykURqWjx;

1.1.1.3
date	2014.02.14.20.07.42;	author joerg;	state Exp;
branches
	1.1.1.3.2.1
	1.1.1.3.4.1;
next	1.1.1.4;
commitid	annVkZ1sc17rF6px;

1.1.1.4
date	2014.05.30.18.14.45;	author joerg;	state Exp;
branches
	1.1.1.4.2.1
	1.1.1.4.4.1;
next	1.1.1.5;
commitid	8q0kdlBlCn09GACx;

1.1.1.5
date	2015.01.29.19.57.40;	author joerg;	state Exp;
branches;
next	1.1.1.6;
commitid	mlISSizlPKvepX7y;

1.1.1.6
date	2016.02.27.22.10.25;	author joerg;	state Exp;
branches
	1.1.1.6.2.1;
next	1.1.1.7;
commitid	tIimz3oDlh1NpBWy;

1.1.1.7
date	2017.01.11.11.09.35;	author joerg;	state dead;
branches;
next	;
commitid	CSMYjjVVkEUAzxBz;

1.1.1.3.2.1
date	2014.08.10.07.08.10;	author tls;	state Exp;
branches;
next	;
commitid	t01A1TLTYxkpGMLx;

1.1.1.3.4.1
date	2014.02.14.20.07.42;	author yamt;	state dead;
branches;
next	1.1.1.3.4.2;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.3.4.2
date	2014.05.22.16.18.31;	author yamt;	state Exp;
branches;
next	;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.4.2.1
date	2015.06.04.20.04.31;	author snj;	state Exp;
branches;
next	;
commitid	yRnjq9fueSo6n9oy;

1.1.1.4.4.1
date	2014.05.30.18.14.45;	author tls;	state dead;
branches;
next	1.1.1.4.4.2;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.4.4.2
date	2014.08.19.23.47.32;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.6.2.1
date	2017.03.20.06.52.43;	author pgoyette;	state dead;
branches;
next	;
commitid	jjw7cAwgyKq7RfKz;


desc
@@


1.1
log
@Initial revision
@
text
@##===- clang/runtime/compiler-rt/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).
#
##===----------------------------------------------------------------------===##

CLANG_LEVEL := ../..
include $(CLANG_LEVEL)/Makefile

CLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \
	$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc))

ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)
PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)

ResourceLibDir := $(ResourceDir)/lib
ResourceIncludeDir := $(ResourceDir)/include
PROJ_resources_lib := $(PROJ_resources)/lib
PROJ_resources_include := $(PROJ_resources)/include

# Initialize a variable to use for extra flags to pass to the
# compiler-rt make process.
COMPILERRT_MAKE_FLAGS :=

# Expect compiler-rt to be in llvm/projects/compiler-rt
COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt

# We don't currently support building runtime libraries when we are
# cross-compiling. The issue is that we really want to be set up so that the
# available compiler targets are independent of the current build.
#
# Since we have to build the runtime libraries for the target, it requires we
# have a cross compiler from the build machine to the target. Although in the
# case where for the current build (host == target), we do have such a cross
# compiler, but not defined in a way that is easy for us to reuse. Regardless,
# that also wouldn't help for other possible compiler configurations.
#
# Thus, the simple set up we currently use is to assume that we will be using
# the just built Clang to compile the compiler-rt libraries. As we grow better
# cross compilation support inside Clang and tool support in LLVM, this makes it
# easier for us to achieve the goal of having the compiler targets be easily
# selected at configure time. However, this design does currently preclude the
# building of compiler-rt libraries when the Clang itself is being cross
# compiled.
#
# There are three possible solutions:
#  1. Require building a build-target version of Clang when cross compiling. This
#     is simplest, but als greatly increases the build time of cross builds.
#
#  2. Require cross builds have a build-target version of Clang available for
#     use. This is a reasonable compromise on #1, as the compiler-rt libraries
#     are simple enough that there is not a strong desire to ensure they are
#     built with the exact version of Clang being used. Similarly, as Clang
#     becomes a better cross compiler it is also increasingly more likely that
#     the cross compiler being used will already be a version of Clang.
#
#  3. Come up with an alternate mechanism to define all the toolchain
#     information that compiler-rt would need to build libraries for all the
#     requested targets. This might be a simple short term solution, but is
#     likely to be unwieldly and irritating to maintain in the long term.
ifneq ($(LLVM_CROSS_COMPILING),1)
ifneq ($(CLANG_NO_RUNTIME),1)
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 darwin_embedded
RuntimeLibrary.darwin.Configs := \
	eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \
	asan_osx_dynamic.dylib \
	profile_osx.a profile_ios.a \
	ubsan_osx.a
RuntimeLibrary.darwin_embedded.Configs := \
	soft_static.a hard_static.a soft_pic.a hard_pic.a

# Support building compiler-rt with relocatable SDKs.
#
# This will cause make to put SDKROOT in the environment, and since we
# are using the built Clang to build compiler-rt, it to pick up that
# location as the default value for the include system root.
ACTIVE_SDK_PATH := $(shell xcrun --show-sdk-path 2> /dev/null)
ifneq ($(ACTIVE_SDK_PATH),)
COMPILERRT_MAKE_FLAGS := SDKROOT=$(ACTIVE_SDK_PATH)
endif
IOSSIM_SDK_PATH := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)
ifneq ($(IOSSIM_SDK_PATH),)
RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib
endif

endif

# On Linux, include a library which has all the runtime functions.
ifeq ($(OS),Linux)
RuntimeDirs += linux
RuntimeLibrary.linux.Configs :=

# TryCompile compiler source flags
# Returns exit code of running a compiler invocation.
TryCompile = \
  $(shell \
    cflags=""; \
    for flag in $(3); do \
      cflags="$$cflags $$flag"; \
    done; \
    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
    echo $$?)

# We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
Runtime32BitConfigs = \
	full-i386.a profile-i386.a san-i386.a asan-i386.a ubsan-i386.a \
	ubsan_cxx-i386.a

# We currently only try to generate runtime libraries on x86.
ifeq ($(ARCH),x86)
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
endif

ifeq ($(ARCH),x86_64)
RuntimeLibrary.linux.Configs += \
	full-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
	tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a ubsan_cxx-x86_64.a \
	dfsan-x86_64.a lsan-x86_64.a
# We need to build 32-bit ASan/UBsan libraries on 64-bit platform, and add them
# to the list of runtime libraries to make
# "clang -fsanitize=(address|undefined) -m32" work.
# We check that Clang can produce working 32-bit binaries by compiling a simple
# executable.
test_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
endif
ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
RuntimeLibrary.linux.Configs += asan-arm-android.so
endif
endif

endif

####
# The build rules below are designed to be generic and should only need to be
# modified based on changes in the compiler-rt layout or build system.
####

# 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) \
	  CC="$(ToolDir)/clang" \
	  LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
	  $(COMPILERRT_MAKE_FLAGS) \
	  $(RuntimeDirs:%=clang_%)
.PHONY: BuildRuntimeLibraries
CleanRuntimeLibraries:
	$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
	  ProjObjRoot=$(PROJ_OBJ_DIR) \
	  $(COMPILERRT_MAKE_FLAGS) \
	  clean
.PHONY: CleanRuntimeLibraries
RuntimeHeader: $(ResourceIncludeDir)/sanitizer

$(PROJ_resources_lib):
	$(Verb) $(MKDIR) $@@

$(ResourceIncludeDir):
	$(Verb) $(MKDIR) $@@

$(ResourceIncludeDir)/sanitizer: $(ResourceIncludeDir)
	$(Verb) $(MKDIR) $@@
	$(Verb) cp $(COMPILERRT_SRC_ROOT)/include/sanitizer/*.h $@@

# 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
$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so: BuildRuntimeLibraries
	@@true
$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib: 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 $$@@
$(ResourceLibDir)/$1/libclang_rt.%.so: \
		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so \
		$(ResourceLibDir)/$1/.dir
	$(Echo) Copying runtime library $1/$$* to build dir
	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.so $$@@
$(ResourceLibDir)/$1/libclang_rt.%.dylib: \
		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib \
		$(ResourceLibDir)/$1/.dir
	$(Echo) Copying runtime library $1/$$* to build dir
	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.dylib $$@@
	$(Echo) Fixing LC_ID_DYLIB of $$@@
	$(Verb) install_name_tool $$@@ -id $$@@
RuntimeLibrary.$1: \
		$(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%)
.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
$(PROJ_resources_lib)/$1/libclang_rt.%.so: \
		$(ResourceLibDir)/$1/libclang_rt.%.so | $(PROJ_resources_lib)/$1
	$(Echo) Installing compiler runtime library: $1/$$*
	$(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1
$(PROJ_resources_lib)/$1/libclang_rt.%.dylib: \
		$(ResourceLibDir)/$1/libclang_rt.%.dylib | $(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.%)
.PHONY: RuntimeLibraryInstall.$1
endef
$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib))))

$(PROJ_resources_include):
	$(Verb) $(MKDIR) $@@

$(PROJ_resources_include)/sanitizer: $(ResourceIncludeDir)/sanitizer $(PROJ_resources_include)
	$(Verb) $(MKDIR) $@@
	$(Echo) Installing compiler runtime headers
	$(Verb) $(DataInstall) $(ResourceIncludeDir)/sanitizer/* \
                               $(PROJ_resources_include)/sanitizer

RuntimeHeaderInstall: $(PROJ_resources_include)/sanitizer
.PHONY: RuntimeHeaderInstall

# Hook into the standard Makefile rules.
all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) RuntimeHeader
install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) RuntimeHeaderInstall
clean-local:: CleanRuntimeLibraries

endif
endif
endif
@


1.1.1.1
log
@Import Clang 3.4rc1 r195771.
@
text
@@


1.1.1.2
log
@Import clang 3.5svn r198450.
@
text
@d69 1
a69 1
#     likely to be unwieldy and irritating to maintain in the long term.
a86 1

d88 1
a88 5
	hard_static.a hard_pic.a
ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
RuntimeLibrary.darwin_embedded.Configs += \
	soft_static.a soft_pic.a
endif
@


1.1.1.3
log
@Import Clang 3.5svn r201163.
@
text
@d81 1
a81 1
RuntimeDirs += darwin macho_embedded
d88 1
a88 1
RuntimeLibrary.macho_embedded.Configs := \
d91 1
a91 1
RuntimeLibrary.macho_embedded.Configs += \
@


1.1.1.3.2.1
log
@Rebase.
@
text
@d129 2
a130 2
	builtins-i386.a profile-i386.a san-i386.a asan-i386.a asan_cxx-i386.a \
	ubsan-i386.a ubsan_cxx-i386.a
d139 3
a141 3
	builtins-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
	asan_cxx-x86_64.a tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a \
	ubsan_cxx-x86_64.a dfsan-x86_64.a lsan-x86_64.a
a171 1
	  VERBOSE=$(VERBOSE) \
a179 1
	  VERBOSE=$(VERBOSE) \
@


1.1.1.4
log
@Import Clang 3.5svn r209886.
@
text
@d129 2
a130 2
	builtins-i386.a profile-i386.a san-i386.a asan-i386.a asan_cxx-i386.a \
	ubsan-i386.a ubsan_cxx-i386.a
d139 3
a141 3
	builtins-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
	asan_cxx-x86_64.a tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a \
	ubsan_cxx-x86_64.a dfsan-x86_64.a lsan-x86_64.a
a171 1
	  VERBOSE=$(VERBOSE) \
a179 1
	  VERBOSE=$(VERBOSE) \
@


1.1.1.4.2.1
log
@Update LLVM to 3.6.1, requested by joerg in ticket 824.
@
text
@d30 4
d83 1
a83 1
	eprintf.a 10.4.a osx.a cc_kext.a \
d85 1
a85 1
	profile_osx.a \
d88 5
a92 5
IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2> /dev/null)
IOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)

ifneq ($(IOS_SDK)$(IOSSIM_SDK),)
RuntimeLibrary.darwin.Configs += ios.a profile_ios.a
d95 8
a102 2
ifneq ($(IOS_SDK),)
RuntimeLibrary.darwin.Configs += cc_kext_ios5.a
d104 2
a105 2

ifneq ($(IOSSIM_SDK),)
a108 6
RuntimeLibrary.macho_embedded.Configs := \
	hard_static.a hard_pic.a
ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
RuntimeLibrary.macho_embedded.Configs += \
	soft_static.a soft_pic.a
endif
d174 1
d182 1
d224 2
@


1.1.1.5
log
@Import Clang 3.6RC1 r227398.
@
text
@d30 4
d83 1
a83 1
	eprintf.a 10.4.a osx.a cc_kext.a \
d85 1
a85 1
	profile_osx.a \
d88 5
a92 5
IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2> /dev/null)
IOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)

ifneq ($(IOS_SDK)$(IOSSIM_SDK),)
RuntimeLibrary.darwin.Configs += ios.a profile_ios.a
d95 8
a102 2
ifneq ($(IOS_SDK),)
RuntimeLibrary.darwin.Configs += cc_kext_ios5.a
d104 2
a105 2

ifneq ($(IOSSIM_SDK),)
a108 6
RuntimeLibrary.macho_embedded.Configs := \
	hard_static.a hard_pic.a
ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
RuntimeLibrary.macho_embedded.Configs += \
	soft_static.a soft_pic.a
endif
d174 1
d182 1
d224 2
@


1.1.1.6
log
@Import Clang 3.8.0rc3 r261930.
@
text
@d82 1
a82 1
	ubsan_osx_dynamic.dylib
d92 1
a92 3
ifneq (,$(filter ARM AARCH64,$(TARGETS_TO_BUILD)))
RuntimeLibrary.darwin.Configs += cc_kext_ios.a
endif
d96 1
a96 2
RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib \
                                 ubsan_iossim_dynamic.dylib
d125 2
a126 1
	builtins-i386.a profile-i386.a
d135 6
a140 3
	builtins-x86_64.a profile-x86_64.a
# We need to build 32-bit libraries on 64-bit platform, and add them
# to the list of runtime libraries to make "clang -m32" work.
d147 3
d169 1
@


1.1.1.6.2.1
log
@Sync with HEAD
@
text
@@


1.1.1.7
log
@Mark files not tagged with clang-291444 as dead.
@
text
@@


1.1.1.4.4.1
log
@file Makefile was added on branch tls-maxphys on 2014-08-19 23:47:32 +0000
@
text
@d1 272
@


1.1.1.4.4.2
log
@Rebase to HEAD as of a few days ago.
@
text
@a0 272
##===- clang/runtime/compiler-rt/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).
#
##===----------------------------------------------------------------------===##

CLANG_LEVEL := ../..
include $(CLANG_LEVEL)/Makefile

CLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \
	$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc))

ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)
PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)

ResourceLibDir := $(ResourceDir)/lib
ResourceIncludeDir := $(ResourceDir)/include
PROJ_resources_lib := $(PROJ_resources)/lib
PROJ_resources_include := $(PROJ_resources)/include

# Initialize a variable to use for extra flags to pass to the
# compiler-rt make process.
COMPILERRT_MAKE_FLAGS :=

# Expect compiler-rt to be in llvm/projects/compiler-rt
COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt

# We don't currently support building runtime libraries when we are
# cross-compiling. The issue is that we really want to be set up so that the
# available compiler targets are independent of the current build.
#
# Since we have to build the runtime libraries for the target, it requires we
# have a cross compiler from the build machine to the target. Although in the
# case where for the current build (host == target), we do have such a cross
# compiler, but not defined in a way that is easy for us to reuse. Regardless,
# that also wouldn't help for other possible compiler configurations.
#
# Thus, the simple set up we currently use is to assume that we will be using
# the just built Clang to compile the compiler-rt libraries. As we grow better
# cross compilation support inside Clang and tool support in LLVM, this makes it
# easier for us to achieve the goal of having the compiler targets be easily
# selected at configure time. However, this design does currently preclude the
# building of compiler-rt libraries when the Clang itself is being cross
# compiled.
#
# There are three possible solutions:
#  1. Require building a build-target version of Clang when cross compiling. This
#     is simplest, but als greatly increases the build time of cross builds.
#
#  2. Require cross builds have a build-target version of Clang available for
#     use. This is a reasonable compromise on #1, as the compiler-rt libraries
#     are simple enough that there is not a strong desire to ensure they are
#     built with the exact version of Clang being used. Similarly, as Clang
#     becomes a better cross compiler it is also increasingly more likely that
#     the cross compiler being used will already be a version of Clang.
#
#  3. Come up with an alternate mechanism to define all the toolchain
#     information that compiler-rt would need to build libraries for all the
#     requested targets. This might be a simple short term solution, but is
#     likely to be unwieldy and irritating to maintain in the long term.
ifneq ($(LLVM_CROSS_COMPILING),1)
ifneq ($(CLANG_NO_RUNTIME),1)
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 macho_embedded
RuntimeLibrary.darwin.Configs := \
	eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \
	asan_osx_dynamic.dylib \
	profile_osx.a profile_ios.a \
	ubsan_osx.a

RuntimeLibrary.macho_embedded.Configs := \
	hard_static.a hard_pic.a
ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
RuntimeLibrary.macho_embedded.Configs += \
	soft_static.a soft_pic.a
endif

# Support building compiler-rt with relocatable SDKs.
#
# This will cause make to put SDKROOT in the environment, and since we
# are using the built Clang to build compiler-rt, it to pick up that
# location as the default value for the include system root.
ACTIVE_SDK_PATH := $(shell xcrun --show-sdk-path 2> /dev/null)
ifneq ($(ACTIVE_SDK_PATH),)
COMPILERRT_MAKE_FLAGS := SDKROOT=$(ACTIVE_SDK_PATH)
endif
IOSSIM_SDK_PATH := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)
ifneq ($(IOSSIM_SDK_PATH),)
RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib
endif

endif

# On Linux, include a library which has all the runtime functions.
ifeq ($(OS),Linux)
RuntimeDirs += linux
RuntimeLibrary.linux.Configs :=

# TryCompile compiler source flags
# Returns exit code of running a compiler invocation.
TryCompile = \
  $(shell \
    cflags=""; \
    for flag in $(3); do \
      cflags="$$cflags $$flag"; \
    done; \
    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
    echo $$?)

# We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
Runtime32BitConfigs = \
	builtins-i386.a profile-i386.a san-i386.a asan-i386.a asan_cxx-i386.a \
	ubsan-i386.a ubsan_cxx-i386.a

# We currently only try to generate runtime libraries on x86.
ifeq ($(ARCH),x86)
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
endif

ifeq ($(ARCH),x86_64)
RuntimeLibrary.linux.Configs += \
	builtins-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
	asan_cxx-x86_64.a tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a \
	ubsan_cxx-x86_64.a dfsan-x86_64.a lsan-x86_64.a
# We need to build 32-bit ASan/UBsan libraries on 64-bit platform, and add them
# to the list of runtime libraries to make
# "clang -fsanitize=(address|undefined) -m32" work.
# We check that Clang can produce working 32-bit binaries by compiling a simple
# executable.
test_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
endif
ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
RuntimeLibrary.linux.Configs += asan-arm-android.so
endif
endif

endif

####
# The build rules below are designed to be generic and should only need to be
# modified based on changes in the compiler-rt layout or build system.
####

# 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) \
	  CC="$(ToolDir)/clang" \
	  VERBOSE=$(VERBOSE) \
	  LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
	  $(COMPILERRT_MAKE_FLAGS) \
	  $(RuntimeDirs:%=clang_%)
.PHONY: BuildRuntimeLibraries
CleanRuntimeLibraries:
	$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
	  ProjObjRoot=$(PROJ_OBJ_DIR) \
	  VERBOSE=$(VERBOSE) \
	  $(COMPILERRT_MAKE_FLAGS) \
	  clean
.PHONY: CleanRuntimeLibraries
RuntimeHeader: $(ResourceIncludeDir)/sanitizer

$(PROJ_resources_lib):
	$(Verb) $(MKDIR) $@@

$(ResourceIncludeDir):
	$(Verb) $(MKDIR) $@@

$(ResourceIncludeDir)/sanitizer: $(ResourceIncludeDir)
	$(Verb) $(MKDIR) $@@
	$(Verb) cp $(COMPILERRT_SRC_ROOT)/include/sanitizer/*.h $@@

# 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
$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so: BuildRuntimeLibraries
	@@true
$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib: 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 $$@@
$(ResourceLibDir)/$1/libclang_rt.%.so: \
		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so \
		$(ResourceLibDir)/$1/.dir
	$(Echo) Copying runtime library $1/$$* to build dir
	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.so $$@@
$(ResourceLibDir)/$1/libclang_rt.%.dylib: \
		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib \
		$(ResourceLibDir)/$1/.dir
	$(Echo) Copying runtime library $1/$$* to build dir
	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.dylib $$@@
	$(Echo) Fixing LC_ID_DYLIB of $$@@
	$(Verb) install_name_tool $$@@ -id $$@@
RuntimeLibrary.$1: \
		$(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%)
.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
$(PROJ_resources_lib)/$1/libclang_rt.%.so: \
		$(ResourceLibDir)/$1/libclang_rt.%.so | $(PROJ_resources_lib)/$1
	$(Echo) Installing compiler runtime library: $1/$$*
	$(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1
$(PROJ_resources_lib)/$1/libclang_rt.%.dylib: \
		$(ResourceLibDir)/$1/libclang_rt.%.dylib | $(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.%)
.PHONY: RuntimeLibraryInstall.$1
endef
$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib))))

$(PROJ_resources_include):
	$(Verb) $(MKDIR) $@@

$(PROJ_resources_include)/sanitizer: $(ResourceIncludeDir)/sanitizer $(PROJ_resources_include)
	$(Verb) $(MKDIR) $@@
	$(Echo) Installing compiler runtime headers
	$(Verb) $(DataInstall) $(ResourceIncludeDir)/sanitizer/* \
                               $(PROJ_resources_include)/sanitizer

RuntimeHeaderInstall: $(PROJ_resources_include)/sanitizer
.PHONY: RuntimeHeaderInstall

# Hook into the standard Makefile rules.
all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) RuntimeHeader
install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) RuntimeHeaderInstall
clean-local:: CleanRuntimeLibraries

endif
endif
endif
@


1.1.1.3.4.1
log
@file Makefile was added on branch yamt-pagecache on 2014-05-22 16:18:31 +0000
@
text
@d1 270
@


1.1.1.3.4.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 270
##===- clang/runtime/compiler-rt/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).
#
##===----------------------------------------------------------------------===##

CLANG_LEVEL := ../..
include $(CLANG_LEVEL)/Makefile

CLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \
	$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc))

ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)
PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)

ResourceLibDir := $(ResourceDir)/lib
ResourceIncludeDir := $(ResourceDir)/include
PROJ_resources_lib := $(PROJ_resources)/lib
PROJ_resources_include := $(PROJ_resources)/include

# Initialize a variable to use for extra flags to pass to the
# compiler-rt make process.
COMPILERRT_MAKE_FLAGS :=

# Expect compiler-rt to be in llvm/projects/compiler-rt
COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt

# We don't currently support building runtime libraries when we are
# cross-compiling. The issue is that we really want to be set up so that the
# available compiler targets are independent of the current build.
#
# Since we have to build the runtime libraries for the target, it requires we
# have a cross compiler from the build machine to the target. Although in the
# case where for the current build (host == target), we do have such a cross
# compiler, but not defined in a way that is easy for us to reuse. Regardless,
# that also wouldn't help for other possible compiler configurations.
#
# Thus, the simple set up we currently use is to assume that we will be using
# the just built Clang to compile the compiler-rt libraries. As we grow better
# cross compilation support inside Clang and tool support in LLVM, this makes it
# easier for us to achieve the goal of having the compiler targets be easily
# selected at configure time. However, this design does currently preclude the
# building of compiler-rt libraries when the Clang itself is being cross
# compiled.
#
# There are three possible solutions:
#  1. Require building a build-target version of Clang when cross compiling. This
#     is simplest, but als greatly increases the build time of cross builds.
#
#  2. Require cross builds have a build-target version of Clang available for
#     use. This is a reasonable compromise on #1, as the compiler-rt libraries
#     are simple enough that there is not a strong desire to ensure they are
#     built with the exact version of Clang being used. Similarly, as Clang
#     becomes a better cross compiler it is also increasingly more likely that
#     the cross compiler being used will already be a version of Clang.
#
#  3. Come up with an alternate mechanism to define all the toolchain
#     information that compiler-rt would need to build libraries for all the
#     requested targets. This might be a simple short term solution, but is
#     likely to be unwieldy and irritating to maintain in the long term.
ifneq ($(LLVM_CROSS_COMPILING),1)
ifneq ($(CLANG_NO_RUNTIME),1)
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 macho_embedded
RuntimeLibrary.darwin.Configs := \
	eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \
	asan_osx_dynamic.dylib \
	profile_osx.a profile_ios.a \
	ubsan_osx.a

RuntimeLibrary.macho_embedded.Configs := \
	hard_static.a hard_pic.a
ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
RuntimeLibrary.macho_embedded.Configs += \
	soft_static.a soft_pic.a
endif

# Support building compiler-rt with relocatable SDKs.
#
# This will cause make to put SDKROOT in the environment, and since we
# are using the built Clang to build compiler-rt, it to pick up that
# location as the default value for the include system root.
ACTIVE_SDK_PATH := $(shell xcrun --show-sdk-path 2> /dev/null)
ifneq ($(ACTIVE_SDK_PATH),)
COMPILERRT_MAKE_FLAGS := SDKROOT=$(ACTIVE_SDK_PATH)
endif
IOSSIM_SDK_PATH := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)
ifneq ($(IOSSIM_SDK_PATH),)
RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib
endif

endif

# On Linux, include a library which has all the runtime functions.
ifeq ($(OS),Linux)
RuntimeDirs += linux
RuntimeLibrary.linux.Configs :=

# TryCompile compiler source flags
# Returns exit code of running a compiler invocation.
TryCompile = \
  $(shell \
    cflags=""; \
    for flag in $(3); do \
      cflags="$$cflags $$flag"; \
    done; \
    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
    echo $$?)

# We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
Runtime32BitConfigs = \
	full-i386.a profile-i386.a san-i386.a asan-i386.a ubsan-i386.a \
	ubsan_cxx-i386.a

# We currently only try to generate runtime libraries on x86.
ifeq ($(ARCH),x86)
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
endif

ifeq ($(ARCH),x86_64)
RuntimeLibrary.linux.Configs += \
	full-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
	tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a ubsan_cxx-x86_64.a \
	dfsan-x86_64.a lsan-x86_64.a
# We need to build 32-bit ASan/UBsan libraries on 64-bit platform, and add them
# to the list of runtime libraries to make
# "clang -fsanitize=(address|undefined) -m32" work.
# We check that Clang can produce working 32-bit binaries by compiling a simple
# executable.
test_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
endif
ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
RuntimeLibrary.linux.Configs += asan-arm-android.so
endif
endif

endif

####
# The build rules below are designed to be generic and should only need to be
# modified based on changes in the compiler-rt layout or build system.
####

# 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) \
	  CC="$(ToolDir)/clang" \
	  LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
	  $(COMPILERRT_MAKE_FLAGS) \
	  $(RuntimeDirs:%=clang_%)
.PHONY: BuildRuntimeLibraries
CleanRuntimeLibraries:
	$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
	  ProjObjRoot=$(PROJ_OBJ_DIR) \
	  $(COMPILERRT_MAKE_FLAGS) \
	  clean
.PHONY: CleanRuntimeLibraries
RuntimeHeader: $(ResourceIncludeDir)/sanitizer

$(PROJ_resources_lib):
	$(Verb) $(MKDIR) $@@

$(ResourceIncludeDir):
	$(Verb) $(MKDIR) $@@

$(ResourceIncludeDir)/sanitizer: $(ResourceIncludeDir)
	$(Verb) $(MKDIR) $@@
	$(Verb) cp $(COMPILERRT_SRC_ROOT)/include/sanitizer/*.h $@@

# 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
$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so: BuildRuntimeLibraries
	@@true
$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib: 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 $$@@
$(ResourceLibDir)/$1/libclang_rt.%.so: \
		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so \
		$(ResourceLibDir)/$1/.dir
	$(Echo) Copying runtime library $1/$$* to build dir
	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.so $$@@
$(ResourceLibDir)/$1/libclang_rt.%.dylib: \
		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib \
		$(ResourceLibDir)/$1/.dir
	$(Echo) Copying runtime library $1/$$* to build dir
	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.dylib $$@@
	$(Echo) Fixing LC_ID_DYLIB of $$@@
	$(Verb) install_name_tool $$@@ -id $$@@
RuntimeLibrary.$1: \
		$(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%)
.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
$(PROJ_resources_lib)/$1/libclang_rt.%.so: \
		$(ResourceLibDir)/$1/libclang_rt.%.so | $(PROJ_resources_lib)/$1
	$(Echo) Installing compiler runtime library: $1/$$*
	$(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1
$(PROJ_resources_lib)/$1/libclang_rt.%.dylib: \
		$(ResourceLibDir)/$1/libclang_rt.%.dylib | $(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.%)
.PHONY: RuntimeLibraryInstall.$1
endef
$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib))))

$(PROJ_resources_include):
	$(Verb) $(MKDIR) $@@

$(PROJ_resources_include)/sanitizer: $(ResourceIncludeDir)/sanitizer $(PROJ_resources_include)
	$(Verb) $(MKDIR) $@@
	$(Echo) Installing compiler runtime headers
	$(Verb) $(DataInstall) $(ResourceIncludeDir)/sanitizer/* \
                               $(PROJ_resources_include)/sanitizer

RuntimeHeaderInstall: $(PROJ_resources_include)/sanitizer
.PHONY: RuntimeHeaderInstall

# Hook into the standard Makefile rules.
all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) RuntimeHeader
install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) RuntimeHeaderInstall
clean-local:: CleanRuntimeLibraries

endif
endif
endif
@


