From fe588fef0963987b5624dc8c4bc73202ac2c9298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Mon, 28 Mar 2022 17:17:41 +0200 Subject: cpp: Set default visibility of all symbols to hidden * configure.ac: Add -fvisibility=hidden to GPGME_CPP_CFLAGS if gcc supports the flag. * lang/cpp/src/Makefile.am (AM_CPPFLAGS): Add GPGME_CPP_CFLAGS. * m4/ax_gcc_func_attribute.m4: New. -- With this change all defined symbols are hidden by default, so that they are not exported anymore. All symbols that are part of the ABI and that shall still be exported are already marked as having default visibility. The m4 macro was taken from the website mentioned in the License header of the file. GnuPG-bug-id: 5906 --- configure.ac | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 43256093..78824962 100644 --- a/configure.ac +++ b/configure.ac @@ -331,8 +331,6 @@ for language in $enabled_languages; do fi done - - # Enable C++ 11 if cpp language is requested LIST_MEMBER("cpp", $enabled_languages) if test "$found" = "1"; then @@ -354,6 +352,16 @@ if test "$found" = "1"; then fi fi +# Check whether compiler supports visibility attribute (if cpp language is enabled) +LIST_MEMBER("cpp", $enabled_languages) +if test "$found" = "1"; then + AX_GCC_FUNC_ATTRIBUTE(visibility) + if test "$ax_cv_have_func_attribute_visibility" = "yes"; then + GPGME_CPP_CFLAGS="$GPGME_CPP_CFLAGS -fvisibility=hidden" + fi +fi +AC_SUBST(GPGME_CPP_CFLAGS) + # Check that if qt is enabled cpp also is enabled LIST_MEMBER("qt", $enabled_languages) if test "$found" = "1"; then -- cgit v1.2.3