diff --git a/ChangeLog b/ChangeLog index 6de45d781..7719d798d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-10-25 Richard Frith-Macdonald + + * configure.ac: Define HAVE_VISIBILITY_ATTRIBUTE if gcc's visibility + attribute is both present in the version being used and working on + the current platform. + * configure: Regenerate + * Headers/Additions/GNUstepBase/config.h.in: Regenerate + * Source/GSPrivate.h: Only use the visibility attribute if it is + available. Avoids warnings (and link errors in at least one case) + on systems where it is not fully supported by gcc yet. + 2006-10-23 Richard Frith-Macdonald * Source/NSCalendarDate: when adding offset to a date, work in diff --git a/Headers/Additions/GNUstepBase/config.h.in b/Headers/Additions/GNUstepBase/config.h.in index 942326052..2b3194b54 100644 --- a/Headers/Additions/GNUstepBase/config.h.in +++ b/Headers/Additions/GNUstepBase/config.h.in @@ -378,6 +378,9 @@ /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF +/* Says whether the visibility attribute works */ +#undef HAVE_VISIBILITY_ATTRIBUTE + /* Define to 1 if you have the `vsprintf' function. */ #undef HAVE_VSPRINTF diff --git a/Source/GSPrivate.h b/Source/GSPrivate.h index f84a46ce0..e48fd2b95 100644 --- a/Source/GSPrivate.h +++ b/Source/GSPrivate.h @@ -28,7 +28,7 @@ @class NSNotification; -#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +#if ( (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) ) && defined(HAVE_VISIBILITY_ATTRIBUTE) ) #define GS_ATTRIB_PRIVATE __attribute__ ((visibility("internal"))) #else #define GS_ATTRIB_PRIVATE diff --git a/configure b/configure index c1724eba0..82b3794ab 100755 --- a/configure +++ b/configure @@ -4352,6 +4352,73 @@ else echo "${ECHO_T}not found" >&6; } fi +{ echo "$as_me:$LINENO: checking for gcc visibility attribute support" >&5 +echo $ECHO_N "checking for gcc visibility attribute support... $ECHO_C" >&6; } +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror" +cat >conftest.$ac_ext <<_ACEOF + + #include + int foo() __attribute__ ((visibility("internal"))); + int foo(){ return 1; } + int main(){ return foo(); } +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + { echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6; } + gs_visibility=1 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: not present" >&5 +echo "${ECHO_T}not present" >&6; } + gs_visibility=0 + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +cat >>confdefs.h <<_ACEOF +#define HAVE_VISIBILITY_ATTRIBUTE $gs_visibility +_ACEOF + +CFLAGS="$saved_CFLAGS" + + #-------------------------------------------------------------------- # Check if system has buggy SO_REUSEADDR #-------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 7e4ee0d52..19b8cb902 100644 --- a/configure.ac +++ b/configure.ac @@ -391,6 +391,24 @@ else AC_MSG_RESULT([not found]) fi +AC_MSG_CHECKING(for gcc visibility attribute support) +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror" +AC_COMPILE_IFELSE([ + #include + int foo() __attribute__ ((visibility("internal"))); + int foo(){ return 1; } + int main(){ return foo(); }], + AC_MSG_RESULT([found]) + gs_visibility=1, + AC_MSG_RESULT([not present]) + gs_visibility=0 +) +AC_DEFINE_UNQUOTED(HAVE_VISIBILITY_ATTRIBUTE,$gs_visibility, + [Says whether the visibility attribute works]) +CFLAGS="$saved_CFLAGS" + + #-------------------------------------------------------------------- # Check if system has buggy SO_REUSEADDR #--------------------------------------------------------------------