From 97eb03c9a7c7c2a5fab40aadeb1066a7502aa8e4 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Sun, 31 May 2015 03:08:17 +0400 Subject: [PATCH] Re-enable symbols visibility support for the Clang compiler Visibility support for Clang was disabled in 7198c33 because of linking errors when building shared libraries, related to non-inline methods in exported template classes. The last Clang version to have these problems is version "4.1 (tags/Apple/clang-421.11.66)" as part of Xcode 4.5.2, and the next release fixes them (version "4.2 (clang-425.0.24)", Xcode 4.6). Check for the Clang version and only disable visibility support when compiling with Apple Clang < 4.2. Note that Apple Clang 4.2 is based on official Clang 3.2 so also check for that version in case of non-Apple builds. The only official Clang that has been tested successfully is 3.4 which worked fine with visibility. Other versions that were tried (3.1 and 3.2) segfault while compiling wx. (this is a backport of 7cacde3 from master) --- build/aclocal/visibility.m4 | 19 ++++++++++++++++--- configure | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/build/aclocal/visibility.m4 b/build/aclocal/visibility.m4 index 05f9b80dec..3d7c972aec 100644 --- a/build/aclocal/visibility.m4 +++ b/build/aclocal/visibility.m4 @@ -49,9 +49,22 @@ AC_DEFUN([WX_VISIBILITY], error this platform has no visibility; #endif - /* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */ - #if defined(__clang__) - clang compiler is still broken w.r.t. visibility; + /* At the time of Xcode 4.1 / Clang 3, Clang++ still didn't + have the bugs sorted out. These were fixed starting with + Xcode 4.6.0 / Apple Clang 4.2 (which is based on Clang 3.2 so + check for that version too). */ + #ifdef __clang__ + #ifdef __APPLE__ + #if __clang_major__ < 4 \ + || (__clang_major__ == 4 && __clang_minor__ < 2) + error Clang compiler version < 4.2 is broken w.r.t. visibility; + #endif + #else + #if __clang_major__ < 3 \ + || (__clang_major__ == 3 && __clang_minor__ < 2) + error Clang compiler version < 3.2 is broken w.r.t. visibility; + #endif + #endif #endif extern __attribute__((__visibility__("hidden"))) int hiddenvar; diff --git a/configure b/configure index 3b50e6565a..4c0f1e8c27 100755 --- a/configure +++ b/configure @@ -28934,9 +28934,22 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu error this platform has no visibility; #endif - /* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */ - #if defined(__clang__) - clang compiler is still broken w.r.t. visibility; + /* At the time of Xcode 4.1 / Clang 3, Clang++ still didn't + have the bugs sorted out. These were fixed starting with + Xcode 4.6.0 / Apple Clang 4.2 (which is based on Clang 3.2 so + check for that version too). */ + #ifdef __clang__ + #ifdef __APPLE__ + #if __clang_major__ < 4 \ + || (__clang_major__ == 4 && __clang_minor__ < 2) + error Clang compiler version < 4.2 is broken w.r.t. visibility; + #endif + #else + #if __clang_major__ < 3 \ + || (__clang_major__ == 3 && __clang_minor__ < 2) + error Clang compiler version < 3.2 is broken w.r.t. visibility; + #endif + #endif #endif extern __attribute__((__visibility__("hidden"))) int hiddenvar;