From ca8d2010707044bc9c1fe9e0a5485cb8309f297e Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Mon, 5 Feb 2018 23:02:09 +0000 Subject: [PATCH] [Sanitizers, Darwin] Disable SANITIZER_SUPPORTS_WEAK_HOOKS before Mac OS X 10.9 Summary: Before Xcode 4.5, undefined weak symbols don't work reliably on Darwin: https://stackoverflow.com/questions/6009321/weak-symbol-link-on-mac-os-x Therefore this patch disables their use before Mac OS X 10.9 which is the first version only supported by Xcode 4.5 and above. Reviewers: glider, kcc, vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41346 llvm-svn: 324284 --- compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index 7ba7adaa..2d68ed1 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -65,7 +65,13 @@ // SANITIZER_SUPPORTS_WEAK_HOOKS means that we support real weak functions that // will evaluate to a null pointer when not defined. #ifndef SANITIZER_SUPPORTS_WEAK_HOOKS -#if (SANITIZER_LINUX || SANITIZER_MAC || SANITIZER_SOLARIS) && !SANITIZER_GO +#if (SANITIZER_LINUX || SANITIZER_SOLARIS) && !SANITIZER_GO +# define SANITIZER_SUPPORTS_WEAK_HOOKS 1 +// Before Xcode 4.5, the Darwin linker doesn't reliably support undefined +// weak symbols. Mac OS X 10.9/Darwin 13 is the first release only supported +// by Xcode >= 4.5. +#elif SANITIZER_MAC && \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 && !SANITIZER_GO # define SANITIZER_SUPPORTS_WEAK_HOOKS 1 #else # define SANITIZER_SUPPORTS_WEAK_HOOKS 0 -- 2.7.4