[libsanitizer] Guard against undefined weak symbols before Mac OS X 10.9 (PR sanitizer/82825)

Message ID yddshb446n9.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series
  • [libsanitizer] Guard against undefined weak symbols before Mac OS X 10.9 (PR sanitizer/82825)
Related show

Commit Message

Rainer Orth Jan. 17, 2018, 7:39 p.m.
As described in the PR, older versions of Mac OS X don't reliably
support undefined weak symbols, leading to hundreds of testsuite
failures for the sanitizers.  The following patch has been approved
upstream (https://reviews.llvm.org/D41346), but not been applied yet.
To fit into the gcc tree, it had to be modified slighly to account for
the Solaris sanitizer port which isn't in our tree yet.

Jakub suggested in the PR to apply the patch now, so that's what I'm
doing here.  I'll insert the upstream revision number in the ChangeLog
once it has been applied there.

Tested on x86_64-apple-darwin11.4.2.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2018-01-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR sanitizer/82825
	* sanitizer_common/sanitizer_internal_defs.h: Cherry-pick upstream
	r??????.

Patch

# HG changeset patch
# Parent  5a47a5ded615a8757277869e03afe2337e6de3d4
Guard against undefined weak symbols before Mac OS X 10.9 (PR sanitizer/82825)

diff --git a/libsanitizer/sanitizer_common/sanitizer_internal_defs.h b/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
--- a/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
+++ b/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
@@ -63,7 +63,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_GO
+#if SANITIZER_LINUX && !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