Changeset 4998

Show
Ignore:
Timestamp:
07/20/09 11:35:52 (4 months ago)
Author:
balaji
Message:

The build system was checking if the C compiler needs to link to
specific libraries (such as -lpthread, -lrt) to link programs
correctly and add them to LDFLAGS. These LDFLAGS were used for all the
compilers (C, C++, Fortran) in the bindings. However, if the C
compiler did not need these libraries to be explicitly linked, while
the remaining compilers did, this would break the build. This showed
up when using the NVIDIA CUDA compiler as the C compiler and gfortran
as the Fortran compiler.

This patch just checks if a library contains the required symbols and
adds it to the LDFLAGS. So, we might end up linking to the library
even if the compiler doesn't need it, but this is a safer solution.

Reviewed by goodell.

Location:
mpich2/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/confdb/aclocal_subcfg.m4

    r4763 r4998  
    1 dnl 
    21dnl PAC_MPICH2_INIT - Initialization routine for top-level mpich2 configure.in. 
    32dnl                   Call before invocation of mpich2's subpackage configure 
    4 dnl 
    53AC_DEFUN([PAC_MPICH2_INIT],[ 
    64# Exporting the MPICH2_INTERNAL_xFLAGS with modified xFLAGS 
    75# before calling subconfigure. 
    8 # Check if the env variable MPICH2_UNIQ_XFLAGS is set to no. 
    9 # MPICH2_UNIQ_XFLAGS is default to yes. It is a way to check 
    10 # if uniq'ed MPICH2_EXTRA_xFLAGS messes up xFLAGS. 
    11 pac_replace=${MPICH2_UNIQ_XFLAGS:-yes} 
    12 # Use user-supplied flags, WRAPPER_xFLAGS, and uniq'ed MPICH2_EXTRA_xFLAGS. 
    13     if test "$pac_replace" = "yes" ; then 
    14         CFLAGS="$WRAPPER_CFLAGS $MPICH2_EXTRA_CFLAGS" 
    15         CXXFLAGS="$WRAPPER_CXXFLAGS $MPICH2_EXTRA_CXXFLAGS" 
    16         FFLAGS="$WRAPPER_FFLAGS $MPICH2_EXTRA_FFLAGS" 
    17         F90FLAGS="$WRAPPER_F90FLAGS $MPICH2_EXTRA_F90FLAGS" 
    18     fi 
    196    MPICH2_INTERNAL_CFLAGS="$CFLAGS" 
    207    MPICH2_INTERNAL_CXXFLAGS="$CXXFLAGS" 
     
    2613    export MPICH2_INTERNAL_F90FLAGS 
    2714# Not sure if we need AC_SUBST(MPICH2_INTERNAL_xFLAGS) 
    28 ])dnl 
    29 dnl 
    30 dnl 
     15]) 
     16 
     17 
    3118dnl PAC_SUBCONFIG_INIT - Initialization routine for subpackge configure.in 
    3219dnl                      Called after AC_INIT before any of xFLAGS is accessed. 
    33 dnl 
    3420AC_DEFUN([PAC_SUBCONFIG_INIT],[ 
    3521# Initialize xFLAGS with MPICH2_INTERNAL_xFLAGS. 
     
    4026    F90FLAGS="$MPICH2_INTERNAL_F90FLAGS" 
    4127  fi 
    42 ])dnl 
    43 dnl 
    44 dnl Do we need PAC_SUBCONFIG_FINALIZE or PAC_MPICH2_FINALIZE ? 
    45 dnl  
     28]) 
     29 
     30 
    4631AC_DEFUN([PAC_SUBCONFIG_FINALIZE],[ 
    47 ])dnl 
     32]) 
     33 
    4834AC_DEFUN([PAC_MPICH2_FINALIZE],[ 
    49 ])dnl 
     35]) 
  • mpich2/trunk/configure.in

    r4993 r4998  
    280280    handle   - Trace handle operations 
    281281    handlealloc - Trace hancle allocations 
    282     dbg      - Add compiler flag, -g, to CFLAGS, CXXFLAGS FFLAGS and F90FLAGS. 
     282    dbg      - Add compiler flag, -g, to all internal 
     283               compiler flags, i.e. MPICH2LIB_CFLAGS, MPICH2LIB_CXXFLAGS, 
     284               MPICH2LIB_FFLAGS, and MPICH2LIB_F90FLAGS. 
    283285    debug    - Synonym for dbg 
    284286    log      - Enable debug event logging 
     
    318320    nochkmsg - No error checking, i.e. --disable-error-checking 
    319321    notiming - No timing collection, i.e. --disable-timing. 
    320     ndebug   - Appends -DNDEBUG to internal CFLAGS, i.e. MPICH2LIB_CFLAGS. 
     322    ndebug   - Appends -DNDEBUG to MPICH2LIB_CFLAGS. 
    321323    all|yes  - "defopt", "nochkmsg", "notiming" and "ndebug" are enabled 
    322324               when --enable-fast is specified without any option. 
     
    532534WRAPPER_FFLAGS=$FFLAGS 
    533535WRAPPER_F90FLAGS=$F90FLAGS 
    534 WRAPPER_LDFLAGS=$LDFLAGS 
    535536export WRAPPER_CFLAGS 
    536537export WRAPPER_CXXFLAGS 
    537538export WRAPPER_FFLAGS 
    538539export WRAPPER_F90FLAGS 
    539 export WRAPPER_LDFLAGS 
    540540 
    541541# ----------------------------------------------------------------------------- 
     
    12181218IFS="$save_IFS" 
    12191219 
    1220 # MPICH2_EXTRA_xFLAGS contains MPICH2LIB_xFLAGS and  
    1221 # all the extra compiler flags added by MPICH2. 
    1222 # Initial all MPICH2_EXTRA_xFLAGS to empty string. 
    1223 MPICH2_EXTRA_CFLAGS="" 
    1224 MPICH2_EXTRA_CXXFLAGS="" 
    1225 MPICH2_EXTRA_FFLAGS="" 
    1226 MPICH2_EXTRA_F90FLAGS="" 
    1227  
    12281220if test "$enable_append_g" = "yes" ; then 
    12291221    CFLAGS="$CFLAGS -g" 
     
    12311223    FFLAGS="$FFLAGS -g" 
    12321224    F90FLAGS="$F90FLAGS -g" 
    1233     MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS -g" 
    1234     MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS -g" 
    1235     MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS -g" 
    1236     MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS -g" 
    12371225fi 
    12381226if test "$enable_append_ndebug" = "yes" ; then 
     
    12411229    FFLAGS="$FFLAGS -DNDEBUG" 
    12421230    F90FLAGS="$F90FLAGS -DNDEBUG" 
    1243     MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS -DNDEBUG" 
    1244     MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS -DNDEBUG" 
    1245     MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS -DNDEBUG" 
    1246     MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS -DNDEBUG" 
    12471231fi 
    12481232if test -n "$perform_meminit" ; then 
     
    16341618PAC_CC_STRICT($enable_strict) 
    16351619if test -n "$pac_cc_strict_flags" ; then 
    1636     MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS $pac_cc_strict_flags" 
     1620    CFLAGS="$CFLAGS $pac_cc_strict_flags" 
    16371621fi 
    16381622# Check for whether the compiler defines a symbol that contains the  
     
    16511635        PAC_C_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_COPTS], [ 
    16521636        CFLAGS="$CFLAGS $MPI_DEFAULT_COPTS" 
    1653         MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS $MPI_DEFAULT_COPTS" 
    16541637                                   ] ) 
    16551638    else 
    16561639        CFLAGS="$CFLAGS $MPI_DEFAULT_COPTS" 
    1657         MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS $MPI_DEFAULT_COPTS" 
    1658     fi 
    1659 fi 
    1660 # Up till here, MPICH2_EXTRA_CFLAGS contains only flags added by MPICH2. 
    1661 # Check with "grep -n MPICH2_EXTRA_CFLAGS configure.in" 
    1662 # Remove duplicated flags from MPICH2_EXTRA_CFLAGS. 
    1663 PAC_MAKE_UNIQ_STRING([MPICH2_EXTRA_CFLAGS]) 
    1664 # Check if $MPICH2LIB_CFLAGS is valid with $CC 
    1665 if test -n "$MPICH2LIB_CFLAGS" ; then 
    1666     if test "$enable_check_compiler_flags" = "yes" ; then 
    1667         PAC_C_CHECK_COMPILER_OPTION( [$MPICH2LIB_CFLAGS], [ 
    1668         CFLAGS="$CFLAGS $MPICH2LIB_CFLAGS" 
    1669         MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS $MPICH2LIB_CFLAGS" 
    1670                                    ] ) 
    1671     else 
    1672         CFLAGS="$CFLAGS $MPICH2LIB_CFLAGS" 
    1673         MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS $MPICH2LIB_CFLAGS" 
    16741640    fi 
    16751641fi 
     
    17621728            PAC_F77_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_FOPTS], [ 
    17631729            FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS" 
    1764             MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS $MPI_DEFAULT_FOPTS" 
    17651730                                         ] ) 
    17661731        else 
    17671732            FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS" 
    1768             MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS $MPI_DEFAULT_FOPTS" 
    1769         fi 
    1770     fi 
    1771     # Up till here, MPICH2_EXTRA_FFLAGS contains only flags added by MPICH2. 
    1772     # Check with "grep -n MPICH2_EXTRA_FFLAGS configure.in" 
    1773     # Remove duplicated flags from MPICH2_EXTRA_FFLAGS. 
    1774     PAC_MAKE_UNIQ_STRING([MPICH2_EXTRA_FFLAGS]) 
    1775     # Check if $MPICH2LIB_FFLAGS is valid with $F77 
    1776     if test -n "$MPICH2LIB_FFLAGS" ; then 
    1777         if test "$enable_check_compiler_flags" = "yes" ; then 
    1778             PAC_F77_CHECK_COMPILER_OPTION( [$MPICH2LIB_FFLAGS], [ 
    1779             FFLAGS="$FFLAGS $MPICH2LIB_FFLAGS" 
    1780             MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS $MPICH2LIB_FFLAGS" 
    1781                                          ] ) 
    1782         else 
    1783             FFLAGS="$FFLAGS $MPICH2LIB_FFLAGS" 
    1784             MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS $MPICH2LIB_FFLAGS" 
    17851733        fi 
    17861734    fi 
     
    22632211            PAC_F90_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_F90OPTS], [ 
    22642212            F90FLAGS="$F90FLAGS $MPI_DEFAULT_F90OPTS" 
    2265             MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS $MPI_DEFAULT_F90OPTS" 
    22662213                                     ] ) 
    22672214        else 
    22682215            F90FLAGS="$F90FLAGS $MPI_DEFAULT_F90OPTS" 
    2269             MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS $MPI_DEFAULT_F90OPTS" 
    22702216        fi 
    22712217    fi 
    2272     # Up till here, MPICH2_EXTRA_F90FLAGS contains only flags added by MPICH2. 
    2273     # Check with "grep -n MPICH2_EXTRA_F90FLAGS configure.in" 
    2274     # Remove duplicated flags from MPICH2_EXTRA_F90FLAGS. 
    2275     PAC_MAKE_UNIQ_STRING([MPICH2_EXTRA_F90FLAGS]) 
    2276     # Check if $MPICH2LIB_F90FLAGS works with $F90 
    2277     if test -n "$MPICH2LIB_F90FLAGS" ; then 
    2278         if test "$enable_check_compiler_flags" = "yes" ; then 
    2279             PAC_F90_CHECK_COMPILER_OPTION( [$MPICH2LIB_F90FLAGS], [ 
    2280             F90FLAGS="$F90FLAGS $MPICH2LIB_F90FLAGS" 
    2281             MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS $MPICH2LIB_F90FLAGS" 
    2282                                      ] ) 
    2283         else 
    2284             F90FLAGS="$F90FLAGS $MPICH2LIB_F90FLAGS" 
    2285             MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS $MPICH2LIB_F90FLAGS" 
    2286         fi 
    2287     fi 
    2288  
    2289     # 
     2218 
    22902219    # Most systems allow the Fortran compiler to process .F and .F90 files 
    22912220    # using the C preprocessor.  However, some systems either do not 
     
    26962625            PAC_CXX_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_CXXOPTS], [ 
    26972626            CXXFLAGS="$CXXFLAGS $MPI_DEFAULT_CXXOPTS" 
    2698             MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS $MPI_DEFAULT_CXXOPTS" 
    26992627                                     ] ) 
    27002628        else 
    27012629            CXXFLAGS="$CXXFLAGS $MPI_DEFAULT_CXXOPTS" 
    2702             MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS $MPI_DEFAULT_CXXOPTS" 
    27032630        fi 
    27042631    fi 
    2705     # Up till here, MPICH2_EXTRA_CXXFLAGS contains only flags added by MPICH2. 
    2706     # Check with "grep -n MPICH2_EXTRA_CXXFLAGS configure.in" 
    2707     # Remove duplicated flags from MPICH2_EXTRA_CXXFLAGS. 
    2708     PAC_MAKE_UNIQ_STRING([MPICH2_EXTRA_CXXFLAGS]) 
    2709     # Check if $MPICH2LIB_CXXFLAGS is valid with $CXX 
    2710     if test -n "$MPICH2LIB_CXXFLAGS" ; then 
    2711         if test "$enable_check_compiler_flags" = "yes" ; then 
    2712             PAC_CXX_CHECK_COMPILER_OPTION( [$MPICH2LIB_CXXFLAGS], [ 
    2713             CXXFLAGS="$CXXFLAGS $MPICH2LIB_CXXFLAGS" 
    2714             MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS $MPICH2LIB_CXXFLAGS" 
    2715                                      ] ) 
    2716         else 
    2717             CXXFLAGS="$CXXFLAGS $MPICH2LIB_CXXFLAGS" 
    2718             MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS $MPICH2LIB_CXXFLAGS" 
    2719         fi 
    2720     fi 
    2721 fi 
    2722  
    2723 export MPICH2_EXTRA_CFLAGS 
    2724 export MPICH2_EXTRA_CXXFLAGS 
    2725 export MPICH2_EXTRA_FFLAGS 
    2726 export MPICH2_EXTRA_F90FLAGS 
     2632fi 
    27272633 
    27282634# Copy the mpicxx.h file to the main include directory 
     
    31873093PAC_C_VOLATILE 
    31883094PAC_C_RESTRICT 
    3189  
    3190 saveCFLAGS=$CFLAGS 
    3191 CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    31923095AC_C_INLINE 
    3193 CFLAGS=$saveCFLAGS 
    31943096 
    31953097PAC_C_GNU_ATTRIBUTE 
     
    50174919    if test "$ac_cv_prog_gcc" = "yes" ; then 
    50184920        CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" 
    5019         MPICH2_EXTRA_CFLAGS="$MPICH2_EXTRA_CFLAGS -fprofile-arcs -ftest-coverage" 
    50204921    else 
    50214922        AC_MSG_WARN([--enable-coverage only supported for GCC]) 
     
    50244925        if test "$ac_cv_cxx_compiler_gnu" = "yes" ; then 
    50254926            CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" 
    5026             MPICH2_EXTRA_CXXFLAGS="$MPICH2_EXTRA_CXXFLAGS -fprofile-arcs -ftest-coverage" 
    50274927        else 
    50284928            AC_MSG_WARN([--enable-coverage only supported for GCC]) 
     
    50344934        if test "$ac_cv_f77_compiler_gnu" = "yes" ; then 
    50354935             FFLAGS="$FFLAGS -fprofile-arcs -ftest-coverage" 
    5036              MPICH2_EXTRA_FFLAGS="$MPICH2_EXTRA_FFLAGS -fprofile-arcs -ftest-coverage" 
    50374936        else 
    50384937            AC_MSG_WARN([--enable-coverage only supported for G77/GFORTRAN]) 
     
    50424941        if test "$ac_cv_f90_compiler_gnu" = "yes" ; then 
    50434942             F90FLAGS="$F90FLAGS -fprofile-arcs -ftest-coverage" 
    5044              MPICH2_EXTRA_F90FLAGS="$MPICH2_EXTRA_F90FLAGS -fprofile-arcs -ftest-coverage" 
    50454943        else 
    50464944            AC_MSG_WARN([--enable-coverage only supported for GFORTRAN]) 
     
    51185016if test "$ac_cv_func_vsnprintf" = "yes" ; then 
    51195017    # vsnprintf may be declared in stdio.h and may need stdarg.h  
    5120     saveCFLAGS=$CFLAGS 
    5121     CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    51225018    PAC_FUNC_NEEDS_DECL([#include <stdio.h> 
    51235019#include <stdarg.h>],vsnprintf) 
    5124     CFLAGS=$saveCFLAGS 
    51255020fi 
    51265021# We would like to use strerror in the file namepublisher; it is also used 
     
    51315026AC_CHECK_FUNCS(snprintf) 
    51325027if test "$ac_cv_func_snprintf" = "yes" ; then 
    5133     saveCFLAGS=$CFLAGS 
    5134     CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    51355028    PAC_FUNC_NEEDS_DECL([#include <stdio.h>],snprintf) 
    5136     CFLAGS=$saveCFLAGS 
    51375029fi 
    51385030# if we are using stdarg, we may need va_copy .  Test to see if we have it 
     
    51435035# test in confdb/aclocal_cc.m4). 
    51445036AC_CACHE_CHECK([for va_copy],pac_cv_func_va_copy,[ 
    5145 saveCFLAGS=$CFLAGS 
    5146 CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    51475037AC_TRY_LINK([ 
    51485038#include <stdarg.h> 
     
    51555045} 
    51565046],[foo1("a test %d", 3);],pac_cv_func_va_copy=yes,pac_cv_func_va_copy=no)]) 
    5157 CFLAGS=$saveCFLAGS 
    51585047 
    51595048if test "$pac_cv_func_va_copy" = "yes" ; then 
     
    51615050else 
    51625051    AC_CACHE_CHECK([for __va_copy],pac_cv_func___va_copy,[ 
    5163     saveCFLAGS=$CFLAGS 
    5164     CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    51655052    AC_TRY_LINK([ 
    51665053#include <stdarg.h> 
     
    51735060} 
    51745061],[foo1("a test %d", 3);],pac_cv_func___va_copy=yes,pac_cv_func___va_copy=no)]) 
    5175     CFLAGS=$saveCFLAGS 
    51765062    if test "$pac_cv_func___va_copy" = "yes" ; then 
    51775063        AC_DEFINE(HAVE___VA_COPY,1,[Define if we have __va_copy]) 
     
    52095095    if test "$ac_cv_func_strdup" = "yes" ; then 
    52105096        # Do we need to declare strdup? 
    5211         saveCFLAGS=$CFLAGS 
    5212         CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    52135097        PAC_FUNC_NEEDS_DECL([#include <string.h>],strdup) 
    5214         CFLAGS=$saveCFLAGS 
    52155098    fi 
    52165099else 
     
    52435126AC_HAVE_FUNCS(mkstemp) 
    52445127if test "$ac_cv_func_mkstemp" = "yes" ; then 
    5245     saveCFLAGS=$CFLAGS 
    5246     CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    52475128    PAC_FUNC_NEEDS_DECL([#include <stdlib.h>],mkstemp) 
    5248     CFLAGS=$saveCFLAGS 
    52495129fi 
    52505130# fdopen() converts from an fd to a FILE* 
    52515131AC_HAVE_FUNCS(fdopen) 
    52525132if test "$ac_cv_func_fdopen" = "yes" ; then 
    5253     saveCFLAGS=$CFLAGS 
    5254     CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    52555133    PAC_FUNC_NEEDS_DECL([#include <stdlib.h>],fdopen) 
    5256     CFLAGS=$saveCFLAGS 
    52575134fi 
    52585135# putenv() sets environment variable 
    52595136AC_HAVE_FUNCS(putenv) 
    52605137if test "$ac_cv_func_putenv" = "yes" ; then 
    5261     saveCFLAGS=$CFLAGS 
    5262     CFLAGS="$CFLAGS $MPICH2_EXTRA_CFLAGS" 
    52635138    PAC_FUNC_NEEDS_DECL([#include <stdlib.h>],putenv) 
    5264     CFLAGS=$saveCFLAGS 
    52655139fi 
    52665140 
     
    53625236    clock_gettime) 
    53635237    missing_function=no 
    5364     # Solaris places clock_gettime in the rt library 
    5365     AC_CHECK_FUNC(clock_gettime,,[missing_function=yes]) 
     5238    # FIXME: We are blindly adding the flag into LDFLAGS without 
     5239    # checking if someone else added it as well, so there might be a 
     5240    # duplication. 
     5241    AC_CHECK_LIB(rt,clock_gettime,LDFLAGS="$LDFLAGS -lrt",missing_function=yes) 
    53665242    if test "$missing_function" = yes ; then 
    5367         AC_SEARCH_LIBS(clock_gettime,rt,missing_function=no) 
    5368         if test "$missing_function" = yes ; then 
    5369              AC_MSG_ERROR([Requested timer clock_gettime (POSIX) is not available]) 
    5370         fi 
     5243       AC_MSG_ERROR([Requested timer clock_gettime (POSIX) is not available]) 
    53715244    fi 
    53725245    AC_CHECK_FUNC(clock_getres,,[missing_function=yes]) 
     
    57565629    ${MPE_THREAD_DEFAULT}.  If the option is specified, but a package 
    57575630    is not given, then the default is posix.] 
    5758 ,, 
    5759 with_thread_package=${MPE_THREAD_DEFAULT}) 
     5631,,with_thread_package=${MPE_THREAD_DEFAULT}) 
    57605632 
    57615633if test "$with_thread_package" = "yes" ; then 
    5762     with_thread_package=posix 
     5634   with_thread_package=posix 
    57635635fi 
    57645636 
     
    57695641        AC_CHECK_HEADERS(pthread.h) 
    57705642        AC_CHECK_FUNCS(pthread_yield) 
    5771         # OSF1 has __pthread_create but not pthread_create (because of  
    5772         # inconsistencies in the pthread spec).  Thus, we look for pthread_key_create 
    5773         AC_SEARCH_LIBS(pthread_key_create,pthread,found=yes,found=no) 
    5774         if test "$found" != "yes" ; then 
    5775            AC_MSG_ERROR([unable to find pthreads library]) 
    5776         elif test "$ac_cv_search_pthread_key_create" = "none required" ; then 
    5777             # Solaris provides a pthread library that does't work 
    5778             # in libc; you must link with -lpthread to get correct  
    5779             # behavior.  Here is a simple test, based on a failure that 
    5780             # we observed 
    5781             AC_MSG_CHECKING([whether pthread routines without explicit lib are broken]) 
    5782             AC_TRY_RUN([#include<pthread.h> 
    5783 int main() { 
    5784     pthread_t id = pthread_self(); 
    5785     int       rc; 
    5786     rc = pthread_equal( id, id ); 
    5787     if (rc) return 0; 
    5788     return 1;} 
    5789 ],pac_cv_lib_pthread_broken=no,pac_cv_lib_pthread_broken=yes,pac_cv_lib_pthread_broken=unknown) 
    5790             AC_MSG_RESULT($pac_cv_lib_pthread_broken) 
    5791             if test "$pac_cv_lib_pthread_broken" = yes ; then 
    5792                 # Try again with -lpthread 
    5793                 AC_MSG_CHECKING([whether pthread routines with explicit lib are broken]) 
    5794                 saveLIBS=$LIBS 
    5795                 LIBS="$LIBS -lpthread" 
    5796                 AC_TRY_RUN([#include<pthread.h> 
    5797 int main() { 
    5798     pthread_t id = pthread_self(); 
    5799     int       rc; 
    5800     rc = pthread_equal( id, id ); 
    5801     if (rc) return 0; 
    5802     return 1;} 
    5803 ],pac_cv_lib_pthread_broken_explicit=no,pac_cv_lib_pthread_broken_explicit=yes,pac_cv_lib_pthread_broken_explicit=unknown) 
    5804             AC_MSG_RESULT($pac_cv_lib_pthread_broken_explicit) 
    5805             if test "$pac_cv_lib_pthread_broken_explicit" != no ; then 
    5806                 LIBS=$saveLIBS 
    5807             fi 
    5808         fi 
    5809         fi 
     5643 
     5644        # If pthreads library is found, just include it. We don't try 
     5645        # to test if the compiler needs it or not, since though MPICH2 
     5646        # itself might not need it, other applications (e.g., those 
     5647        # compiled with the C++ or Fortran compilers) might. 
     5648        # FIXME: We are blindly adding the flag into LDFLAGS without 
     5649        # checking if someone else added it as well, so there might be 
     5650        # a duplication. 
     5651        AC_CHECK_LIB(pthread,pthread_key_create,LDFLAGS="$LDFLAGS -lpthread",) 
     5652 
    58105653        # Check for a routine that specify a routine to call on  
    58115654        # thread exit.  We can use this to release memory that may 
     
    58735716        fi 
    58745717 
    5875         THR_LIBS="$THR_LIBS -lpthread" 
    58765718        MPICH2_THREAD_PACKAGE=pthreads 
    58775719        ;; 
     
    63846226# Unlike WRAPPER_CFLAGS, the linker flags will always be needed to ensure that  
    63856227# all of the required libraries are present. 
    6386 WRAPPER_LDFLAGS="$WRAPPER_LDFLAGS $LDFLAGS $THR_LDFLAGS" 
     6228WRAPPER_LDFLAGS="$LDFLAGS $THR_LDFLAGS" 
     6229export WRAPPER_LDFLAGS 
    63876230AC_SUBST(WRAPPER_CFLAGS) 
    63886231AC_SUBST(WRAPPER_CXXFLAGS)