[Mesa-dev] [PATCH 2/2] Don't use -fvisibilty=hidden on cygwin

Dan Nicholson dbn.lists at gmail.com
Wed Apr 27 03:39:18 PDT 2011


On Tue, Apr 26, 2011 at 5:00 AM, Jon TURNEY <jon.turney at dronecode.org.uk> wrote:
> Using -fvisibility=hidden makes the current cygwin gcc emit a warning
> "warning: visibility attribute not supported in this configuration; ignored"
> for every single non-static symbol
>
> $ make clean && make 2>&1 | grep "ignored" | wc -l
> 6457
>
> This is pretty annoying and makes it hard to spot other errors and warnings
> in the compiler output.
>
> It's not clear how to fix this.  Possibly the correct solution is explicitly
> decorate all symbols with macros which annotate the expected visibility and
> evaluate to attribute(hidden/default) or dllexport depending on the target,
> as suggested at [1], but this would be a lot of work and misses the main
> advantage of -fvisibility=hidden (that you don't have to explicitly annotate
> everything :-)), so I guess we are supposed to know when -fvisibility isn't
> going to be useful and not use it.
>
> [1] http://gcc.gnu.org/wiki/Visibility
>
> Alternatively, the configuration check could be made more complex to avoid
> using this flag is the target isn't ELF or using the flag generates a warning

You could add -Werror to the CFLAGS used for the visibility test since
any host that's throwing warnings for something so simple probably has
issues with visibility. Something like:

diff --git a/configure.ac b/configure.ac
index 8989c2b..ec662a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,7 +152,7 @@ if test "x$GCC" = xyes; then
     save_CFLAGS="$CFLAGS"
     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
     VISIBILITY_CFLAGS="-fvisibility=hidden"
-    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
+    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS -Werror"
     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
                   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);

Does that do the right thing?

--
Dan


More information about the mesa-dev mailing list