diff --git a/libcilkrts/ChangeLog b/libcilkrts/ChangeLog index c73b9233850..abcd198a635 100644 --- a/libcilkrts/ChangeLog +++ b/libcilkrts/ChangeLog @@ -1,3 +1,11 @@ +2013-11-22 Rainer Orth + + * configure.ac (libcilkrts_cv_have_attribute_visibility): Check + for __attribute__((visibility)). + * configure: Regenerate. + * include/cilk/common.h (CILK_EXPORT, CILK_EXPORT_DATA): Only use + __attribute__((visibility)) if HAVE_ATTRIBUTE_VISIBILITY. + 2013-11-22 Rainer Orth * configure.ac (AC_PROG_CXX): Move after AC_PROG_CC. diff --git a/libcilkrts/configure b/libcilkrts/configure index c510e14c717..d60ac410a83 100644 --- a/libcilkrts/configure +++ b/libcilkrts/configure @@ -4874,6 +4874,33 @@ _ACEOF fi +# Check whether the target supports protected visibility. +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void __attribute__((visibility("protected"))) foo(void) { } +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libcilkrts_cv_have_attribute_visibility=yes +else + libcilkrts_cv_have_attribute_visibility=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +if test $libcilkrts_cv_have_attribute_visibility = yes; then + +$as_echo "#define HAVE_ATTRIBUTE_VISIBILITY 1" >>confdefs.h + +fi + # Get target configury. . ${srcdir}/configure.tgt if test -n "$UNSUPPORTED"; then @@ -11060,7 +11087,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11063 "configure" +#line 11090 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11166,7 +11193,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11169 "configure" +#line 11196 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/libcilkrts/configure.ac b/libcilkrts/configure.ac index 0332d9c552d..84588db4224 100644 --- a/libcilkrts/configure.ac +++ b/libcilkrts/configure.ac @@ -54,6 +54,18 @@ AC_CONFIG_FILES([Makefile]) AM_ENABLE_MULTILIB(, ..) AC_FUNC_ALLOCA +# Check whether the target supports protected visibility. +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror" +AC_TRY_COMPILE([void __attribute__((visibility("protected"))) foo(void) { }], + [], libcilkrts_cv_have_attribute_visibility=yes, + libcilkrts_cv_have_attribute_visibility=no) +CFLAGS="$save_CFLAGS" +if test $libcilkrts_cv_have_attribute_visibility = yes; then + AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1, + [Define to 1 if the target supports __attribute__((visibility(...))).]) +fi + # Get target configury. . ${srcdir}/configure.tgt if test -n "$UNSUPPORTED"; then diff --git a/libcilkrts/include/cilk/common.h b/libcilkrts/include/cilk/common.h index 8ec19afa922..d2c84fa95a2 100644 --- a/libcilkrts/include/cilk/common.h +++ b/libcilkrts/include/cilk/common.h @@ -101,7 +101,7 @@ namespace cilk { # define CILK_EXPORT /* nothing */ # define CILK_EXPORT_DATA /* nothing */ #else /* Unix/gcc */ -# ifdef IN_CILK_RUNTIME +# if defined(IN_CILK_RUNTIME) && defined(HAVE_ATTRIBUTE_VISIBILITY) # define CILK_EXPORT __attribute__((visibility("protected"))) # define CILK_EXPORT_DATA __attribute__((visibility("protected"))) # else