Add support for controlling symbol visibility using the HP and

Solaris C compilers.
This commit is contained in:
Todd C. Miller
2012-06-15 14:18:23 -04:00
parent 203abd98b9
commit 60a3019483
3 changed files with 120 additions and 2 deletions

91
configure vendored
View File

@@ -20118,10 +20118,101 @@ if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
CFLAGS="${CFLAGS} -fvisibility=hidden"
LT_LDEXPORTS=
else
if test -z "$GCC"; then
case "$host" in
*-*-hpux*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Bhidden_def" >&5
$as_echo_n "checking whether C compiler accepts -Bhidden_def... " >&6; }
if ${ax_cv_check_cflags___Bhidden_def+:} false; then :
$as_echo_n "(cached) " >&6
else
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -Bhidden_def"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ax_cv_check_cflags___Bhidden_def=yes
else
ax_cv_check_cflags___Bhidden_def=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Bhidden_def" >&5
$as_echo "$ax_cv_check_cflags___Bhidden_def" >&6; }
if test x"$ax_cv_check_cflags___Bhidden_def" = xyes; then :
$as_echo "#define HAVE_DSO_VISIBILITY 1" >>confdefs.h
CFLAGS="${CFLAGS} -Bhidden_def"
LT_LDEXPORTS=
else
:
fi
;;
*-*-solaris2*)
as_CACHEVAR=`$as_echo "ax_cv_check_cflags__-xldscope=hidden" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -xldscope=hidden" >&5
$as_echo_n "checking whether C compiler accepts -xldscope=hidden... " >&6; }
if eval \${$as_CACHEVAR+:} false; then :
$as_echo_n "(cached) " >&6
else
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -xldscope=hidden"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$as_CACHEVAR=yes"
else
eval "$as_CACHEVAR=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
eval ac_res=\$$as_CACHEVAR
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
$as_echo "#define HAVE_DSO_VISIBILITY 1" >>confdefs.h
CFLAGS="${CFLAGS} -xldscope=hidden"
LT_LDEXPORTS=
else
:
fi
;;
esac
fi
fi
if test -n "$LT_LDEXPORTS"; then
if test "$lt_cv_prog_gnu_ld" = "yes"; then

View File

@@ -3178,6 +3178,25 @@ AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [
AC_DEFINE(HAVE_DSO_VISIBILITY)
CFLAGS="${CFLAGS} -fvisibility=hidden"
LT_LDEXPORTS=
], [
if test -z "$GCC"; then
case "$host" in
*-*-hpux*)
AX_CHECK_COMPILE_FLAG([-Bhidden_def], [
AC_DEFINE(HAVE_DSO_VISIBILITY)
CFLAGS="${CFLAGS} -Bhidden_def"
LT_LDEXPORTS=
])
;;
*-*-solaris2*)
AX_CHECK_COMPILE_FLAG([-xldscope=hidden], [
AC_DEFINE(HAVE_DSO_VISIBILITY)
CFLAGS="${CFLAGS} -xldscope=hidden"
LT_LDEXPORTS=
])
;;
esac
fi
])
dnl

View File

@@ -54,8 +54,16 @@
#ifndef __dso_public
# ifdef HAVE_DSO_VISIBILITY
# if defined(__GNUC__)
# define __dso_public __attribute__((__visibility__("default")))
# define __dso_hidden __attribute__((__visibility__("hidden")))
# elif defined(__SUNPRO_C)
# define __dso_public __global
# define __dso_hidden __hidden
# else
# define __dso_public __declspec(dllexport)
# define __dso_hidden
# endif
# else
# define __dso_public
# define __dso_hidden