On Tue, Feb 17, 2015 at 11:00 AM, Sedat Dilek <sedat.di...@gmail.com> wrote:
> On Tue, Feb 17, 2015 at 10:40 AM, Marc Dietrich <marvi...@gmx.de> wrote:
>> This adds clang/gcc visibility macro detection to configure and 
>> util/macros.h.
>> This is can be used to conveniently add e.g. a "HIDDEN" attribute to a 
>> function.
>>
>> Signed-off-by: Marc Dietrich <marvi...@gmx.de>
>> ---
>> v2: use VISIBILITY_*FLAGS instead of *FLAGS directly
>> v3: no change
>>
>>  configure.ac      | 28 ++++++----------------------
>>  src/util/macros.h |  6 ++++++
>>  2 files changed, 12 insertions(+), 22 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 351027b..266764a 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -189,6 +189,7 @@ AX_GCC_FUNC_ATTRIBUTE([flatten])
>>  AX_GCC_FUNC_ATTRIBUTE([format])
>>  AX_GCC_FUNC_ATTRIBUTE([malloc])
>>  AX_GCC_FUNC_ATTRIBUTE([packed])
>> +AX_GCC_FUNC_ATTRIBUTE([visibility])
>>
>>  AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes)
>>
>> @@ -245,17 +246,13 @@ if test "x$GCC" = xyes; then
>>                    AC_MSG_RESULT([yes]),
>>                    [CFLAGS="$save_CFLAGS -Wmissing-prototypes";
>>                     AC_MSG_RESULT([no])]);
>> +    CFLAGS=$save_CFLAGS
>>
>>      # Enable -fvisibility=hidden if using a gcc that supports it
>
> Can you restore this comment with a general pointer to "...compiler
> that support it".
>
> BTW, what is the compiler option called for clang to suppress
> visibility(-hiden) feature - ... -fvisibility=no ?
> I would like to test w/o your patches.
>
> - Sedat -
>
>> -    save_CFLAGS="$CFLAGS"
>> -    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
>> -    VISIBILITY_CFLAGS="-fvisibility=hidden"
>> -    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
>> -    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
>> -                  [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
>> -
>> -    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
>> -    CFLAGS=$save_CFLAGS
>> +    if test "x${ax_cv_have_func_attribute_visibility}" = xyes; then
>> +       VISIBILITY_CFLAGS="-fvisibility=hidden"
>> +       VISIBILITY_CXXFLAGS="-fvisibility=hidden"
>> +    fi
>>
>>      # Work around aliasing bugs - developers should comment this out
>>      CFLAGS="$CFLAGS -fno-strict-aliasing"
>> @@ -267,19 +264,6 @@ fi
>>  if test "x$GXX" = xyes; then
>>      CXXFLAGS="$CXXFLAGS -Wall"
>>
>> -    # Enable -fvisibility=hidden if using a gcc that supports it
>> -    save_CXXFLAGS="$CXXFLAGS"
>> -    AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
>> -    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
>> -    CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
>> -    AC_LANG_PUSH([C++])
>> -    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
>> -                  [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
>> -    AC_LANG_POP([C++])
>> -
>> -    # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
>> -    CXXFLAGS=$save_CXXFLAGS
>> -
>>      # Work around aliasing bugs - developers should comment this out
>>      CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
>>
>> diff --git a/src/util/macros.h b/src/util/macros.h
>> index eec8b93..7682511 100644
>> --- a/src/util/macros.h
>> +++ b/src/util/macros.h
>> @@ -117,6 +117,12 @@ do {                       \
>>  #define PRINTFLIKE(f, a)
>>  #endif
>>
>> +#ifdef HAVE_FUNC_ATTRIBUTE_VISIBILITY
>> +#define HIDDEN __attribute__((visibility("hidden")))
>> +#else
>> +#define HIDDEN
>> +#endif
>> +
>>  #ifdef HAVE_FUNC_ATTRIBUTE_MALLOC
>>  #define MALLOCLIKE __attribute__((__malloc__))
>>  #else
>> --
>> 2.2.2
>>

Here the fix for the comment in visibility macro detection.

- Sedat -
From 25ae86da648c611c466a2167d1fbb3c85c0c1def Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.di...@gmail.com>
Date: Wed, 18 Feb 2015 05:59:26 +0100
Subject: [PATCH] configure: Fix comment in visibility macro detection

Fixes: "configure: add visibility macro detection to configure (v3)"
Signed-off-by: Sedat Dilek <sedat.di...@gmail.com>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 612473b8f77f..77e17d121e59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,7 +197,7 @@ if test "x$GCC" = xyes; then
 		    AC_MSG_RESULT([no])]);
     CFLAGS=$save_CFLAGS
 
-    # Enable -fvisibility=hidden if using a gcc that supports it
+    # Enable -fvisibility=hidden if using a compiler that supports it
     if test "x${ax_cv_have_func_attribute_visibility}" = xyes; then
 	VISIBILITY_CFLAGS="-fvisibility=hidden"
 	VISIBILITY_CXXFLAGS="-fvisibility=hidden"
-- 
2.3.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to