[PATCH] D41346: [Sanitizers, Darwin] Disable SANITIZER_SUPPORTS_WEAK_HOOKS before Mac OS X 10.9

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 04:10:11 PST 2017


ro created this revision.
ro added reviewers: glider, kcc.
ro added a project: Sanitizers.
Herald added subscribers: Sanitizers, fedor.sergeev, kubamracek.

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.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D41346

Files:
  lib/sanitizer_common/sanitizer_internal_defs.h


Index: lib/sanitizer_common/sanitizer_internal_defs.h
===================================================================
--- lib/sanitizer_common/sanitizer_internal_defs.h
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41346.127328.patch
Type: text/x-patch
Size: 966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171218/d91a8143/attachment.bin>


More information about the llvm-commits mailing list