From eab4a561974eb54796a0a51f11f7167f8d2a7e0c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 00:56:49 +0000 Subject: r12836: use: -fvisibility=hidden -D_PUBLIC_="__attribute__((visibility(\"default\")))" if the compiler supports it, this will cause that modules can only access public functions (gcc 4 supports this) metze (This used to be commit bcf4c362556b8168fc0b63af5708e4a78c7b93fb) --- source4/build/m4/check_cc.m4 | 19 +++++++++++++++++++ source4/configure.in | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/build/m4/check_cc.m4 b/source4/build/m4/check_cc.m4 index aa6c8752ed..7551b67b17 100644 --- a/source4/build/m4/check_cc.m4 +++ b/source4/build/m4/check_cc.m4 @@ -116,6 +116,25 @@ AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"], AC_MSG_ERROR([cant find test code. Aborting config]), AC_MSG_WARN([cannot run when cross-compiling])) +# +# Check if the compiler support ELF visibility for symbols +# +if test x"$GCC" = x"yes" ; then + AX_CFLAGS_GCC_OPTION([-fvisibility=hidden], VISIBILITY_CFLAGS) +fi +if test -n "$VISIBILITY_CFLAGS"; then + OLD_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} ${VISIBILITY_CFLAGS} -D_PUBLIC_=__attribute__((visibility(\"default\")))" + VISIBILITY_CFLAGS="${VISIBILITY_CFLAGS} -D_PUBLIC_=\"__attribute__((visibility(\\\"default\\\")))\"" + AC_MSG_CHECKING([that the C compiler can use the VISIBILITY_CFLAGS]) + AC_TRY_RUN([ + _PUBLIC_ void vis_foo1(void) {} + __attribute__((visibility("default"))) void vis_foo2(void) {} + #include "${srcdir-.}/build/tests/trivial.c" + ], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no);VISIBILITY_CFLAGS=""]) + CFLAGS="${OLD_CFLAGS}" +fi + # # Check if the compiler can handle the options we selected by # --enable-*developer diff --git a/source4/configure.in b/source4/configure.in index bd64cdf184..7fb6ccf38a 100644 --- a/source4/configure.in +++ b/source4/configure.in @@ -53,8 +53,8 @@ if test "${ac_cv_prog_CC}" = "insure"; then fi ################################################# -# add DEVELOPER_CFLAGS only for the real build -CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}" +# add *_CFLAGS only for the real build +CFLAGS="${CFLAGS} ${VISIBILITY_CFLAGS} ${DEVELOPER_CFLAGS}" ################################################# # final configure stuff -- cgit