summaryrefslogtreecommitdiff
path: root/make/platform
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2014-11-10 19:38:15 +0000
committerBob Wilson <bob.wilson@apple.com>2014-11-10 19:38:15 +0000
commitf028d70fcadd9b6c4d3ce1dd1af89703e422f6fa (patch)
tree3e3611bec45cfcceac78c0d5cbf728e0eac02c51 /make/platform
parent60927db68941599e8e1bda74e64a1142642f3829 (diff)
Build Darwin libclang_rt libraries against real SDKs.
The minimal fake SDK was very useful in allowing us to build for all Darwin platforms without needing access to the real SDKs, but it did not support building any of the sanitizer runtimes. It's important to fix that. As a consequence, if you don't have the iOS SDKs installed, we will now skip building the iOS-specific libclang_rt libraries. rdar://problem/18825276 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'make/platform')
-rw-r--r--make/platform/clang_darwin.mk88
1 files changed, 52 insertions, 36 deletions
diff --git a/make/platform/clang_darwin.mk b/make/platform/clang_darwin.mk
index ad79f77bf..7b73dc54a 100644
--- a/make/platform/clang_darwin.mk
+++ b/make/platform/clang_darwin.mk
@@ -6,16 +6,21 @@
Description := Static runtime libraries for clang/Darwin.
-# A function that ensures we don't try to build for architectures that we
-# don't have working toolchains for.
+# A function that ensures we don't try to build for architectures and SDKs
+# that we don't have working toolchains for. Arguments:
+# (1): List of architectures
+# (2): Library name
+# (3): SDK path
+# The result is a possibly empty subset of the architectures from argument 1.
CheckArches = \
$(shell \
result=""; \
- for arch in $(1); do \
+ if [ "X$(3)" != X ]; then \
+ for arch in $(1); do \
if $(CC) -arch $$arch -c \
-integrated-as \
$(ProjSrcRoot)/make/platform/clang_darwin_test_input.c \
- -isysroot $(ProjSrcRoot)/SDKs/darwin \
+ -isysroot $(3) \
-o /dev/null > /dev/null 2> /dev/null; then \
if $(LD) -v 2>&1 | grep "configured to support" \
| tr ' ' '\n' | grep "^$$arch$$" >/dev/null 2>/dev/null; then \
@@ -30,7 +35,8 @@ CheckArches = \
"warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
printf 1>&2 " (clang does not support it)\n"; \
fi; \
- done; \
+ done; \
+ fi; \
echo $$result)
XCRun = \
@@ -53,6 +59,10 @@ STRIP := $(call XCRun,strip)
LIPO := $(call XCRun,lipo)
DSYMUTIL := $(call XCRun,dsymutil)
+OSX_SDK := $(call XCRunSdkPath,macosx)
+IOS_SDK := $(call XCRunSdkPath,iphoneos)
+IOSSIM_SDK := $(call XCRunSdkPath,iphonesimulator)
+
Configs :=
UniversalArchs :=
@@ -60,51 +70,53 @@ UniversalArchs :=
# still be referenced from Darwin system headers. This symbol is only ever
# needed on i386.
Configs += eprintf
-UniversalArchs.eprintf := $(call CheckArches,i386,eprintf)
+UniversalArchs.eprintf := $(call CheckArches,i386,eprintf,$(OSX_SDK))
# Configuration for targeting 10.4. We need a few functions missing from
# libgcc_s.10.4.dylib. We only build x86 slices since clang doesn't really
# support targeting PowerPC.
Configs += 10.4
-UniversalArchs.10.4 := $(call CheckArches,i386 x86_64,10.4)
+UniversalArchs.10.4 := $(call CheckArches,i386 x86_64,10.4,$(OSX_SDK))
# Configuration for targeting iOS for a couple of functions that didn't
# make it into libSystem.
Configs += ios
-UniversalArchs.ios := $(call CheckArches,i386 x86_64 armv7 arm64,ios)
+UniversalArchs.ios := $(call CheckArches,i386 x86_64,ios,$(IOSSIM_SDK))
+UniversalArchs.ios += $(call CheckArches,armv7 arm64,ios,$(IOS_SDK))
# Configuration for targeting OSX. These functions may not be in libSystem
# so we should provide our own.
Configs += osx
-UniversalArchs.osx := $(call CheckArches,i386 x86_64 x86_64h,osx)
+UniversalArchs.osx := $(call CheckArches,i386 x86_64 x86_64h,osx,$(OSX_SDK))
# Configuration for use with kernel/kexts.
Configs += cc_kext
-UniversalArchs.cc_kext := $(call CheckArches,armv7 arm64 i386 x86_64 x86_64h,cc_kext)
+UniversalArchs.cc_kext := $(call CheckArches,i386 x86_64 x86_64h,cc_kext,$(OSX_SDK))
+UniversalArchs.cc_kext += $(call CheckArches,armv7 arm64,cc_kext,$(IOS_SDK))
# Configuration for use with kernel/kexts for iOS 5.0 and earlier (which used
-# a different code generation strategy).
+# a different code generation strategy). Note: the x86_64 slice is unused but
+# it avoids build problems (see pr14013).
Configs += cc_kext_ios5
-UniversalArchs.cc_kext_ios5 := $(call CheckArches,x86_64 armv7,cc_kext_ios5)
+UniversalArchs.cc_kext_ios5 := $(call CheckArches,x86_64,cc_kext_ios5,$(IOSSIM_SDK))
+UniversalArchs.cc_kext_ios5 += $(call CheckArches,armv7,cc_kext_ios5,$(IOS_SDK))
# Configurations which define the profiling support functions.
Configs += profile_osx
-UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64 x86_64h,profile_osx)
+UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64 x86_64h,profile_osx,$(OSX_SDK))
Configs += profile_ios
-UniversalArchs.profile_ios := $(call CheckArches,i386 x86_64 armv7 arm64,profile_ios)
+UniversalArchs.profile_ios := $(call CheckArches,i386 x86_64,profile_ios,$(IOSSIM_SDK))
+UniversalArchs.profile_ios += $(call CheckArches,armv7 arm64,profile_ios,$(IOS_SDK))
# Configurations which define the ASAN support functions.
Configs += asan_osx_dynamic
-UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_osx_dynamic)
+UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_osx_dynamic,$(OSX_SDK))
-IOSSIM_SDK_PATH := $(call XCRunSdkPath,iphonesimulator)
-ifneq ($(IOSSIM_SDK_PATH),)
Configs += asan_iossim_dynamic
-UniversalArchs.asan_iossim_dynamic := $(call CheckArches,i386 x86_64,asan_iossim_dynamic)
-endif
+UniversalArchs.asan_iossim_dynamic := $(call CheckArches,i386 x86_64,asan_iossim_dynamic,$(IOSSIM_SDK))
Configs += ubsan_osx
-UniversalArchs.ubsan_osx := $(call CheckArches,i386 x86_64 x86_64h,ubsan_osx)
+UniversalArchs.ubsan_osx := $(call CheckArches,i386 x86_64 x86_64h,ubsan_osx,$(OSX_SDK))
# Darwin 10.6 has a bug in cctools that makes it unable to use ranlib on our ARM
# object files. If we are on that platform, strip out all ARM archs. We still
@@ -119,17 +131,18 @@ endif
# If RC_SUPPORTED_ARCHS is defined, treat it as a list of the architectures we
# are intended to support and limit what we try to build to that.
-#
-# We make sure to remove empty configs if we end up dropping all the requested
-# archs for a particular config.
ifneq ($(RC_SUPPORTED_ARCHS),)
$(foreach config,$(Configs),\
$(call Set,UniversalArchs.$(config),\
- $(filter $(RC_SUPPORTED_ARCHS),$(UniversalArchs.$(config))))\
- $(if $(UniversalArchs.$(config)),,\
- $(call Set,Configs,$(filter-out $(config),$(Configs)))))
+ $(filter $(RC_SUPPORTED_ARCHS),$(UniversalArchs.$(config))))
endif
+# Remove empty configs if we end up dropping all the requested
+# archs for a particular config.
+$(foreach config,$(Configs),\
+ $(if $(strip $(UniversalArchs.$(config))),,\
+ $(call Set,Configs,$(filter-out $(config),$(Configs)))))
+
###
# Forcibly strip off any -arch, as that totally breaks our universal support.
@@ -147,28 +160,31 @@ IOS_DEPLOYMENT_ARGS := -mios-version-min=1.0
IOS6_DEPLOYMENT_ARGS := -mios-version-min=6.0
IOSSIM_DEPLOYMENT_ARGS := -mios-simulator-version-min=1.0
-# Use our stub SDK as the sysroot to support more portable building.
-OSX_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
-IOS_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
-IOS6_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
-IOSSIM_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
+OSX_DEPLOYMENT_ARGS += -isysroot $(OSX_SDK)
+IOS_DEPLOYMENT_ARGS += -isysroot $(IOS_SDK)
+IOS6_DEPLOYMENT_ARGS += -isysroot $(IOS_SDK)
+IOSSIM_DEPLOYMENT_ARGS += -isysroot $(IOSSIM_SDK)
CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
-# FIXME: We can't build ASAN with our stub SDK yet.
+
CFLAGS.asan_osx_dynamic := \
- $(CFLAGS) -mmacosx-version-min=10.7 -fno-builtin \
+ $(CFLAGS) -mmacosx-version-min=10.7 \
+ -isysroot $(OSX_SDK) \
+ -fno-builtin \
-gline-tables-only \
-DMAC_INTERPOSE_FUNCTIONS=1
CFLAGS.asan_iossim_dynamic := \
$(CFLAGS) -mios-simulator-version-min=7.0 \
- -isysroot $(IOSSIM_SDK_PATH) \
+ -isysroot $(IOSSIM_SDK) \
-fno-builtin \
-gline-tables-only \
-DMAC_INTERPOSE_FUNCTIONS=1
-CFLAGS.ubsan_osx := $(CFLAGS) -mmacosx-version-min=10.6 -fno-builtin
+CFLAGS.ubsan_osx := $(CFLAGS) -mmacosx-version-min=10.6 \
+ -isysroot $(OSX_SDK) \
+ -fno-builtin
CFLAGS.ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
CFLAGS.ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
@@ -209,7 +225,7 @@ SHARED_LIBRARY.asan_iossim_dynamic := 1
# or -Wl,-syslibroot.
LDFLAGS.asan_iossim_dynamic := -undefined dynamic_lookup -install_name @rpath/libclang_rt.asan_iossim_dynamic.dylib \
-Wl,-ios_simulator_version_min,7.0.0 \
- -mios-simulator-version-min=7.0 -isysroot $(IOSSIM_SDK_PATH)
+ -mios-simulator-version-min=7.0 -isysroot $(IOSSIM_SDK)
FUNCTIONS.eprintf := eprintf
FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf