Makefile revision 0e7a1cf16c361cd247e31472c253663f6ae32feb
1da79da2a8748e4d58eeedd1b7f39bf4fb8a86d10Bob Wilson##===- clang/runtime/compiler-rt/Makefile ------------------*- Makefile -*-===## 2562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# 3253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar# The LLVM Compiler Infrastructure 4253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar# 5253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar# This file is distributed under the University of Illinois Open Source 6253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar# License. See LICENSE.TXT for details. 7562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# 8562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson##===----------------------------------------------------------------------===## 9562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# 10562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# This file defines support for building the Clang runtime libraries (which are 11562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# implemented by compiler-rt) and placing them in the proper locations in the 12562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Clang resources directory (i.e., where the driver expects them). 13562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# 14253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar##===----------------------------------------------------------------------===## 15253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar 16484fc57c8d2d3ba645a03f9e294dcebc5aacaf44Nick LewyckyCLANG_LEVEL := ../.. 17562627d782393c0d8045625a53a97f4fbad091bcOwen Andersoninclude $(CLANG_LEVEL)/Makefile 18253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar 19562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonCLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \ 20562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc)) 21bc817cffbca01c879f13e9290d94797f6caafc7aDaniel Dunbar 22562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION) 23562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonPROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION) 24562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 25562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonResourceLibDir := $(ResourceDir)/lib 260e7a1cf16c361cd247e31472c253663f6ae32febAlexander PotapenkoResourceIncludeDir := $(ResourceDir)/include 27562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonPROJ_resources_lib := $(PROJ_resources)/lib 280e7a1cf16c361cd247e31472c253663f6ae32febAlexander PotapenkoPROJ_resources_include := $(PROJ_resources)/include 29562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 30562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Expect compiler-rt to be in llvm/projects/compiler-rt 31562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonCOMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt 32562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 33e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# We don't currently support building runtime libraries when we are 34e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# cross-compiling. The issue is that we really want to be set up so that the 35e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# available compiler targets are independent of the current build. 36e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 37e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# Since we have to build the runtime libraries for the target, it requires we 38e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# have a cross compiler from the build machine to the target. Although in the 39e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# case where for the current build (host == target), we do have such a cross 40e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# compiler, but not defined in a way that is easy for us to reuse. Regardless, 41e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# that also wouldn't help for other possible compiler configurations. 42e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 43e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# Thus, the simple set up we currently use is to assume that we will be using 44e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# the just built Clang to compile the compiler-rt libraries. As we grow better 45e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# cross compilation support inside Clang and tool support in LLVM, this makes it 46e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# easier for us to achieve the goal of having the compiler targets be easily 47e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# selected at configure time. However, this design does currently preclude the 48e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# building of compiler-rt libraries when the Clang itself is being cross 49e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# compiled. 50e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 51e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# There are three possible solutions: 52e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 1. Require building a build-target version of Clang when cross compiling. This 53e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# is simplest, but als greatly increases the build time of cross builds. 54e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 55e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 2. Require cross builds have a build-target version of Clang available for 56e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# use. This is a reasonable compromise on #1, as the compiler-rt libraries 57e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# are simple enough that there is not a strong desire to ensure they are 58e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# built with the exact version of Clang being used. Similarly, as Clang 59e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# becomes a better cross compiler it is also increasingly more likely that 60e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# the cross compiler being used will already be a version of Clang. 61e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 62e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# 3. Come up with an alternate mechanism to define all the toolchain 63e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# information that compiler-rt would need to build libraries for all the 64e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# requested targets. This might be a simple short term solution, but is 65e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# likely to be unwieldly and irritating to maintain in the long term. 66e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbarifneq ($(LLVM_CROSS_COMPILING),1) 67562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonifneq ($(CLANG_NO_RUNTIME),1) 68562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonifeq ($(shell test -d $(COMPILERRT_SRC_ROOT) && echo OK),OK) 69562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 70562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Select the compiler-rt configuration to use, and install directory. 71562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# 72562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# FIXME: Eventually, we want some kind of configure support for this. We want to 73562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# build/install runtime libraries for as many targets as clang was configured to 74562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# support. 75562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeDirs := 76562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonifeq ($(OS),Darwin) 77562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeDirs += darwin 78f471487ff1e673531543576bc170898c2ab19f41Daniel DunbarRuntimeLibrary.darwin.Configs := \ 797a0c064770355a4918df69f95de8dea6338a59a2Daniel Dunbar eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \ 80f8d4a6b80d3e0f19c9735fbe0be7bf5f8b21ec18Alexey Samsonov asan_osx_dynamic.dylib \ 8175fcb193aeeec5c4f10cc39df60a5ce7526b1b28Alexey Samsonov profile_osx.a profile_ios.a \ 8275fcb193aeeec5c4f10cc39df60a5ce7526b1b28Alexey Samsonov ubsan_osx.a 83562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendif 84ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar 85ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar# On Linux, include a library which has all the runtime functions. 86ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarifeq ($(OS),Linux) 87ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel DunbarRuntimeDirs += linux 88ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel DunbarRuntimeLibrary.linux.Configs := 89ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar 90f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# TryCompile compiler source flags 91f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# Returns exit code of running a compiler invocation. 92f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey SamsonovTryCompile = \ 93f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov $(shell \ 94f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov cflags=""; \ 95f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov for flag in $(3); do \ 96f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov cflags="$$cflags $$flag"; \ 97f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov done; \ 98f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \ 99f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov echo $$?) 100f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov 101230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruth# We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts. 102230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler CarruthRuntime32BitConfigs = \ 10361a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith full-i386.a profile-i386.a san-i386.a asan-i386.a ubsan-i386.a \ 10461a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith ubsan_cxx-i386.a 105230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruth 106230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruth# We currently only try to generate runtime libraries on x86. 107230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruthifeq ($(ARCH),x86) 108230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler CarruthRuntimeLibrary.linux.Configs += $(Runtime32BitConfigs) 109ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarendif 110f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov 111ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarifeq ($(ARCH),x86_64) 1127df67e6892d74a6653473089473166a30608f416Daniel DunbarRuntimeLibrary.linux.Configs += \ 11361a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith full-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \ 1142eeed711beec49dfad5d3a3f16fdfca4b2f3acf0Peter Collingbourne tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a ubsan_cxx-x86_64.a \ 115d9def9e75e6fae8f215223da4e78c7ec7e3fa4acAlexey Samsonov dfsan-x86_64.a lsan-x86_64.a 116e0d80f1852bff0bcf8f71b73773cdff71bc94f33Alexey Samsonov# We need to build 32-bit ASan/UBsan libraries on 64-bit platform, and add them 117e0d80f1852bff0bcf8f71b73773cdff71bc94f33Alexey Samsonov# to the list of runtime libraries to make 118e0d80f1852bff0bcf8f71b73773cdff71bc94f33Alexey Samsonov# "clang -fsanitize=(address|undefined) -m32" work. 119f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# We check that Clang can produce working 32-bit binaries by compiling a simple 120f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# executable. 121f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonovtest_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c 122f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonovifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0) 123230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler CarruthRuntimeLibrary.linux.Configs += $(Runtime32BitConfigs) 124ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarendif 12519baf068e8d113a242694003ba04508282804e8eEvgeniy Stepanovifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),) 12619baf068e8d113a242694003ba04508282804e8eEvgeniy StepanovRuntimeLibrary.linux.Configs += asan-arm-android.so 12719baf068e8d113a242694003ba04508282804e8eEvgeniy Stepanovendif 128f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonovendif 129ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar 130db0ab63998eb9aad0ead03d3f76f095f9b1eb036Daniel Dunbarendif 131253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar 132e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#### 133e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# The build rules below are designed to be generic and should only need to be 134e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# modified based on changes in the compiler-rt layout or build system. 135e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#### 136e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar 137562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Rule to build the compiler-rt libraries we need. 138562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# 139562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# We build all the libraries in a single shot to avoid recursive make as much as 140562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# possible. 141562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonBuildRuntimeLibraries: 142562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \ 143562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \ 144562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson ProjObjRoot=$(PROJ_OBJ_DIR) \ 1453518058dace8f4c9c3ed0b6a30b0bdf08a10d559Daniel Dunbar CC="$(ToolDir)/clang" \ 14619baf068e8d113a242694003ba04508282804e8eEvgeniy Stepanov LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \ 147562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(RuntimeDirs:%=clang_%) 148562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: BuildRuntimeLibraries 149562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonCleanRuntimeLibraries: 150562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \ 151562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \ 152562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson ProjObjRoot=$(PROJ_OBJ_DIR) \ 153562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson clean 154562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: CleanRuntimeLibraries 1550e7a1cf16c361cd247e31472c253663f6ae32febAlexander PotapenkoRuntimeHeader: $(ResourceIncludeDir)/sanitizer 156562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 157562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_resources_lib): 158562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Verb) $(MKDIR) $@ 159562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 1600e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko$(ResourceIncludeDir): 1610e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Verb) $(MKDIR) $@ 1620e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko 1630e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko$(ResourceIncludeDir)/sanitizer: $(ResourceIncludeDir) 1640e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Verb) $(MKDIR) $@ 1650e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Verb) cp $(COMPILERRT_SRC_ROOT)/include/sanitizer/*.h $@ 1660e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko 167562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Expand rules for copying/installing each individual library. We can't use 168562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# implicit rules here because we need to match against multiple things. 169562627d782393c0d8045625a53a97f4fbad091bcOwen Andersondefine RuntimeLibraryTemplate 170562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a: BuildRuntimeLibraries 171562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson @true 17212f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so: BuildRuntimeLibraries 17312f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar @true 17412f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib: BuildRuntimeLibraries 17512f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar @true 176562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PRECIOUS: $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a 177562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 178562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Rule to copy the libraries to their resource directory location. 179562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(ResourceLibDir)/$1/libclang_rt.%.a: \ 180562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a \ 181562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(ResourceLibDir)/$1/.dir 182562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Echo) Copying runtime library $1/$$* to build dir 183562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.a $$@ 18412f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(ResourceLibDir)/$1/libclang_rt.%.so: \ 18512f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so \ 18612f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(ResourceLibDir)/$1/.dir 18712f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Echo) Copying runtime library $1/$$* to build dir 18812f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.so $$@ 18912f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(ResourceLibDir)/$1/libclang_rt.%.dylib: \ 19012f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib \ 19112f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(ResourceLibDir)/$1/.dir 19212f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Echo) Copying runtime library $1/$$* to build dir 19312f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.dylib $$@ 194b626280eb16a62e32a100f0082e9ea7e496a51d7Alexander Potapenko $(Echo) Fixing LC_ID_DYLIB of $$@ 195b626280eb16a62e32a100f0082e9ea7e496a51d7Alexander Potapenko $(Verb) install_name_tool $$@ -id $$@ 196562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeLibrary.$1: \ 19712f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%) 198562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: RuntimeLibrary.$1 19946bbbdd0111c386c2341919a62c5742f2519efa6Daniel Dunbar 200562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_resources_lib)/$1: $(PROJ_resources_lib) 201562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Verb) $(MKDIR) $$@ 202562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 203562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_resources_lib)/$1/libclang_rt.%.a: \ 204562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(ResourceLibDir)/$1/libclang_rt.%.a | $(PROJ_resources_lib)/$1 205562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Echo) Installing compiler runtime library: $1/$$* 206562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson $(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1 20712f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_resources_lib)/$1/libclang_rt.%.so: \ 20812f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(ResourceLibDir)/$1/libclang_rt.%.so | $(PROJ_resources_lib)/$1 20912f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Echo) Installing compiler runtime library: $1/$$* 21012f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1 21112f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_resources_lib)/$1/libclang_rt.%.dylib: \ 21212f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(ResourceLibDir)/$1/libclang_rt.%.dylib | $(PROJ_resources_lib)/$1 21312f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Echo) Installing compiler runtime library: $1/$$* 21412f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1 215562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 216562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Rule to install runtime libraries. 217562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeLibraryInstall.$1: \ 21812f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar $(RuntimeLibrary.$1.Configs:%=$(PROJ_resources_lib)/$1/libclang_rt.%) 219562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: RuntimeLibraryInstall.$1 220562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendef 221562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib)))) 222562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 2230e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko$(PROJ_resources_include): 2240e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Verb) $(MKDIR) $@ 2250e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko 2260e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko$(PROJ_resources_include)/sanitizer: $(ResourceIncludeDir)/sanitizer $(PROJ_resources_include) 2270e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Verb) $(MKDIR) $@ 2280e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Echo) Installing compiler runtime headers 2290e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(Verb) $(DataInstall) $(ResourceIncludeDir)/sanitizer/* \ 2300e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko $(PROJ_resources_include)/sanitizer 2310e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko 2320e7a1cf16c361cd247e31472c253663f6ae32febAlexander PotapenkoRuntimeHeaderInstall: $(PROJ_resources_include)/sanitizer 2330e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko.PHONY: RuntimeHeaderInstall 2340e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenko 235562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Hook into the standard Makefile rules. 2360e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenkoall-local:: $(RuntimeDirs:%=RuntimeLibrary.%) RuntimeHeader 2370e7a1cf16c361cd247e31472c253663f6ae32febAlexander Potapenkoinstall-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) RuntimeHeaderInstall 238562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonclean-local:: CleanRuntimeLibraries 239562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson 240562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendif 241562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendif 242e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbarendif 243