r12836: use: -fvisibility=hidden -D_PUBLIC_="__attribute__((visibility(\"default...
authorStefan Metzmacher <metze@samba.org>
Wed, 11 Jan 2006 00:56:49 +0000 (00:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:50:04 +0000 (13:50 -0500)
if the compiler supports it, this will cause that modules can only access
public functions (gcc 4 supports this)

metze

source/build/m4/check_cc.m4
source/configure.in

index aa6c8752ed91d590cc94ac0047cac3312e401d60..7551b67b17a22cd9cfde3e2f712bad0a18e5f632 100644 (file)
@@ -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
index bd64cdf1845ad73f1cf7e9b9bd1b14ba4a3b8b41..7fb6ccf38ab8378bae8e46b0f9168b51d427af29 100644 (file)
@@ -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