summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-02-17 23:30:51 +0000
committerMatthias Braun <matze@braunis.de>2015-02-17 23:30:51 +0000
commit7859c0ef5b932f0074e4af67f8ff9014e86ff673 (patch)
treeac2f6863e4715ecb9634c55b8f3c525d616c4714 /make
parent9f1b2b2a2655682ebf544623e8633d8f887d8649 (diff)
Revert "Remove support for building sanitizers from Makefile/autoconf build."
This reverts commit r229556. Reverting this for now as internal apple builds rely on this functionality. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229585 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'make')
-rw-r--r--make/platform/clang_darwin.mk58
-rw-r--r--make/platform/clang_linux.mk75
2 files changed, 130 insertions, 3 deletions
diff --git a/make/platform/clang_darwin.mk b/make/platform/clang_darwin.mk
index cf7e418a6..4f71c0b46 100644
--- a/make/platform/clang_darwin.mk
+++ b/make/platform/clang_darwin.mk
@@ -112,6 +112,16 @@ Configs += 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,$(OSX_SDK))
+
+Configs += asan_iossim_dynamic
+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,$(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
# build the libraries themselves so that Clang can find them where it expects
@@ -162,6 +172,27 @@ IOSSIM_DEPLOYMENT_ARGS += -isysroot $(IOSSIM_SDK)
CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
+CFLAGS.asan_osx_dynamic := \
+ $(CFLAGS) -mmacosx-version-min=10.7 \
+ -stdlib=libc++ \
+ -isysroot $(OSX_SDK) \
+ -fno-builtin \
+ -gline-tables-only \
+ -DMAC_INTERPOSE_FUNCTIONS=1 \
+ -DASAN_DYNAMIC=1
+
+CFLAGS.asan_iossim_dynamic := \
+ $(CFLAGS) -mios-simulator-version-min=7.0 \
+ -isysroot $(IOSSIM_SDK) \
+ -fno-builtin \
+ -gline-tables-only \
+ -DMAC_INTERPOSE_FUNCTIONS=1 \
+ -DASAN_DYNAMIC=1
+
+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)
CFLAGS.ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
@@ -191,6 +222,20 @@ CFLAGS.profile_ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
CFLAGS.profile_ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
CFLAGS.profile_ios.arm64 := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
+# Configure the asan_osx_dynamic library to be built shared.
+SHARED_LIBRARY.asan_osx_dynamic := 1
+LDFLAGS.asan_osx_dynamic := -lc++ -undefined dynamic_lookup -install_name @rpath/libclang_rt.asan_osx_dynamic.dylib \
+ -mmacosx-version-min=10.7 \
+ -isysroot $(OSX_SDK)
+
+# Configure the asan_iossim_dynamic library to be built shared.
+SHARED_LIBRARY.asan_iossim_dynamic := 1
+# configure+make uses Clang, so we're using isysroot instead of --sysroot
+# 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)
+
FUNCTIONS.eprintf := eprintf
FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf
@@ -208,6 +253,19 @@ FUNCTIONS.profile_osx := GCDAProfiling InstrProfiling InstrProfilingBuffer \
InstrProfilingRuntime
FUNCTIONS.profile_ios := $(FUNCTIONS.profile_osx)
+FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(AsanCXXFunctions) \
+ $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions) \
+ $(AsanDynamicFunctions)
+
+FUNCTIONS.asan_iossim_dynamic := $(AsanFunctions) $(AsanCXXFunctions) \
+ $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions) \
+ $(AsanDynamicFunctions)
+
+FUNCTIONS.ubsan_osx := $(UbsanFunctions) $(UbsanCXXFunctions) \
+ $(SanitizerCommonFunctions)
+
CCKEXT_PROFILE_FUNCTIONS := \
InstrProfiling \
InstrProfilingBuffer \
diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk
index cb023f3db..fc4405734 100644
--- a/make/platform/clang_linux.mk
+++ b/make/platform/clang_linux.mk
@@ -49,34 +49,80 @@ endif
# Build runtime libraries for i386.
ifeq ($(call contains,$(SupportedArches),i386),true)
-Configs += builtins-i386 profile-i386
+Configs += builtins-i386 profile-i386 san-i386 asan-i386 asan_cxx-i386 \
+ ubsan-i386 ubsan_cxx-i386
Arch.builtins-i386 := i386
Arch.profile-i386 := i386
+Arch.san-i386 := i386
+Arch.asan-i386 := i386
+Arch.asan_cxx-i386 := i386
+Arch.ubsan-i386 := i386
+Arch.ubsan_cxx-i386 := i386
endif
# Build runtime libraries for x86_64.
ifeq ($(call contains,$(SupportedArches),x86_64),true)
-Configs += builtins-x86_64 profile-x86_64
+Configs += builtins-x86_64 profile-x86_64 san-x86_64 asan-x86_64 asan_cxx-x86_64 \
+ tsan-x86_64 msan-x86_64 ubsan-x86_64 ubsan_cxx-x86_64 dfsan-x86_64 \
+ lsan-x86_64
Arch.builtins-x86_64 := x86_64
Arch.profile-x86_64 := x86_64
+Arch.san-x86_64 := x86_64
+Arch.asan-x86_64 := x86_64
+Arch.asan_cxx-x86_64 := x86_64
+Arch.tsan-x86_64 := x86_64
+Arch.msan-x86_64 := x86_64
+Arch.ubsan-x86_64 := x86_64
+Arch.ubsan_cxx-x86_64 := x86_64
+Arch.dfsan-x86_64 := x86_64
+Arch.lsan-x86_64 := x86_64
endif
endif
+ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
+Configs += asan-arm-android
+Arch.asan-arm-android := arm-android
+endif
+
endif
###
CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
+SANITIZER_CFLAGS := -fPIE -fno-builtin -gline-tables-only
CFLAGS.builtins-i386 := $(CFLAGS) -m32
CFLAGS.builtins-x86_64 := $(CFLAGS) -m64
CFLAGS.profile-i386 := $(CFLAGS) -m32
CFLAGS.profile-x86_64 := $(CFLAGS) -m64
+CFLAGS.san-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.san-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.asan-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.asan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.asan_cxx-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.asan_cxx-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.tsan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.msan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.ubsan-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.ubsan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.ubsan_cxx-i386 := $(CFLAGS) -m32 $(SANITIZER_CFLAGS)
+CFLAGS.ubsan_cxx-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS)
+CFLAGS.dfsan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+CFLAGS.lsan-x86_64 := $(CFLAGS) -m64 $(SANITIZER_CFLAGS) -fno-rtti
+
+SHARED_LIBRARY.asan-arm-android := 1
+ANDROID_COMMON_FLAGS := -target arm-linux-androideabi \
+ --sysroot=$(LLVM_ANDROID_TOOLCHAIN_DIR)/sysroot \
+ -B$(LLVM_ANDROID_TOOLCHAIN_DIR)
+CFLAGS.asan-arm-android := $(CFLAGS) $(SANITIZER_CFLAGS) \
+ $(ANDROID_COMMON_FLAGS) -fno-rtti
+LDFLAGS.asan-arm-android := $(LDFLAGS) $(ANDROID_COMMON_FLAGS) -ldl -lm -llog \
+ -lstdc++ -Wl,-soname=libclang_rt.asan-arm-android.so -Wl,-z,defs
# Use our stub SDK as the sysroot to support more portable building. For now we
# just do this for the core module, because the stub SDK doesn't have
-# enough support to build the profile runtime.
+# enough support to build the sanitizers or profile runtimes.
CFLAGS.builtins-i386 += --sysroot=$(ProjSrcRoot)/SDKs/linux
CFLAGS.builtins-x86_64 += --sysroot=$(ProjSrcRoot)/SDKs/linux
@@ -86,6 +132,29 @@ FUNCTIONS.profile-i386 := GCDAProfiling InstrProfiling InstrProfilingBuffer \
InstrProfilingFile InstrProfilingPlatformOther \
InstrProfilingRuntime
FUNCTIONS.profile-x86_64 := $(FUNCTIONS.profile-i386)
+FUNCTIONS.san-i386 := $(SanitizerCommonFunctions)
+FUNCTIONS.san-x86_64 := $(SanitizerCommonFunctions)
+FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions)
+FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions) $(LsanCommonFunctions)
+FUNCTIONS.asan_cxx-i386 := $(AsanCXXFunctions)
+FUNCTIONS.asan_cxx-x86_64 := $(AsanCXXFunctions)
+FUNCTIONS.asan-arm-android := $(AsanFunctions) $(AsanCXXFunctions) \
+ $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions)
+FUNCTIONS.tsan-x86_64 := $(TsanFunctions) $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions)
+FUNCTIONS.msan-x86_64 := $(MsanFunctions) $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions)
+FUNCTIONS.ubsan-i386 := $(UbsanFunctions)
+FUNCTIONS.ubsan-x86_64 := $(UbsanFunctions)
+FUNCTIONS.ubsan_cxx-i386 := $(UbsanCXXFunctions)
+FUNCTIONS.ubsan_cxx-x86_64 := $(UbsanCXXFunctions)
+FUNCTIONS.dfsan-x86_64 := $(DfsanFunctions) $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions)
+FUNCTIONS.lsan-x86_64 := $(LsanFunctions) $(InterceptionFunctions) \
+ $(SanitizerCommonFunctions)
# Always use optimized variants.
OPTIMIZED := 1