From: Yury Gribov Date: Wed, 25 Apr 2018 05:03:36 +0000 (+0100) Subject: Hide private symbols. X-Git-Tag: R_2_2_7~24^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30f8c30b6a9cf3711dfef1a9bb7d5b045a206d89;p=libexpat Hide private symbols. --- diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 673184fa..a052f189 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -101,6 +101,10 @@ set(EXTRA_COMPILE_FLAGS) if(FLAG_NO_STRICT_ALIASING) set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fno-strict-aliasing") endif() +if(FLAG_VISIBILITY) + add_definitions(-DXML_ENABLE_VISIBILITY=1) + set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fvisibility=hidden") +endif(FLAG_VISIBILITY) if (WARNINGS_AS_ERRORS) if(MSVC) add_definitions(/WX) diff --git a/expat/ConfigureChecks.cmake b/expat/ConfigureChecks.cmake index dbb49210..818d2492 100644 --- a/expat/ConfigureChecks.cmake +++ b/expat/ConfigureChecks.cmake @@ -68,3 +68,4 @@ configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h" add_definitions(-DHAVE_EXPAT_CONFIG_H) check_c_compiler_flag("-fno-strict-aliasing" FLAG_NO_STRICT_ALIASING) +check_c_compiler_flag("-fvisibility=hidden" FLAG_VISIBILITY) diff --git a/expat/configure.ac b/expat/configure.ac index a68d9a4e..12f66422 100644 --- a/expat/configure.ac +++ b/expat/configure.ac @@ -88,6 +88,13 @@ if test "$GCC" = yes ; then LDFLAGS="${LDFLAGS} -fno-strict-aliasing" fi +AC_MSG_CHECKING(whether compiler supports visibility) +OLDCFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fvisibility=hidden -Wall -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void __attribute__((visibility("default"))) foo(void); void foo(void) {}]])], + AC_MSG_RESULT(yes); CFLAGS="$OLDCFLAGS -fvisibility=hidden -DXML_ENABLE_VISIBILITY=1", + AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS") + dnl Checks for header files. AC_HEADER_STDC diff --git a/expat/lib/expat_external.h b/expat/lib/expat_external.h index 629483a9..875225d7 100644 --- a/expat/lib/expat_external.h +++ b/expat/lib/expat_external.h @@ -93,7 +93,11 @@ # endif #endif /* not defined XML_STATIC */ -#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4) +#ifndef XML_ENABLE_VISIBILITY +# define XML_ENABLE_VISIBILITY 0 +#endif + +#if !defined(XMLIMPORT) && XML_ENABLE_VISIBILITY # define XMLIMPORT __attribute__ ((visibility ("default"))) #endif diff --git a/expat/lib/internal.h b/expat/lib/internal.h index e33fdcb0..dc4ef0c7 100644 --- a/expat/lib/internal.h +++ b/expat/lib/internal.h @@ -115,6 +115,11 @@ extern "C" { #endif +#ifdef XML_ENABLE_VISIBILITY +#if XML_ENABLE_VISIBILITY +__attribute__ ((visibility ("default"))) +#endif +#endif void _INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef);