From 746f7976ab82b7c1d1c31349b4cd098f020de848 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Tue, 18 May 2021 20:22:36 -0700 Subject: [PATCH] [trace] Refine the ZSTD_HAVE_WEAK_SYMBOLS detection * Only enable for ELF on x86-64 or i386. * Also explicitly disable for AIX. Fixes #2658. --- lib/common/zstd_trace.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/common/zstd_trace.h b/lib/common/zstd_trace.h index 2da5640771..f9121f7d8e 100644 --- a/lib/common/zstd_trace.h +++ b/lib/common/zstd_trace.h @@ -17,10 +17,19 @@ extern "C" { #include -/* weak symbol support */ -#if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && defined(__GNUC__) && \ +/* weak symbol support + * For now, enable conservatively: + * - Only GNUC + * - Only ELF + * - Only x86-64 and i386 + * Also, explicitly disable on platforms known not to work so they aren't + * forgotten in the future. + */ +#if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && \ + defined(__GNUC__) && defined(__ELF__) && \ + (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)) && \ !defined(__APPLE__) && !defined(_WIN32) && !defined(__MINGW32__) && \ - !defined(__CYGWIN__) + !defined(__CYGWIN__) && !defined(_AIX) # define ZSTD_HAVE_WEAK_SYMBOLS 1 #else # define ZSTD_HAVE_WEAK_SYMBOLS 0