1
1

This commit fixes trac:2917. By using the cleaned up version of check_visibility that is in the hwloc trunk repo.

This commit was SVN r25495.

The following Trac tickets were found above:
  Ticket 2917 --> https://svn.open-mpi.org/trac/ompi/ticket/2917
Этот коммит содержится в:
Terry Dontje 2011-11-22 00:01:09 +00:00
родитель 1000af1c48
Коммит 1f53b32216
2 изменённых файлов: 133 добавлений и 110 удалений

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

@ -11,7 +11,7 @@
# 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-2010 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-2011 Oracle and/or its affiliates. All rights reserved.
# $COPYRIGHT$ # $COPYRIGHT$
# #
# Additional copyrights may follow # Additional copyrights may follow
@ -24,86 +24,83 @@
AC_DEFUN([OPAL_CHECK_VISIBILITY],[ AC_DEFUN([OPAL_CHECK_VISIBILITY],[
AC_REQUIRE([AC_PROG_GREP]) AC_REQUIRE([AC_PROG_GREP])
msg="whether to enable symbol visibility"
# Check if the compiler has support for visibility, like some # Check if the compiler has support for visibility, like some
# versions of gcc, icc Sun Studio cc. # 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"; then
AC_MSG_CHECKING([$msg])
AC_MSG_RESULT([no (disabled)])
have_visibility=0
else
CFLAGS_orig="$CFLAGS"
add=
# check using gcc -fvisibility=hidden flag opal_visibility_define=0
CFLAGS="$CFLAGS_orig -fvisibility=hidden" opal_msg="whether to enable symbol visibility"
AC_CACHE_CHECK([if $CC supports -fvisibility],
[opal_cv_cc_fvisibility], if test "$enable_visibility" = "no"; then
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ AC_MSG_CHECKING([$opal_msg])
__attribute__((visibility("default"))) int foo; AC_MSG_RESULT([no (disabled)])
]],[[int i;]])], else
[opal_cv_cc_fvisibility=yes], CFLAGS_orig=$CFLAGS
[if test -s conftest.err ; then
$GREP -iq "visibility" conftest.err opal_add=
if test "$?" = "0" ; then case "$ompi_c_vendor" in
opal_cv_cc_fvisibility=no sun)
else
opal_cv_cc_fvisibility=yes
fi
else
opal_cv_cc_fvisibility=yes
fi],
[opal_cv_cc_fvisibility=no])
])
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" opal_add="-xldscope=hidden"
AC_CACHE_CHECK([if $CC supports -xldscope], CFLAGS="$CFLAGS_orig $opal_add"
[opal_cv_cc_xldscope],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ AC_MSG_CHECKING([if $CC supports -xldscope])
__attribute__((visibility("default"))) int foo; AC_LINK_IFELSE([AC_LANG_PROGRAM([[
]],[[int i;]])], __attribute__((visibility("default"))) int foo;
[opal_cv_cc_fvisibilty=yes], ]],[[int i;]])],
[if test -s conftest.err ; then [],
$GREP -iq "visibility" conftest.err [AS_IF([test -s conftest.err],
if test "$?" = "0" ; then [$GREP -iq visibility conftest.err
opal_cv_cc_xldscope="no" # If we find "visibility" in the stderr, then
else # assume it doesn't work
opal_cv_cc_xldscope="yes" AS_IF([test "$?" = "0"], [opal_add=])])
fi ])
else AS_IF([test "$opal_add" = ""],
opal_cv_cc_xldscope="yes" [AC_MSG_RESULT([no])],
fi], [AC_MSG_RESULT([yes])])
[opal_cv_cc_xldscope="no"]) ;;
])
fi *)
if test "$opal_cv_cc_fvisibility" = "yes" ; then # Check using -fvisibility=hidden
add=" -fvisibility=hidden" opal_add=-fvisibility=hidden
have_visibility=1 CFLAGS="$CFLAGS_orig $opal_add"
AC_MSG_CHECKING([$msg])
AC_MSG_RESULT([yes (via$add)]) AC_MSG_CHECKING([if $CC supports -fvisibility])
AC_MSG_WARN([$add has been added to CFLAGS]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[
elif test "$opal_cv_cc_xldscope" = "yes" ; then __attribute__((visibility("default"))) int foo;
add=" -xldscope=hidden" ]],[[int i;]])],
have_visibility=1 [],
AC_MSG_CHECKING([$msg]) [AS_IF([test -s conftest.err],
AC_MSG_RESULT([yes (via$add)]) [$GREP -iq visibility conftest.err
AC_MSG_WARN([$add has been added to CFLAGS]) # If we find "visibility" in the stderr, then
# assume it doesn't work
AS_IF([test "$?" = "0"], [opal_add=])])
])
AS_IF([test "$opal_add" = ""],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])])
;;
esac
CFLAGS=$CFLAGS_orig
OPAL_VISIBILITY_CFLAGS=$opal_add
if test "$opal_add" != "" ; then
opal_visibility_define=1
AC_MSG_CHECKING([$opal_msg])
AC_MSG_RESULT([yes (via $opal_add)])
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([$msg]) AC_MSG_CHECKING([$opal_msg])
AC_MSG_RESULT([no (unsupported)]) AC_MSG_RESULT([no (unsupported)])
have_visibility=0
fi fi
CFLAGS="$CFLAGS_orig$add" unset opal_add
OPAL_VISIBILITY_CFLAGS="$add"
unset add
fi fi
AC_DEFINE_UNQUOTED([OPAL_C_HAVE_VISIBILITY], [$have_visibility], AC_DEFINE_UNQUOTED([OPAL_C_HAVE_VISIBILITY], [$opal_visibility_define],
[Whether C compiler supports -fvisibility]) [Whether C compiler supports symbol visibility or not])
]) ])

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

@ -14,6 +14,7 @@
# Copyright (c) 2009 INRIA. All rights reserved. # Copyright (c) 2009 INRIA. All rights reserved.
# Copyright (c) 2009-2010 Université Bordeaux 1 # Copyright (c) 2009-2010 Université Bordeaux 1
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
# See COPYING in top-level directory. # See COPYING in top-level directory.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -60,7 +61,6 @@ AC_DEFUN([_HWLOC_CHECK_VISIBILITY],[
[AC_REQUIRE([AC_PROG_GREP])], [AC_REQUIRE([AC_PROG_GREP])],
[GREP=grep]) [GREP=grep])
msg="whether to enable visibility"
# Check if the compiler has support for visibility, like some # Check if the compiler has support for visibility, like some
# versions of gcc, icc. # versions of gcc, icc.
AC_ARG_ENABLE(visibility, AC_ARG_ENABLE(visibility,
@ -73,50 +73,76 @@ AC_DEFUN([_HWLOC_CHECK_VISIBILITY],[
;; ;;
esac esac
hwloc_visibility_define=0
hwloc_msg="whether to enable symbol visibility"
if test "$enable_visibility" = "no"; then if test "$enable_visibility" = "no"; then
AC_MSG_CHECKING([$msg]) AC_MSG_CHECKING([$hwloc_msg])
AC_MSG_RESULT([no (disabled)]) AC_MSG_RESULT([no (disabled)])
have_visibility=0
else else
CFLAGS_orig="$CFLAGS" CFLAGS_orig=$CFLAGS
CFLAGS="$CFLAGS_orig -fvisibility=hidden"
hwloc_add= hwloc_add=
AC_CACHE_CHECK([if $CC supports -fvisibility], case "$ompi_c_vendor" in
[hwloc_cv_cc_fvisibility], sun)
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ # Check using Sun Studio -xldscope=hidden flag
__attribute__((visibility("default"))) int foo; hwloc_add="-xldscope=hidden"
]],[[int i;]])], CFLAGS="$CFLAGS_orig $hwloc_add"
[hwloc_cv_cc_fvisibility=yes],
[if test -s conftest.err ; then AC_MSG_CHECKING([if $CC supports -xldscope])
$GREP -iq "visibility" conftest.err AC_LINK_IFELSE([AC_LANG_PROGRAM([[
if test "$?" = "0" ; then __attribute__((visibility("default"))) int foo;
hwloc_cv_cc_fvisibility=no ]],[[int i;]])],
else [],
hwloc_cv_cc_fvisibility=yes [AS_IF([test -s conftest.err],
fi [$GREP -iq visibility conftest.err
else # If we find "visibility" in the stderr, then
hwloc_cv_cc_fvisibility=yes # assume it doesn't work
fi], AS_IF([test "$?" = "0"], [hwloc_add=])])
[hwloc_cv_cc_fvisibility=no]) ])
]) AS_IF([test "$hwloc_add" = ""],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])])
;;
*)
# Check using -fvisibility=hidden
hwloc_add=-fvisibility=hidden
CFLAGS="$CFLAGS_orig $hwloc_add"
AC_MSG_CHECKING([if $CC supports -fvisibility])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
__attribute__((visibility("default"))) int foo;
]],[[int i;]])],
[],
[AS_IF([test -s conftest.err],
[$GREP -iq visibility conftest.err
# If we find "visibility" in the stderr, then
# assume it doesn't work
AS_IF([test "$?" = "0"], [hwloc_add=])])
])
AS_IF([test "$hwloc_add" = ""],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])])
;;
esac
if test "$hwloc_cv_cc_fvisibility" = "yes" ; then
hwloc_add=" -fvisibility=hidden"
have_visibility=1
AC_MSG_CHECKING([$msg])
AC_MSG_RESULT([yes (via$hwloc_add)])
elif test "$enable_visibility" = "yes"; then
AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting])
else
AC_MSG_CHECKING([$msg])
AC_MSG_RESULT([no (unsupported)])
have_visibility=0
fi
CFLAGS=$CFLAGS_orig CFLAGS=$CFLAGS_orig
HWLOC_VISIBILITY_CFLAGS=$hwloc_add HWLOC_VISIBILITY_CFLAGS=$hwloc_add
unset hwloc_add
if test "$hwloc_add" != "" ; then
hwloc_visibility_define=1
AC_MSG_CHECKING([$hwloc_msg])
AC_MSG_RESULT([yes (via $hwloc_add)])
elif test "$enable_visibility" = "yes"; then
AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting])
else
AC_MSG_CHECKING([$hwloc_msg])
AC_MSG_RESULT([no (unsupported)])
fi
unset hwloc_add
fi fi
AC_DEFINE_UNQUOTED([HWLOC_C_HAVE_VISIBILITY], [$have_visibility], AC_DEFINE_UNQUOTED([HWLOC_C_HAVE_VISIBILITY], [$hwloc_visibility_define],
[Whether C compiler supports -fvisibility]) [Whether C compiler supports symbol visibility or not])
]) ])