[Mesa-dev] [PATCH] configure: simplify visibility compiler flag detection

Sedat Dilek sedat.dilek at gmail.com
Sun Mar 1 10:37:01 PST 2015


On Sun, Mar 1, 2015 at 7:30 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Sun, Mar 1, 2015 at 6:09 AM, Marc Dietrich <marvin24 at gmx.de> wrote:
>> This patch simplifies the visibility compiler flag detection in configure and
>> makes it more generic to also support compilers other than gcc.
>
> This simplification relies on the assumption that compilers support
> -fvisibility=... if and only if they support
> attribute(visibility("...")).
>
> I guess that might be the case, but the logic doesn't seem very sound.
>
> Is the 'if test "x$GCC" = xyes; then' test actually rejecting clang?
> It doesn't seem so, since above there's a 'if test "x$GCC" = xyes -a
> "x$acv_mesa_CLANG" = xno; then'
>
> So, I guess it looks to me like we already support visibility
> detection for !gcc.
>

This simplified patch does not work as expected with 2/2 v3 (see [1]).
It breaks my build with mesa v10.4.5.

- Sedat -

[1] http://patchwork.freedesktop.org/patch/42679/

>>
>> Cc: Emil Velikov <emil.l.velikov at gmail.com>
>> Signed-off-by: Marc Dietrich <marvin24 at gmx.de>
>>
>> ---
>>  configure.ac | 32 +++++++-------------------------
>>  1 file changed, 7 insertions(+), 25 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 5fbb7bc..7565c0c 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)
>>
>> @@ -223,6 +224,12 @@ cygwin*)
>>      ;;
>>  esac
>>
>> +# 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"
>
> Indent these the same amount as elsewhere.
>
>> +fi
>> +
>>  dnl Add flags for gcc and g++
>>  if test "x$GCC" = xyes; then
>>      CFLAGS="$CFLAGS -Wall"
>> @@ -245,18 +252,6 @@ if test "x$GCC" = xyes; then
>>                    AC_MSG_RESULT([yes]),
>>                    [CFLAGS="$save_CFLAGS -Wmissing-prototypes";
>>                     AC_MSG_RESULT([no])]);
>> -
>> -    # Enable -fvisibility=hidden if using a gcc that supports it
>> -    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
>> -
>>      # Work around aliasing bugs - developers should comment this out
>>      CFLAGS="$CFLAGS -fno-strict-aliasing"
>>
>> @@ -267,19 +262,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"
>>
>> --
>> 2.3.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list