1
1

configury: ensure wrapper static LIBS is filled properly

In core library portions of the configury (e.g., top-level
configure.ac itself), we were calling AC_CHECK_LIB and
OPAL_CHECK_FUNC_LIB to check for various libraries.

'''SIDENOTE:''' It turns out that modern Autoconf has AC_SEARCH_LIBS,
which does just about exactly what OPAL_CHECK_FUNC_LIB does.  So this
commit effectively replaces OPAL_CHECK_FUNC_LIB with AC_SEARCH_LIBS.

However, we never bothered to add these found libraries to the wrapper
compiler list of libraries used for static linking (doh!).  We've been
getting lucky for quite a while that components were adding the same
libraries to their wrapper compiler LIBS list.  

This is problematic, however, if we don't build some of these
components.  For example, Paul Hargrove noticed that if he configured
with --disable-shared --enable-static --disable-io-romio, ROMIO was no
longer adding some libraries to the wrapper LIBS list -- libraries
that just happened to also be needed by core OPAL/ORTE/OMPI layers.

The solution is not to use AC_CHECK_LIB or OPAL_CHECK_FUNC_LIB, but
use a pair of new macros:

 * OPAL_SEARCH_LIBS_CORE: a wrapper around AC_SEARCH_LIBS.  If we add
   something to $LIBS, then also add it to the wrapper list of static
   libraries.  This is the main piece of functionality that was
   wrong/missing.
 * OPAL_SEARCH_LIBS_COMPONENT: similar to OPAL_SEARCH_LIBS_CORE, but
   instead of directly adding it to the wrapper list of static
   libaries, add it to <framework>_<component>_LIBS (which eventually
   gets slurped up into the wrapper list of static libraries.  See the
   lengthy comment in config/opal_setup_wrappers.m4 near the beginning
   of OPAL_SETUP_WRAPPER_INIT() for a more detailed explanation).
   Most components did this correctly already, but one or two weren't
   right, so I implemented this second macro quite similar to the
   first and put it everywhere we already used AC_SEARCH_LIBS or
   OPAL_CHECK_FUNC_LIB.

This needs to soak for a day or two on the trunk before moving to the
v1.8 branch.

Refs trac:4834

cmr=v1.8.2:reviewer=ggouaillardet

This commit was SVN r32447.

The following Trac tickets were found above:
  Ticket 4834 --> https://svn.open-mpi.org/trac/ompi/ticket/4834
Этот коммит содержится в:
Jeff Squyres 2014-08-07 23:54:45 +00:00
родитель 79f517941c
Коммит c6d9bf906e
7 изменённых файлов: 80 добавлений и 68 удалений

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

@ -1,51 +0,0 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2013 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
# OPAL_CHECK_FUNC_LIB(func, lib, [action-if-found], [action-if-not-found])
# ------------------------------
# Try to find function func, first with the present LIBS, second with
# lib added to LIBS. If func is found with the libraries listed in
# LIBS, no modification to LIBS is made. If func is in lib (but not
# in LIBS) then lib is added to LIBS. If func is not in lib, then
# LIBS is not modified.
AC_DEFUN([OPAL_CHECK_FUNC_LIB],[
OPAL_VAR_SCOPE_PUSH([LIBS_save])
AS_VAR_PUSHDEF([opal_var], [opal_cv_func_lib_$1_$2])dnl
AC_CACHE_CHECK([if we need -l$2 for $1],
opal_var,
[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
[AS_VAR_SET(opal_var, "no")],
[LIBS_save="$LIBS"
LIBS="$LIBS -l$2"
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
[AS_VAR_SET(opal_var, "yes")],
[AS_VAR_SET(opal_var, "not found")])
LIBS="$LIBS_save"])])
AS_VAR_IF(opal_var, [yes],
[LIBS="$LIBS -l$2"])
# see if we actually have $1. Use AC_CHECK_FUNCS so that it
# does the glibc "not implemented" check. Will use the current LIBS,
# so will check in -l$2 if we decided we needed it above
AC_CHECK_FUNCS([$1], $3, $4)
AS_VAR_POPDEF([opal_var])dnl
OPAL_VAR_SCOPE_POP
])

61
config/opal_search_libs.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,61 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2013-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
# OPAL SEARCH_LIBS_CORE(func, list-of-libraries,
# action-if-found, action-if-not-found,
# other-libraries)
#
# Wrapper around AC SEARCH_LIBS. If a library ends up being added to
# $LIBS, then also add it to the wrapper LIBS list (so that it is
# added to the link command line for the static link case).
#
# NOTE: COMPONENTS SHOULD NOT USE THIS MACRO! Components should use
# OPAL_SEARCH_LIBS_COMPONENT. The reason why is because this macro
# calls OPAL_WRAPPER_FLAGS_ADD -- see big comment in
# opal_setup_wrappers.m4 for an explanation of why this is bad).
AC_DEFUN([OPAL_SEARCH_LIBS_CORE],[
OPAL_VAR_SCOPE_PUSH(LIBS_save add)
LIBS_save=$LIBS
AC_SEARCH_LIBS([$1], [$2],
[ # Found it! See if anything was added to LIBS
add=`echo $LIBS | sed -e "s/$LIBS_save$//"`
if test "x$add" != "x"; then
OPAL_WRAPPER_FLAGS_ADD([LIBS], [$add])
fi
$3],
[$4], [$5])
OPAL_VAR_SCOPE_POP
])dnl
# OPAL SEARCH_LIBS_COMPONENT(prefix, func, list-of-libraries,
# action-if-found, action-if-not-found,
# other-libraries)
#
# Same as OPAL SEARCH_LIBS_CORE, above, except that we don't call OPAL
# WRAPPER_FLAGS_ADD. Instead, we add it to the ${prefix}_LIBS
# variable (i.e., $prefix is usually "framework_component", such as
# "fbtl_posix").
AC_DEFUN([OPAL_SEARCH_LIBS_COMPONENT],[
OPAL_VAR_SCOPE_PUSH(LIBS_save add)
LIBS_save=$LIBS
AC_SEARCH_LIBS([$2], [$3],
[ # Found it! See if anything was added to LIBS
add=`echo $LIBS | sed -e "s/$LIBS_save$//"`
if test "x$add" != "x"; then
OPAL_FLAGS_APPEND_UNIQ($1_LIBS, [$add])
fi
$4],
[$5], [$6])
OPAL_VAR_SCOPE_POP
])dnl

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

@ -860,20 +860,20 @@ AC_CACHE_SAVE
opal_show_title "Library and Function tests"
# Darwin doesn't need -lutil, as it's something other than this -lutil.
OPAL_CHECK_FUNC_LIB([openpty], [util])
OPAL_SEARCH_LIBS_CORE([openpty], [util])
AC_CHECK_LIB([nsl], [gethostbyname])
OPAL_SEARCH_LIBS_CORE([nsl], [gethostbyname])
AC_CHECK_LIB([socket], [socket])
OPAL_SEARCH_LIBS_CORE([socket], [socket])
# Solaris has sched_yield in -lrt, usually in libc
OPAL_CHECK_FUNC_LIB([sched_yield], [rt])
OPAL_SEARCH_LIBS_CORE([sched_yield], [rt])
# IRIX has dirname in -lgen, usually in libc
OPAL_CHECK_FUNC_LIB([dirname], [gen])
OPAL_SEARCH_LIBS_CORE([dirname], [gen])
# Darwin doesn't need -lm, as it's a symlink to libSystem.dylib
OPAL_CHECK_FUNC_LIB([ceil], [m])
OPAL_SEARCH_LIBS_CORE([ceil], [m])
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty getpwuid fork waitpid execve pipe ptsname setsid mmap tcgetpgrp posix_memalign strsignal sysconf syslog vsyslog regcmp regexec regfree _NSGetEnviron socketpair strncpy_s _strdup usleep mkfifo dbopen dbm_open statfs statvfs setpgid])

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

@ -28,8 +28,9 @@ AC_DEFUN([MCA_ompi_fbtl_posix_CONFIG],[
fbtl_posix_happy=no
AC_CHECK_HEADER([aio.h],
[dnl NetBSD has aio_* in -lrt, vs. the usual libc
OPAL_CHECK_FUNC_LIB([aio_write], [rt],
[fbtl_posix_happy="yes"])])
OPAL_SEARCH_LIBS_COMPONENT([fbtl_posix],
[aio_write], [rt],
[fbtl_posix_happy="yes"])])
AS_IF([test "$fbtl_posix_happy" = "yes"],
[$1],

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

@ -10,7 +10,7 @@
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -33,9 +33,9 @@ AC_DEFUN([MCA_opal_backtrace_execinfo_CONFIG],[
AC_CHECK_HEADERS([execinfo.h])
# FreeBSD has backtrace in -lexecinfo, usually in libc
OPAL_CHECK_FUNC_LIB([backtrace], [execinfo],
[backtrace_execinfo_happy="yes"],
[backtrace_execinfo_happy="no"])
OPAL_SEARCH_LIBS_COMPONENT([backtrace_execinfo], [backtrace], [execinfo],
[backtrace_execinfo_happy="yes"],
[backtrace_execinfo_happy="no"])
AS_IF([test "$backtrace_execinfo_happy" = "yes"],
[$1], [$2])

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

@ -8,7 +8,7 @@
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2006 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
# $COPYRIGHT$
#
@ -127,7 +127,7 @@ AC_DEFUN([MCA_opal_crs_blcr_CONFIG],[
#
crs_blcr_have_working_cr_request=0
AC_MSG_CHECKING(for BLCR working cr_request)
OPAL_CHECK_FUNC_LIB([cr_request_file],[cr],
OPAL_SEARCH_LIBS_COMPONENT([crs_blcr], [cr_request_file],[cr],
[AC_TRY_COMPILE([#include <libcr.h>],
[#if CR_RELEASE_MAJOR <= 0 && CR_RELEASE_MINOR < 6
#error Version earlier than 0.6.0
@ -149,7 +149,8 @@ AC_DEFUN([MCA_opal_crs_blcr_CONFIG],[
#
crs_blcr_have_cr_request_checkpoint=0
AC_MSG_CHECKING(for BLCR cr_request_checkpoint)
OPAL_CHECK_FUNC_LIB([cr_request_checkpoint],[cr],
OPAL_SEARCH_LIBS_COMPONENT([crs_blcr],
[cr_request_checkpoint],[cr],
[crs_blcr_have_cr_request_checkpoint=1
],
[crs_blcr_have_cr_request_checkpoint=0

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

@ -10,7 +10,7 @@
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2010-2011 Los Alamos National Security, LLC.
# All rights reserved.
# $COPYRIGHT$
@ -35,7 +35,7 @@ AC_DEFUN([MCA_opal_shmem_posix_CONFIG],[
[AC_MSG_RESULT([no])
shmem_posix_sm_build_posix=0],
[AC_MSG_RESULT([yes])
AC_SEARCH_LIBS([shm_open], [rt],
OPAL_SEARCH_LIBS_COMPONENT([shmem_posix], [shm_open], [rt],
[shmem_posix_sm_build_posix=1],
[shmem_posix_sm_build_posix=0])])
AS_IF([test "$enable_posix_shmem" = "yes" -a "$shmem_posix_sm_build_posix" = "0"],