From 36b315db2d7613d5a6070ac16181990393a121b8 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 23 Aug 2014 10:50:14 +0000 Subject: [PATCH] oshmem configury: tighten up the pshmem checks Make the checks for macro weak symbols be equivalent to the checks for weak symbols. Also fix up several OSHMEM configure checks: * fix an errant AC_MSG_REQUEST * don't check for profiling ability during configure options checks. Instead, defer it to later, when we have weak symbol check results. * don't directly call _FOO macros from the top level * make setting up OSHMEM profiling similar to MPI profiling: create OSHMEM_SETUP_PROFILING macro * cache the results of checking for macro weak symbols (for parity with the weak symbol check -- although we should really revisit/audit the whole cache-checking scheme throughout all m4 code; it may well be inconsistently used) * add some more [] m4 quoting, even in the original C weak symbols test * style: fix some whitespace errors Refs trac:4868 This commit was SVN r32590. The following Trac tickets were found above: Ticket 4868 --> https://svn.open-mpi.org/trac/ompi/ticket/4868 --- config/c_weak_symbols.m4 | 50 ++++++++++++++++++++---------- config/oshmem_configure_options.m4 | 40 +++++++++++------------- config/oshmem_setup_profiling.m4 | 45 +++++++++++++++++++++++++++ configure.ac | 12 ++++--- 4 files changed, 104 insertions(+), 43 deletions(-) create mode 100644 config/oshmem_setup_profiling.m4 diff --git a/config/c_weak_symbols.m4 b/config/c_weak_symbols.m4 index 64fa9ad91a..20e5dbb129 100644 --- a/config/c_weak_symbols.m4 +++ b/config/c_weak_symbols.m4 @@ -6,16 +6,17 @@ 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 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) 2014 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. +dnl Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. dnl $COPYRIGHT$ -dnl +dnl dnl Additional copyrights may follow -dnl +dnl dnl $HEADER$ dnl @@ -45,10 +46,10 @@ EOF # Try the compile OPAL_LOG_COMMAND( [$CC $CFLAGS -c conftest_weak.c], - OPAL_LOG_COMMAND( + [OPAL_LOG_COMMAND( [$CC $CFLAGS conftest.c conftest_weak.o -o conftest $LDFLAGS $LIBS], [opal_c_weak_symbols_happy=1], - [opal_c_weak_symbols_happy=0]), + [opal_c_weak_symbols_happy=0])], [opal_c_weak_symbols_happy=0]) AS_IF([test "$opal_c_weak_symbols_happy" = "1"], [$1], [$2]) @@ -58,6 +59,21 @@ OPAL_LOG_COMMAND( ]) +# OPAL_C_WEAK_SYMBOLS() +# --------------------- +# sets OPAL_C_HAVE_WEAK_SYMBOLS=1 if C compiler has support for weak symbols +AC_DEFUN([OPAL_C_WEAK_SYMBOLS],[ + AC_CACHE_CHECK([for weak symbol support], + [opal_cv_c_weak_symbols], + [_OPAL_C_WEAK_SYMBOLS([opal_cv_c_weak_symbols="yes"], + [opal_cv_c_weak_symbols="no"])]) + + AS_IF([test "$opal_cv_c_weak_symbols" = "yes"], + [OPAL_C_HAVE_WEAK_SYMBOLS=1], [OPAL_C_HAVE_WEAK_SYMBOLS=0]) +]) dnl + +######################################################################## + # _OPAL_C_MACRO_WEAK_SYMBOLS(action_if_found, [action_if_not_found]) # ------------------------------------------------------------ AC_DEFUN([_OPAL_C_MACRO_WEAK_SYMBOLS],[ @@ -90,10 +106,10 @@ EOF # Try the compile OPAL_LOG_COMMAND( [$CC $CFLAGS -c conftest_weak.c], - OPAL_LOG_COMMAND( + [OPAL_LOG_COMMAND( [$CC $CFLAGS conftest.c conftest_weak.o -o conftest $LDFLAGS $LIBS], [opal_c_macro_weak_symbols_happy=1], - [opal_c_macro_weak_symbols_happy=0]), + [opal_c_macro_weak_symbols_happy=0])], [opal_c_macro_weak_symbols_happy=0]) AS_IF([test "$opal_c_macro_weak_symbols_happy" = "1"], [$1], [$2]) @@ -102,15 +118,17 @@ OPAL_LOG_COMMAND( rm -f conftest_weak.h conftest_weak.c conftest.c conftest ]) -# OPAL_C_WEAK_SYMBOLS() +# OPAL_C_MACRO_WEAK_SYMBOLS # --------------------- -# sets OPAL_C_WEAK_SYMBOLS=1 if C compiler has support for weak symbols -AC_DEFUN([OPAL_C_WEAK_SYMBOLS],[ - AC_CACHE_CHECK([for weak symbol support], - [opal_cv_c_weak_symbols], - [_OPAL_C_WEAK_SYMBOLS([opal_cv_c_weak_symbols="yes"], - [opal_cv_c_weak_symbols="no"])]) +# Sets OPAL_C_HAVE_MACRO_WEAK_SYMBOLS=1 if C compiler has support for weak +# symbols +AC_DEFUN([OPAL_C_MACRO_WEAK_SYMBOLS],[ + AC_CACHE_CHECK([for macro weak symbol support], + [opal_cv_c_macro_weak_symbols], + [_OPAL_C_WEAK_SYMBOLS([opal_cv_c_macro_weak_symbols="yes"], + [opal_cv_c_macro_weak_symbols="no"])]) - AS_IF([test "$opal_cv_c_weak_symbols" = "yes"], - [OPAL_C_HAVE_WEAK_SYMBOLS=1], [OPAL_C_HAVE_WEAK_SYMBOLS=0]) + AS_IF([test "$opal_cv_c_macro_weak_symbols" = "yes"], + [OPAL_C_HAVE_MACRO_WEAK_SYMBOLS=1], + [OPAL_C_HAVE_MACRO_WEAK_SYMBOLS=0]) ]) dnl diff --git a/config/oshmem_configure_options.m4 b/config/oshmem_configure_options.m4 index d6f2eb8fb6..60a6698571 100644 --- a/config/oshmem_configure_options.m4 +++ b/config/oshmem_configure_options.m4 @@ -36,8 +36,9 @@ if test "$oshmem_arg_given" = "yes"; then AC_MSG_WARN([only supports Linux.]) AC_MSG_ERROR([Cannot continue]) fi + else + AC_MSG_RESULT([no]) fi - AC_MSG_RESULT([no]) else if test "$opal_found_linux" = "yes"; then enable_oshmem=yes @@ -101,29 +102,23 @@ AC_DEFINE_UNQUOTED(OSHMEM_PARAM_CHECK, $shmem_param_check, # # OSHMEM profiling support # -AC_MSG_CHECKING([if want pshmem_]) AC_ARG_ENABLE(oshmem-profile, AC_HELP_STRING([--enable-oshmem-profile], [enable OSHMEM profiling (default: enabled)])) -if test "$enable_oshmem" != "no" -a "$enable_oshmem_profile" != "no"; then - _OPAL_C_WEAK_SYMBOLS([ - _OPAL_C_MACRO_WEAK_SYMBOLS([ - AC_MSG_RESULT([yes]) - oshmem_profiling_support=1],[ - AC_MSG_RESULT([no]) - AC_MSG_WARN([Macro defined weak symbols not supported by compiler. - Profiling will be disabled.]) - oshmem_profiling_support=0])], [ - AC_MSG_RESULT([no]) - AC_MSG_WARN([Weak symbols not supported by compiler. - Profiling will be disabled.]) - oshmem_profiling_support=0] - ) -else - AC_MSG_RESULT([no]) - oshmem_profiling_support=0 -fi -AM_CONDITIONAL(OSHMEM_PROFILING, test $oshmem_profiling_support -eq 1) +AC_MSG_CHECKING([if want pshmem]) +AS_IF([test "$enable_oshmem_profile" != "no"], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) + +# Bozo check +AS_IF([test "$enable_oshmem" = "no" && \ + test "$enable_oshmem_profile" = "yes"], + [AC_MSG_WARN([OpenSHMEM profiling was requested, but OpenSHMEM has been explicitly disabled]) + AC_MSG_ERROR([Cannot continue])]) + +# Cannot check if we can enable profiling because it is not yet +# known whether the compiler supports weak symbols. + # # Fortran bindings @@ -151,7 +146,8 @@ else fi # -# We can't set am_conditional here since it's yet unknown if there is valid Fortran compiler avaliable +# We can't set am_conditional here since it's yet unknown if there is +# valid Fortran compiler avaliable # ]) dnl diff --git a/config/oshmem_setup_profiling.m4 b/config/oshmem_setup_profiling.m4 new file mode 100644 index 0000000000..838c11b8db --- /dev/null +++ b/config/oshmem_setup_profiling.m4 @@ -0,0 +1,45 @@ +# -*- shell-script -*- +# +# Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +AC_DEFUN([OSHMEM_SETUP_PROFILING],[ + opal_show_subtitle "OpenSHMEM profiling" + + AC_MSG_CHECKING([if pshmem will be enabled]) + AS_IF([test "$enable_oshmem" != "no" && \ + test "$enable_oshmem_profile" != "no"], + [AS_IF([test "$OPAL_C_HAVE_WEAK_SYMBOLS" -eq 1 && \ + test "$OPAL_C_HAVE_MACRO_WEAK_SYMBOLS" -eq 1], + [ # We want OSHMEM and we have all the required weak + # symbol support + oshmem_profiling_support=1 + AC_MSG_RESULT([yes (weak symbols supported)])], + [ # We want OSHMEM, but we do NOT have all the + # required weak symbol support + oshmem_profiling_support=0 + AC_MSG_RESULT([no (weak symbols not supported)]) + AS_IF([test "$OPAL_C_HAVE_WEAK_SYMBOLS" -eq 0], + [AC_MSG_WARN([Weak symbols not supported by compiler])]) + AS_IF([test "$OPAL_C_HAVE_MACRO_WEAK_SYMBOLS" -eq 0], + [AC_MSG_WARN([Macro weak symbols not supported by compiler])]) + AC_MSG_WARN([OpenSHMEM profiling is disabled.]) + + AS_IF(["$enable_oshmem_profile" = "yes" -a + $oshmem_profiling_support -eq 0], + [AC_MSG_WARN([OpenSHMEM profiling requested but cannot be enabled]) + AC_MSG_ERROR([Cannot continue])]) + ]) + ],[ + # We do not want OSHMEM, so disable profiling + oshmem_profiling_support=0 + AC_MSG_RESULT([no (OpenSHMEM disabled)]) + ]) + + AM_CONDITIONAL([OSHMEM_PROFILING], [test $oshmem_profiling_support -eq 1]) +]) dnl diff --git a/configure.ac b/configure.ac index d4bdaf9306..acf27065fe 100644 --- a/configure.ac +++ b/configure.ac @@ -535,6 +535,7 @@ if test "x$opal_cv_c_compiler_vendor" != "xmicrosoft"; then AC_C_RESTRICT fi OPAL_C_WEAK_SYMBOLS +OPAL_C_MACRO_WEAK_SYMBOLS if test "$GCC" = "yes"; then CFLAGS=$CFLAGS_save fi @@ -601,17 +602,18 @@ m4_ifdef([project_oshmem], [OSHMEM_SETUP_JAVA_BINDINGS]) ################################## -# MPI API profiling layer +# MPI / OpenSHMEM API profiling layer ################################## -# Setup OMPI bindings (if we're building the OMPI project). Note that -# opal_wrapper.c has a hard-coded use of the OMPI_ENABLE_MPI_PROFILING -# macro, so we need to define it (to 0) even if we're not building the -# OMPI project. +# Setup profiling bindings (if we're building the relevant projects). +# Note that opal_wrapper.c has a hard-coded use of the +# OMPI_ENABLE_MPI_PROFILING macro, so we need to define it (to 0) even +# if we're not building the OMPI project. m4_ifdef([project_ompi], [OMPI_SETUP_MPI_PROFILING], [AC_DEFINE([OMPI_ENABLE_MPI_PROFILING], [0], [We are not building OMPI, so no profiling])]) +m4_ifdef([project_oshmem], [OSHMEM_SETUP_PROFILING]) ##################################