1
1

Fix a few problems with the compiler visibility test:

* Update to be safe for AC 2.68 by using AC_LINK_IFELSE instead of
   AC_TRY_LINK
 * If enable visibility was used, ensure we fail if the compiler
   doesn't support it
 * Rename OMPI_CHECK_VISIBILITY -> OPAL_CHECK_VISIBILITY (and all
   internal variables)

This commit was SVN r23923.
Этот коммит содержится в:
Jeff Squyres 2010-10-23 14:32:44 +00:00
родитель 8a37b3071a
Коммит 8ffb046649
2 изменённых файлов: 32 добавлений и 35 удалений

Просмотреть файл

@ -1009,7 +1009,7 @@ AC_CACHE_SAVE
# the visibility feature. # the visibility feature.
ompi_show_title "Symbol visibility feature" ompi_show_title "Symbol visibility feature"
OMPI_CHECK_VISIBILITY OPAL_CHECK_VISIBILITY

Просмотреть файл

@ -10,7 +10,7 @@
# University of Stuttgart. All rights reserved. # University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California. # Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved. # All rights reserved.
# Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. # Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$ # $COPYRIGHT$
# #
@ -19,19 +19,18 @@
# $HEADER$ # $HEADER$
# #
# OPAL_CHECK_VISIBILITY
# OMPI_CHECK_VISIBILITY
# -------------------------------------------------------- # --------------------------------------------------------
AC_DEFUN([OMPI_CHECK_VISIBILITY],[ AC_DEFUN([OPAL_CHECK_VISIBILITY],[
AC_REQUIRE([AC_PROG_GREP]) AC_REQUIRE([AC_PROG_GREP])
# Check if the compiler has support for visibility, like some versions of gcc, icc Sun Studio cc. # Check if the compiler has support for visibility, like some versions of gcc, icc Sun Studio cc.
AC_ARG_ENABLE(visibility, AC_ARG_ENABLE(visibility,
AC_HELP_STRING([--enable-visibility], AC_HELP_STRING([--enable-visibility],
[enable visibility feature of certain compilers/linkers (default: enabled)])) [enable visibility feature of certain compilers/linkers (default: enabled)]))
if test "$enable_visibility" = "no" -o "$opal_cv___attribute__visibility" = "0"; then if test "$enable_visibility" = "no"; then
AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_CHECKING([whether to enable symbol visibility])
AC_MSG_RESULT([no]) AC_MSG_RESULT([no (disabled)])
have_visibility=0 have_visibility=0
else else
CFLAGS_orig="$CFLAGS" CFLAGS_orig="$CFLAGS"
@ -40,71 +39,69 @@ AC_DEFUN([OMPI_CHECK_VISIBILITY],[
# check using gcc -fvisibility=hidden flag # check using gcc -fvisibility=hidden flag
CFLAGS="$CFLAGS_orig -fvisibility=hidden" CFLAGS="$CFLAGS_orig -fvisibility=hidden"
AC_CACHE_CHECK([if $CC supports -fvisibility], AC_CACHE_CHECK([if $CC supports -fvisibility],
[ompi_cv_cc_fvisibility], [opal_cv_cc_fvisibility],
[AC_TRY_LINK([ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
__attribute__((visibility("default"))) int foo; __attribute__((visibility("default"))) int foo;
void bar(void) { fprintf(stderr, "bar\n"); } ]],[[int i;]])],
],[], [opal_cv_cc_fvisibility=yes],
[if test -s conftest.err ; then [if test -s conftest.err ; then
$GREP -iq "visibility" conftest.err $GREP -iq "visibility" conftest.err
if test "$?" = "0" ; then if test "$?" = "0" ; then
ompi_cv_cc_fvisibility="no" opal_cv_cc_fvisibility=no
else else
ompi_cv_cc_fvisibility="yes" opal_cv_cc_fvisibility=yes
fi fi
else else
ompi_cv_cc_fvisibility="yes" opal_cv_cc_fvisibility=yes
fi], fi],
[ompi_cv_cc_fvisibility="no"]) [opal_cv_cc_fvisibility=no])
]) ])
if test "$ompi_c_vendor" = "sun" ; then if test "$ompi_c_vendor" = "sun" ; then
# Check using Sun Studio -xldscope=hidden flag # Check using Sun Studio -xldscope=hidden flag
CFLAGS="$CFLAGS_orig -xldscope=hidden" CFLAGS="$CFLAGS_orig -xldscope=hidden"
AC_CACHE_CHECK([if $CC supports -xldscope], AC_CACHE_CHECK([if $CC supports -xldscope],
[ompi_cv_cc_xldscope], [opal_cv_cc_xldscope],
[AC_TRY_LINK([ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
__attribute__((visibility("default"))) int foo; __attribute__((visibility("default"))) int foo;
void bar(void) { fprintf(stderr, "bar\n"); } ]],[[int i;]])],
],[], [opal_cv_cc_fvisibilty=yes],
[if test -s conftest.err ; then [if test -s conftest.err ; then
$GREP -iq "visibility" conftest.err $GREP -iq "visibility" conftest.err
if test "$?" = "0" ; then if test "$?" = "0" ; then
ompi_cv_cc_xldscope="no" opal_cv_cc_xldscope="no"
else else
ompi_cv_cc_xldscope="yes" opal_cv_cc_xldscope="yes"
fi fi
else else
ompi_cv_cc_xldscope="yes" opal_cv_cc_xldscope="yes"
fi], fi],
[ompi_cv_cc_xldscope="no"]) [opal_cv_cc_xldscope="no"])
]) ])
fi fi
if test "$ompi_cv_cc_fvisibility" = "yes" ; then if test "$opal_cv_cc_fvisibility" = "yes" ; then
add=" -fvisibility=hidden" add=" -fvisibility=hidden"
have_visibility=1 have_visibility=1
AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_CHECKING([whether to enable symbol visibility])
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes (via$add)])
AC_MSG_WARN([$add has been added to CFLAGS]) AC_MSG_WARN([$add has been added to CFLAGS])
elif test "$ompi_cv_cc_xldscope" = "yes" ; then elif test "$opal_cv_cc_xldscope" = "yes" ; then
add=" -xldscope=hidden" add=" -xldscope=hidden"
have_visibility=1 have_visibility=1
AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_CHECKING([whether to enable symbol visibility])
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes (via$add)])
AC_MSG_WARN([$add has been added to CFLAGS]) AC_MSG_WARN([$add has been added to CFLAGS])
elif test "$enable_visibility" = "yes"; then elif test "$enable_visibility" = "yes"; then
AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting]) AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting])
else else
AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_CHECKING([whether enable symbol visibility])
AC_MSG_RESULT([no]) AC_MSG_RESULT([no (unsupported)])
have_visibility=0 have_visibility=0
fi fi
CFLAGS="$CFLAGS_orig$add" CFLAGS="$CFLAGS_orig$add"
OPAL_VISIBILITY_CFLAGS="$add" OPAL_VISIBILITY_CFLAGS="$add"
unset add unset add
fi fi
AC_DEFINE_UNQUOTED([OPAL_C_HAVE_VISIBILITY], [$have_visibility], AC_DEFINE_UNQUOTED([OPAL_C_HAVE_VISIBILITY], [$have_visibility],
[Whether C compiler supports -fvisibility]) [Whether C compiler supports -fvisibility])
]) ])