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/Changes b/expat/Changes index a3cd55b1..de19af59 100644 --- a/expat/Changes +++ b/expat/Changes @@ -4,10 +4,13 @@ NOTE: We are looking for help with a few things: Release x.x.x XXX XXXXXX XX XXXX Other changes: + #195 #197 Autotools/CMake: Utilize -fvisibility=hidden to stop + exporting non-API symbols #212 CMake: Make libdir of pkgconfig expat.pc support multilib Special thanks to: @userwithuid + Yury Gribov Release 2.2.6 Sun August 12 2018 Bug fixes: 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);