From 60a3019483debecd4e512a66a7cac23f70f62d1c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 15 Jun 2012 14:18:23 -0400 Subject: [PATCH] Add support for controlling symbol visibility using the HP and Solaris C compilers. --- configure | 91 +++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 19 ++++++++++ include/missing.h | 12 +++++-- 3 files changed, 120 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 63e2739c2..248c0bc35 100755 --- a/configure +++ b/configure @@ -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 diff --git a/configure.in b/configure.in index a260e65d2..f0af2b0d8 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/include/missing.h b/include/missing.h index 1c428fdab..238907c18 100644 --- a/include/missing.h +++ b/include/missing.h @@ -54,8 +54,16 @@ #ifndef __dso_public # ifdef HAVE_DSO_VISIBILITY -# define __dso_public __attribute__((__visibility__("default"))) -# define __dso_hidden __attribute__((__visibility__("hidden"))) +# 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 -- 2.50.1