From aa7a4d0f6fd8bde3774cd3ba67dccfcc51562f35 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 11 Jul 2018 11:26:37 +0900 Subject: [PATCH 01/10] hwloc: prefer external hwloc component Signed-off-by: Gilles Gouaillardet Signed-off-by: Jeff Squyres (cherry picked from commit open-mpi/ompi@ce2c9fffd421036f46c3d35c1c85439d57538ca6) --- opal/mca/hwloc/external/configure.m4 | 142 +++++++++++++++------------ opal/mca/hwloc/hwloc201/configure.m4 | 4 +- 2 files changed, 79 insertions(+), 67 deletions(-) diff --git a/opal/mca/hwloc/external/configure.m4 b/opal/mca/hwloc/external/configure.m4 index d1b4a1380b7..24721f514c9 100644 --- a/opal/mca/hwloc/external/configure.m4 +++ b/opal/mca/hwloc/external/configure.m4 @@ -1,7 +1,7 @@ # -*- shell-script -*- # # Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved -# Copyright (c) 2014-2017 Research Organization for Information Science +# Copyright (c) 2014-2018 Research Organization for Information Science # and Technology (RIST). All rights reserved. # # Copyright (c) 2018 Intel, Inc. All rights reserved. @@ -84,7 +84,7 @@ AC_DEFUN([MCA_opal_hwloc_external_POST_CONFIG],[ AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[ AC_CONFIG_FILES([opal/mca/hwloc/external/Makefile]) - OPAL_VAR_SCOPE_PUSH([opal_hwloc_external_CPPFLAGS_save opal_hwloc_external_CFLAGS_save opal_hwloc_external_LDFLAGS_save opal_hwloc_external_LIBS_save opal_hwloc_external_want opal_hwloc_external_tmp opal_hwloc_external_lstopo]) + OPAL_VAR_SCOPE_PUSH([opal_hwloc_external_CPPFLAGS_save opal_hwloc_external_CFLAGS_save opal_hwloc_external_LDFLAGS_save opal_hwloc_external_LIBS_save opal_hwloc_external_tmp opal_hwloc_external_lstopo opal_hwloc_summary_msg]) AC_ARG_WITH([hwloc-libdir], [AC_HELP_STRING([--with-hwloc-libdir=DIR], @@ -98,19 +98,9 @@ AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[ AC_MSG_WARN([were specified, which does not make sense.]) AC_MSG_ERROR([Cannot continue])]) - # Do we want this external component? (slightly redundant logic, - # but hopefully slightly more clear...) - opal_hwloc_external_want=no - AS_IF([test "$with_hwloc_libdir" != ""], [opal_hwloc_external_want=yes]) - AS_IF([test "$with_hwloc" = "external"], [opal_hwloc_external_want=yes]) - AS_IF([test "$with_hwloc" != "" && \ - test "$with_hwloc" != "no" && \ - test "$with_hwloc" != "internal" && \ - test "$with_hwloc" != "future"], [opal_hwloc_external_want=yes]) - AS_IF([test "$with_hwloc" = "no"], [opal_hwloc_external_want=no]) - - # If we still want external support, try it - AS_IF([test "$opal_hwloc_external_want" = "yes"], + opal_hwloc_summary_msg="internal" + # Try external support if needed + AS_IF([test "$with_hwloc" != "internal"], [OPAL_CHECK_WITHDIR([hwloc-libdir], [$with_hwloc_libdir], [libhwloc.*]) @@ -144,64 +134,86 @@ AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[ LDFLAGS="$LDFLAGS $opal_hwloc_external_LDFLAGS" LIBS="$LIBS $opal_hwloc_external_LIBS" AC_CHECK_DECLS([HWLOC_OBJ_OSDEV_COPROC], [], [], [#include ]) - AC_CHECK_FUNCS([hwloc_topology_dup])]) + AC_CHECK_FUNCS([hwloc_topology_dup]) - CPPFLAGS=$opal_hwloc_external_CPPFLAGS_save - CFLAGS=$opal_hwloc_external_CFLAGS_save - LDFLAGS=$opal_hwloc_external_LDFLAGS_save - LIBS=$opal_hwloc_external_LIBS_save - ]) - - # Done! - AS_IF([test "$opal_hwloc_external_support" = "yes"], - [AC_DEFINE_UNQUOTED([HWLOC_EXTERNAL_HWLOC_VERSION], - [external], - [Version of hwloc]) - - # See if the external hwloc supports XML - AC_MSG_CHECKING([if external hwloc supports XML]) - AS_IF([test "$opal_hwloc_dir" != ""], - [opal_hwloc_external_lstopo="$opal_hwloc_dir/bin/lstopo"], - [OPAL_WHICH(lstopo, opal_hwloc_external_lstopo)]) - opal_hwloc_external_tmp=`$opal_hwloc_external_lstopo --help | $GREP "Supported output file formats" | grep xml` - AS_IF([test "$opal_hwloc_external_tmp" = ""], - [opal_hwloc_external_enable_xml=0 - AC_MSG_RESULT([no])], - [opal_hwloc_external_enable_xml=1 - AC_MSG_RESULT([yes])]) - - AC_CHECK_HEADERS([infiniband/verbs.h]) - - AC_MSG_CHECKING([if external hwloc version is 1.5 or greater]) - AS_IF([test "$opal_hwloc_dir" != ""], - [opal_hwloc_external_CFLAGS_save=$CFLAGS - CFLAGS="-I$opal_hwloc_dir/include $opal_hwloc_external_CFLAGS_save"]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include ]], - [[ + AC_MSG_CHECKING([if external hwloc version is 1.5 or greater]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[ #if HWLOC_API_VERSION < 0x00010500 #error "hwloc API version is less than 0x00010500" #endif - ]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_ERROR([Cannot continue])]) - - AS_IF([test "$opal_hwloc_dir" != ""], - [CFLAGS=$opal_hwloc_external_CFLAGS_save]) + ]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + opal_hwloc_external_support=no])]) - # These flags need to get passed to the wrapper compilers - # (this is unnecessary for the internal/embedded hwloc) + # If external hwloc is not explicitly requested, check external version + # is not lower than the internal one + AS_IF([test "$opal_hwloc_external_support" = "yes"], + [AS_IF([test -z "$with_hwloc" || test "$with_hwloc" = "yes"], + [AC_MSG_CHECKING([if external hwloc version is 2.0 or greater]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[ +#if HWLOC_API_VERSION < 0x00020000 +#error "hwloc API version is less than 0x00020000" +#endif + ]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + opal_hwloc_summary_msg="internal (external hlwoc version is less than internal version 2.0)" + AC_MSG_WARN([external hwloc version is less than internal version 2.0]) + AC_MSG_WARN([using internal hwloc]) + opal_hwloc_external_support=no])])]) - # Finally, add some flags to the wrapper compiler if we're - # building with developer headers so that our headers can - # be found. - hwloc_external_WRAPPER_EXTRA_CPPFLAGS=$opal_hwloc_external_CPPFLAGS - hwloc_external_WRAPPER_EXTRA_LDFLAGS=$opal_hwloc_external_LDFLAGS - hwloc_external_WRAPPER_EXTRA_LIBS=$opal_hwloc_external_LIBS + AS_IF([test "$opal_hwloc_external_support" = "yes"], + [AC_DEFINE_UNQUOTED([HWLOC_EXTERNAL_HWLOC_VERSION], + [external], + [Version of hwloc]) + + # See if the external hwloc supports XML + AC_MSG_CHECKING([if external hwloc supports XML]) + AS_IF([test "$opal_hwloc_dir" != ""], + [opal_hwloc_external_lstopo="$opal_hwloc_dir/bin/lstopo"], + [OPAL_WHICH(lstopo, opal_hwloc_external_lstopo)]) + opal_hwloc_external_tmp=`$opal_hwloc_external_lstopo --help | $GREP "Supported output file formats" | grep xml` + AS_IF([test "$opal_hwloc_external_tmp" = ""], + [opal_hwloc_external_enable_xml=0 + AC_MSG_RESULT([no])], + [opal_hwloc_external_enable_xml=1 + AC_MSG_RESULT([yes])]) + + AC_CHECK_HEADERS([infiniband/verbs.h]) + + # These flags need to get passed to the wrapper compilers + # (this is unnecessary for the internal/embedded hwloc) + + # Finally, add some flags to the wrapper compiler if we're + # building with developer headers so that our headers can + # be found. + hwloc_external_WRAPPER_EXTRA_CPPFLAGS=$opal_hwloc_external_CPPFLAGS + hwloc_external_WRAPPER_EXTRA_LDFLAGS=$opal_hwloc_external_LDFLAGS + hwloc_external_WRAPPER_EXTRA_LIBS=$opal_hwloc_external_LIBS]) + + CPPFLAGS=$opal_hwloc_external_CPPFLAGS_save + CFLAGS=$opal_hwloc_external_CFLAGS_save + LDFLAGS=$opal_hwloc_external_LDFLAGS_save + LIBS=$opal_hwloc_external_LIBS_save + ]) + # Done! + AS_IF([test "$opal_hwloc_external_support" = "yes"], + [opal_hwloc_summary_msg="external" $1], - [$2]) + [# Abort is external hwloc was explicitly requested but cannot be built + AS_IF([test "$with_hwloc" != internal && + test -n "$with_hwloc"], + [AC_MSG_WARN([external hwloc cannot be built]) + AC_MSG_ERROR([Cannot continue.])]) + $2]) + + OPAL_SUMMARY_ADD([[Miscellaneous]],[[HWLOC support]], [], [$opal_hwloc_summary_msg]) AC_SUBST(opal_hwloc_external_LDFLAGS) AC_SUBST(opal_hwloc_external_LIBS) diff --git a/opal/mca/hwloc/hwloc201/configure.m4 b/opal/mca/hwloc/hwloc201/configure.m4 index b6e60bc11e3..33f55b0d442 100644 --- a/opal/mca/hwloc/hwloc201/configure.m4 +++ b/opal/mca/hwloc/hwloc201/configure.m4 @@ -2,7 +2,7 @@ # # Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved # Copyright (c) 2014-2017 Intel, Inc. All rights reserved. -# Copyright (c) 2015-2017 Research Organization for Information Science +# Copyright (c) 2015-2018 Research Organization for Information Science # and Technology (RIST). All rights reserved. # Copyright (c) 2016 Los Alamos National Security, LLC. All rights # reserved. @@ -17,7 +17,7 @@ # # Priority # -AC_DEFUN([MCA_opal_hwloc_hwloc201_PRIORITY], [90]) +AC_DEFUN([MCA_opal_hwloc_hwloc201_PRIORITY], [80]) # # Force this component to compile in static-only mode From 6f5a4534922ec62a8fda2b1027cd4e1a7dd796be Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 17 Jul 2018 18:12:37 -0700 Subject: [PATCH 02/10] event: trivial comment change Switch from #-style to dnl-style. Signed-off-by: Jeff Squyres (cherry picked from commit open-mpi/ompi@83e4a45a9f4c873cbde79478baef9b93f29f8799) --- opal/mca/event/configure.m4 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/opal/mca/event/configure.m4 b/opal/mca/event/configure.m4 index f8040446009..407b7a52a2b 100644 --- a/opal/mca/event/configure.m4 +++ b/opal/mca/event/configure.m4 @@ -1,6 +1,6 @@ dnl -*- shell-script -*- dnl -dnl Copyright (c) 2010-2013 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -8,12 +8,12 @@ dnl dnl $HEADER$ dnl -# There will only be one component used in this framework, and it will -# be selected at configure time by priority. Components must set -# their priorities in their configure.m4 files. They must also set -# the shell variable $opal_event_base_include to a header file name -# (relative to opal/mca/event) that will be included in -# opal/mca/event/event.h. +dnl There will only be one component used in this framework, and it will +dnl be selected at configure time by priority. Components must set +dnl their priorities in their configure.m4 files. They must also set +dnl the shell variable $opal_event_base_include to a header file name +dnl (relative to opal/mca/event) that will be included in +dnl opal/mca/event/event.h. dnl We only want one winning component (vs. STOP_AT_FIRST_PRIORITY, dnl which will allow all components of the same priority who succeed to From 1ea021933f38c9cdfafbc4ffee3ae35c63a39b96 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 17 Jul 2018 18:14:33 -0700 Subject: [PATCH 03/10] event/external: prefer external event component Signed-off-by: Jeff Squyres (cherry picked from commit open-mpi/ompi@a70ecf526773a3bc43b582f8d44e91b5def374e1) --- opal/mca/event/configure.m4 | 31 +++++ opal/mca/event/external/configure.m4 | 189 ++++++++++++++------------- 2 files changed, 132 insertions(+), 88 deletions(-) diff --git a/opal/mca/event/configure.m4 b/opal/mca/event/configure.m4 index 407b7a52a2b..5fde182b4cf 100644 --- a/opal/mca/event/configure.m4 +++ b/opal/mca/event/configure.m4 @@ -18,11 +18,42 @@ dnl opal/mca/event/event.h. dnl We only want one winning component (vs. STOP_AT_FIRST_PRIORITY, dnl which will allow all components of the same priority who succeed to dnl win) + m4_define(MCA_opal_event_CONFIGURE_MODE, STOP_AT_FIRST) +dnl +dnl Setup --with-libevent and --with-libevent-libdir +dnl +AC_DEFUN([MCA_opal_event_SETUP],[ + AC_ARG_WITH([libevent], + [AC_HELP_STRING([--with-libevent=DIR], + [Search for libevent headers and libraries in DIR. Should only be used if an external copy of libevent is being used.])]) + + # Bozo check + AS_IF([test "$with_libevent" = "no"], + [AC_MSG_WARN([It is not possible to configure Open MPI --without-libevent]) + AC_MSG_ERROR([Cannot continue])]) + AS_IF([test "$with_libevent" = "yes"], + [with_libevent=]) + + AC_ARG_WITH([libevent-libdir], + [AC_HELP_STRING([--with-libevent-libdir=DIR], + [Search for libevent libraries in DIR. Should only be used if an external copy of libevent is being used.])]) + + # Make sure the user didn't specify --with-libevent=internal and + # --with-libevent-libdir=whatever (because you can only specify + # --with-libevent-libdir when external libevent is being used). + AS_IF([test "$with_libevent" = "internal" && test -n "$with_libevent_libdir"], + [AC_MSG_WARN([Both --with-libevent=internal and --with-libevent-libdir=DIR]) + AC_MSG_WARN([were specified, which does not make sense.]) + AC_MSG_ERROR([Cannot continue])]) +]) + AC_DEFUN([MCA_opal_event_CONFIG],[ opal_event_base_include= + MCA_opal_event_SETUP + # configure all the components MCA_CONFIGURE_FRAMEWORK($1, $2, 1) diff --git a/opal/mca/event/external/configure.m4 b/opal/mca/event/external/configure.m4 index 498af38b405..2ba19aa8a14 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -1,8 +1,8 @@ # -*- shell-script -*- # -# Copyright (c) 2009-2013 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved # Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. -# Copyright (c) 2015-2017 Research Organization for Information Science +# Copyright (c) 2015-2018 Research Organization for Information Science # and Technology (RIST). All rights reserved. # # Copyright (c) 2017 Intel, Inc. All rights reserved. @@ -56,72 +56,59 @@ AC_DEFUN([MCA_opal_event_external_POST_CONFIG],[ AC_DEFUN([MCA_opal_event_external_CONFIG],[ AC_CONFIG_FILES([opal/mca/event/external/Makefile]) - OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save]) - - AC_ARG_WITH([libevent], - [AC_HELP_STRING([--with-libevent=DIR], - [Search for libevent headers and libraries in DIR. Should only be used if an external copy of libevent is being used.])]) - - # Bozo check - AS_IF([test "$with_libevent" = "no"], - [AC_MSG_WARN([It is not possible to configure Open MPI --without-libevent]) - AC_MSG_ERROR([Cannot continue])]) - - AC_ARG_WITH([libevent-libdir], - [AC_HELP_STRING([--with-libevent-libdir=DIR], - [Search for libevent libraries in DIR. Should only be used if an external copy of libevent is being used.])]) - - # Make sure the user didn't specify --with-libevent=internal and - # --with-libevent-libdir=whatever (because you can only specify - # --with-libevent-libdir when external libevent is being used). - AS_IF([test "$with_libevent" = "internal" && test -n "$with_libevent_libdir"], - [AC_MSG_WARN([Both --with-libevent=internal and --with-libevent-libdir=DIR]) - AC_MSG_WARN([were specified, which does not make sense.]) - AC_MSG_ERROR([Cannot continue])]) - - # Do we want this external component? (slightly redundant logic, - # but hopefully slightly more clear...) - opal_event_external_want=no - AS_IF([test "$with_libevent" = "external"], [opal_event_external_want=yes]) - AS_IF([test -n "$with_libevent_libdir"], [opal_event_external_want=yes]) - AS_IF([test -n "$with_libevent" && test "$with_libevent" != "no" && test "$with_libevent" != "internal"], [opal_event_external_want=yes]) - - # If we want external support, try it - AS_IF([test "$opal_event_external_want" = "yes"], - [ # Error out if the specified dir does not exist - OPAL_CHECK_WITHDIR([libevent-libdir], [$with_libevent_libdir], - [libevent.*]) - - AC_MSG_CHECKING([for external libevent in]) - AS_IF([test "$with_libevent" != "external" && test "$with_libevent" != "yes"], - [opal_event_dir=$with_libevent - AC_MSG_RESULT([$opal_event_dir]) - OPAL_CHECK_WITHDIR([libevent], [$opal_event_dir], - [include/event.h]) - AS_IF([test -z "$with_libevent_libdir" || test "$with_libevent_libdir" = "yes"], - [AC_MSG_CHECKING([for $with_libevent/lib64]) - AS_IF([test -d "$with_libevent/lib64"], - [opal_event_libdir_found=yes - AC_MSG_RESULT([found])], - [opal_event_libdir_found=no - AC_MSG_RESULT([not found])]) - AS_IF([test "$opal_event_libdir_found" = "yes"], - [opal_event_libdir="$with_libevent/lib64"], - [AC_MSG_CHECKING([for $with_libevent/lib]) - AS_IF([test -d "$with_libevent/lib"], - [AC_MSG_RESULT([found]) - opal_event_libdir="$with_libevent/lib"], - [AC_MSG_RESULT([not found]) - AC_MSG_WARN([Library directories were not found:]) - AC_MSG_WARN([ $with_libevent/lib64]) - AC_MSG_WARN([ $with_libevent/lib]) - AC_MSG_WARN([Please use --with-libevent-libdir to identify it.]) - AC_MSG_ERROR([Cannot continue])])])])], - [AC_MSG_RESULT([(default search paths)])]) - AS_IF([test ! -z "$with_libevent_libdir" && test "$with_libevent_libdir" != "yes"], - [opal_event_libdir="$with_libevent_libdir"]) - - opal_event_external_CPPFLAGS_save=$CPPFLAGS + OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save opal_event_dir opal_event_external_support opal_event_summary_msg]) + + # Make some processing below easier ($with_libevent==yes and + # $with_libevent==no has already been filtered out). + AS_IF([test "$with_libevent" = "external"], + [with_libevent=]) + + opal_event_summary_msg="internal" + + # Once we get to this point, $with_libevent is either: blank, a + # directory location, or "internal". + + # Check the value of $with_libevent_libdir. This macro safely + # handles "yes", "no", blank, and directory name values. + OPAL_CHECK_WITHDIR([libevent-libdir], [$with_libevent_libdir], + [libevent.*]) + + # Did the user want us to check for libevent in a specific location? + AC_MSG_CHECKING([for external libevent in]) + AS_IF([test -n "$with_libevent" && \ + test "$with_libevent" != "external" && \ + test "$with_libevent" != "internal" && \ + test "$with_libevent" != "yes" && \ + test "$with_libevent" != "no"], + [opal_event_dir=$with_libevent + AC_MSG_RESULT([$opal_event_dir]) + OPAL_CHECK_WITHDIR([libevent], [$opal_event_dir], + [include/event.h]) + AS_IF([test -z "$with_libevent_libdir" || test "$with_libevent_libdir" = "yes"], + [AC_MSG_CHECKING([for $with_libevent/lib64]) + AS_IF([test -d "$with_libevent/lib64"], + [opal_event_libdir_found=yes + AC_MSG_RESULT([found])], + [opal_event_libdir_found=no + AC_MSG_RESULT([not found])]) + AS_IF([test "$opal_event_libdir_found" = "yes"], + [opal_event_libdir="$with_libevent/lib64"], + [AC_MSG_CHECKING([for $with_libevent/lib]) + AS_IF([test -d "$with_libevent/lib"], + [AC_MSG_RESULT([found]) + opal_event_libdir="$with_libevent/lib"], + [AC_MSG_RESULT([not found]) + AC_MSG_WARN([Library directories were not found:]) + AC_MSG_WARN([ $with_libevent/lib64]) + AC_MSG_WARN([ $with_libevent/lib]) + AC_MSG_WARN([Please use --with-libevent-libdir to identify it.]) + AC_MSG_ERROR([Cannot continue])])])])], + [AC_MSG_RESULT([(default search paths)])]) + AS_IF([test ! -z "$with_libevent_libdir" && test "$with_libevent_libdir" != "yes"], + [opal_event_libdir="$with_libevent_libdir"]) + + AS_IF([test "$with_libevent" != "internal"], + [opal_event_external_CPPFLAGS_save=$CPPFLAGS opal_event_external_CFLAGS_save=$CFLAGS opal_event_external_LDFLAGS_save=$LDFLAGS opal_event_external_LIBS_save=$LIBS @@ -136,23 +123,42 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ [opal_event_external_support=yes], [opal_event_external_support=no]) - # Ensure that this libevent has the symbol - # "evthread_set_lock_callbacks", which will only exist if - # libevent was configured with thread support. - LIBS="$opal_event_external_LDFLAGS $LIBS" - AC_CHECK_LIB([event], [evthread_set_lock_callbacks], - [], - [AC_MSG_WARN([External libevent does not have thread support]) - AC_MSG_WARN([Open MPI requires libevent to be compiled with]) - AC_MSG_WARN([thread support enabled]) - AC_MSG_ERROR([Cannot continue])]) - - AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads], - [], - [AC_MSG_WARN([External libevent does not have thread support]) - AC_MSG_WARN([Open MPI requires libevent to be compiled with]) - AC_MSG_WARN([thread support enabled]) - AC_MSG_ERROR([Cannot continue])]) + AS_IF([test "$opal_event_external_support" = "yes"], + [# Ensure that this libevent has the symbol + # "evthread_set_lock_callbacks", which will only exist if + # libevent was configured with thread support. + LIBS="$opal_event_external_LDFLAGS $LIBS" + AC_CHECK_LIB([event], [evthread_set_lock_callbacks], + [], + [AC_MSG_WARN([External libevent does not have thread support]) + AC_MSG_WARN([Open MPI requires libevent to be compiled with]) + AC_MSG_WARN([thread support enabled]) + opal_event_external_support=no])]) + + AS_IF([test "$opal_event_external_support" = "yes"], + [AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads], + [], + [AC_MSG_WARN([External libevent does not have thread support]) + AC_MSG_WARN([Open MPI requires libevent to be compiled with]) + AC_MSG_WARN([thread support enabled]) + opal_event_external_support=no])]) + + AS_IF([test "$opal_event_external_support" = "yes"], + [AS_IF([test -z "$with_libevent" || test "$with_libevent" = "yes"], + [AC_MSG_CHECKING([if external libevent version is 2.0.21 or greater]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[ +#if _EVENT_NUMERIC_VERSION < 0x02001500 +#error "libevent API version is less than 0x02001500" +#endif + ]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + opal_event_summary_msg="internal (external libevent version is less that internal version 2.0.21)" + AC_MSG_WARN([external libevent version is less than internal version (2.0.21)]) + AC_MSG_WARN([using internal libevent]) + opal_event_external_support=no])])]) CPPFLAGS=$opal_event_external_CPPFLAGS_save CFLAGS=$opal_event_external_CFLAGS_save @@ -171,20 +177,27 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ # building with developer headers so that our headers can # be found. event_external_WRAPPER_EXTRA_LDFLAGS=$opal_event_external_LDFLAGS - event_external_WRAPPER_EXTRA_LIBS=$opal_event_external_LIBS - ]) + event_external_WRAPPER_EXTRA_LIBS=$opal_event_external_LIBS]) + +################################################################## # Done! AS_IF([test "$opal_event_external_support" = "yes"], - [ # If we configured successfully, set + [# If we configured successfully, set # OPAL_HAVE_WORKING_EVENTOPS to 1 (it's a calculated value # in the embedded Open MPI libevent, so we can only assume # what it is in the installed libevent :-\ ). file=$opal_event_dir/include/libevent/config.h OPAL_HAVE_WORKING_EVENTOPS=1 + opal_event_summary_msg="external" $1], [OPAL_HAVE_WORKING_EVENTOPS=0 + AS_IF([test "$with_libevent" != internal && test -n "$with_libevent"], + [AC_MSG_WARN([external libevent requested but cannot be built]) + AC_MSG_ERROR([Cannot continue.])]) $2]) + OPAL_SUMMARY_ADD([[Miscellaneous]],[[Libevent support]], [], [$opal_event_summary_msg]) + OPAL_VAR_SCOPE_POP ])dnl From 2c2f9b8169995775956e5a66cf6f7924ad8f335f Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Mon, 23 Jul 2018 09:18:48 -0700 Subject: [PATCH 04/10] Leave opal_event_external_support exposed as global var Signed-off-by: Ralph Castain (cherry picked from commit open-mpi/ompi@5cab823979e785b77520b439fbfbc941b8741dc9) --- opal/mca/event/external/configure.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opal/mca/event/external/configure.m4 b/opal/mca/event/external/configure.m4 index 2ba19aa8a14..232f149abbd 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -5,7 +5,7 @@ # Copyright (c) 2015-2018 Research Organization for Information Science # and Technology (RIST). All rights reserved. # -# Copyright (c) 2017 Intel, Inc. All rights reserved. +# Copyright (c) 2017-2018 Intel, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -56,7 +56,7 @@ AC_DEFUN([MCA_opal_event_external_POST_CONFIG],[ AC_DEFUN([MCA_opal_event_external_CONFIG],[ AC_CONFIG_FILES([opal/mca/event/external/Makefile]) - OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save opal_event_dir opal_event_external_support opal_event_summary_msg]) + OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save opal_event_dir opal_event_summary_msg]) # Make some processing below easier ($with_libevent==yes and # $with_libevent==no has already been filtered out). From eca16720de2a5cb82cd28d26dcaca390d155663f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 8 Aug 2018 09:58:49 -0700 Subject: [PATCH 05/10] hwloc201: only configure if hwloc:external fails We know that hwloc:external will be configured first (because of its priority). Take advantage of that here in hwloc201 by having it refuse to configure / politely fail if hwloc:external succeeded. Also print out some additional lines in configure output indicating what is going on (i.e., hwloc:external succeeded, so this component will be skipped, or hwloc:external failed, so this component will be used). Signed-off-by: Jeff Squyres (cherry picked from commit 4e5f432786d1ab99304e40dadec40ac45e93e76f) --- opal/mca/hwloc/hwloc201/configure.m4 | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/opal/mca/hwloc/hwloc201/configure.m4 b/opal/mca/hwloc/hwloc201/configure.m4 index 33f55b0d442..9da91b2c958 100644 --- a/opal/mca/hwloc/hwloc201/configure.m4 +++ b/opal/mca/hwloc/hwloc201/configure.m4 @@ -1,6 +1,6 @@ # -*- shell-script -*- # -# Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved +# Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved # Copyright (c) 2014-2017 Intel, Inc. All rights reserved. # Copyright (c) 2015-2018 Research Organization for Information Science # and Technology (RIST). All rights reserved. @@ -69,6 +69,21 @@ AC_DEFUN([MCA_opal_hwloc_hwloc201_POST_CONFIG],[ # MCA_hwloc_hwloc201_CONFIG([action-if-found], [action-if-not-found]) # -------------------------------------------------------------------- AC_DEFUN([MCA_opal_hwloc_hwloc201_CONFIG],[ + # We know that the external hwloc component will be configured + # before this one because of its priority. This component is only + # needed if the external component was not successful in selecting + # itself. + AC_MSG_CHECKING([if hwloc external component succeeded]) + AS_IF([test "$opal_hwloc_external_support" = "yes"], + [AC_MSG_RESULT([yes]) + AC_MSG_NOTICE([hwloc:external succeeded, so this component will be skipped]) + $2], + [AC_MSG_RESULT([no]) + AC_MSG_NOTICE([hwloc:external failed, so this component will be used]) + MCA_opal_hwloc_hwloc201_BACKEND_CONFIG($1, $2)]) +]) + +AC_DEFUN([MCA_opal_hwloc_hwloc201_BACKEND_CONFIG],[ # Hwloc needs to know if we have Verbs support AC_REQUIRE([OPAL_CHECK_VERBS_DIR]) @@ -80,19 +95,11 @@ AC_DEFUN([MCA_opal_hwloc_hwloc201_CONFIG],[ opal_hwloc_hwloc201_basedir=opal/mca/hwloc/hwloc201 opal_hwloc_hwloc201_support=no - AS_IF([test "$with_hwloc" = "internal" || test -z "$with_hwloc" || test "$with_hwloc" = "yes"], - [opal_hwloc_external="no"], - [opal_hwloc_external="yes"]) - opal_hwloc_hwloc201_save_CPPFLAGS=$CPPFLAGS opal_hwloc_hwloc201_save_LDFLAGS=$LDFLAGS opal_hwloc_hwloc201_save_LIBS=$LIBS - # Run the hwloc configuration - if no external hwloc, then set the prefixi - # to minimize the chance that someone will use the internal symbols - AS_IF([test "$opal_hwloc_external" = "no" && - test "$with_hwloc" != "future"], - [HWLOC_SET_SYMBOL_PREFIX([opal_hwloc201_])]) + HWLOC_SET_SYMBOL_PREFIX([opal_hwloc201_]) # save XML or graphical options opal_hwloc_hwloc201_save_cairo=$enable_cairo From 6cb3d61dd18fc8eb2a33a1657f34204ff3dd0c7a Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 8 Aug 2018 10:04:16 -0700 Subject: [PATCH 06/10] libevent2022: only configure if event:external fails We know that event:external will be configured first (because of its priority). Take advantage of that here in libevent2022 by having it refuse to configure / politely fail if event:external succeeded. Also print out some additional lines in configure output indicating what is going on (i.e., event:external succeeded, so this component will be skipped, or event:external failed, so this component will be used). Signed-off-by: Jeff Squyres (cherry picked from commit b063cb6b0f251052dc72d2496e5745ce83d6b869) --- opal/mca/event/libevent2022/configure.m4 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/opal/mca/event/libevent2022/configure.m4 b/opal/mca/event/libevent2022/configure.m4 index 81ffb3ca82b..2d67735ddcb 100644 --- a/opal/mca/event/libevent2022/configure.m4 +++ b/opal/mca/event/libevent2022/configure.m4 @@ -1,6 +1,6 @@ # -*- shell-script -*- # -# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights reserved. # Copyright (c) 2015 Intel, Inc. All rights reserved. # Copyright (c) 2015-2016 Research Organization for Information Science @@ -86,6 +86,21 @@ EOF # [action-if-cant-compile]) # ------------------------------------------------ AC_DEFUN([MCA_opal_event_libevent2022_CONFIG],[ + # We know that the external event component will be configured + # before this one because of its priority. This component is only + # needed if the external component was not successful in selecting + # itself. + AC_MSG_CHECKING([if event external component succeeded]) + AS_IF([test "$opal_event_external_support" = "yes"], + [AC_MSG_RESULT([yes]) + AC_MSG_NOTICE([event:external succeeded, so this component will be skipped]) + $2], + [AC_MSG_RESULT([no]) + AC_MSG_NOTICE([event:external failed, so this component will be used]) + MCA_opal_event_libevent2022_BACKEND_CONFIG($1, $2)]) +]) + +AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[ OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save libevent_file event_args libevent_happy]) AC_CONFIG_FILES([opal/mca/event/libevent2022/Makefile]) From 63d68ded488af23bdb4f856942154903b505eabf Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Aug 2018 10:30:04 -0700 Subject: [PATCH 07/10] libevent2022/configure.m4: minor comment cleanup Change # -> dnl. No code or logic changes. Signed-off-by: Jeff Squyres (cherry picked from commit 17aa64e43825dd27148fc47d3f8f5694fc091d38) --- opal/mca/event/libevent2022/configure.m4 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/opal/mca/event/libevent2022/configure.m4 b/opal/mca/event/libevent2022/configure.m4 index 2d67735ddcb..fb412629048 100644 --- a/opal/mca/event/libevent2022/configure.m4 +++ b/opal/mca/event/libevent2022/configure.m4 @@ -14,9 +14,9 @@ # AC_DEFUN([MCA_opal_event_libevent2022_PRIORITY], [80]) -# -# Force this component to compile in static-only mode -# +dnl +dnl Force this component to compile in static-only mode +dnl AC_DEFUN([MCA_opal_event_libevent2022_COMPILE_MODE], [ AC_MSG_CHECKING([for MCA component $2:$3 compile mode]) $4="static" @@ -82,9 +82,9 @@ EOF ]) ]) -# MCA_event_libevent2022_CONFIG([action-if-can-compile], -# [action-if-cant-compile]) -# ------------------------------------------------ +dnl MCA_event_libevent2022_CONFIG([action-if-can-compile], +dnl [action-if-cant-compile]) +dnl ------------------------------------------------ AC_DEFUN([MCA_opal_event_libevent2022_CONFIG],[ # We know that the external event component will be configured # before this one because of its priority. This component is only From 5c5246f65544e4c63de7d200d4f97dbeab0e34d9 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Aug 2018 10:30:45 -0700 Subject: [PATCH 08/10] libevent2022/configure.m4: trivial cleanup Put argument to AM_CONDITIONAL inside []. No code or logic changes. Signed-off-by: Jeff Squyres (cherry picked from commit 80df3f040be2b26162df9cc73a0cfd9e3d11732d) --- opal/mca/event/libevent2022/configure.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opal/mca/event/libevent2022/configure.m4 b/opal/mca/event/libevent2022/configure.m4 index fb412629048..8f1319305bf 100644 --- a/opal/mca/event/libevent2022/configure.m4 +++ b/opal/mca/event/libevent2022/configure.m4 @@ -24,7 +24,8 @@ AC_DEFUN([MCA_opal_event_libevent2022_COMPILE_MODE], [ ]) AC_DEFUN([MCA_opal_event_libevent2022_POST_CONFIG], [ - AM_CONDITIONAL(OPAL_EVENT_HAVE_THREAD_SUPPORT, test "$enable_event_thread_support" = "yes") + AM_CONDITIONAL(OPAL_EVENT_HAVE_THREAD_SUPPORT, + [test "$enable_event_thread_support" = "yes"]) AS_IF([test "$1" = "1"], [ # Build libevent/include/event2/event-config.h. If we # don't do it here, then libevent's Makefile.am will build From 714f203985c910015d8e7abc3168beddad8d92d4 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Aug 2018 10:38:12 -0700 Subject: [PATCH 09/10] libevent2022/configure.m4: always invoke sub-configure In order to make "make distclean" (and friends) work, we need to *always* invoke the embedded configure script -- even if we know that we're not going to use this component. But in cases where we know we're not going to use this component, we also need to avoid the side effects of the code path that is used when we *do* want to use this component. So split the two possibilities into two different macros: 1. MCA_opal_event_libevent2022_FAKE_CONFIG: which does almost nothing except invoke the underlying "configure" script. 2. MCA_opal_event_libevent2022_REAL_CONFIG: which does all the real work (including invoking the underlying "configure" script). Signed-off-by: Jeff Squyres (cherry picked from commit 69aa46e1676c00bb41e54b95bbcf1df3b00dc9c1) --- opal/mca/event/libevent2022/configure.m4 | 100 +++++++++++++++-------- 1 file changed, 65 insertions(+), 35 deletions(-) diff --git a/opal/mca/event/libevent2022/configure.m4 b/opal/mca/event/libevent2022/configure.m4 index 8f1319305bf..244fcc8ba4b 100644 --- a/opal/mca/event/libevent2022/configure.m4 +++ b/opal/mca/event/libevent2022/configure.m4 @@ -35,8 +35,8 @@ AC_DEFUN([MCA_opal_event_libevent2022_POST_CONFIG], [ # copied from libevent's Makefile.am. AC_CONFIG_COMMANDS([opal/mca/event/libevent2022/libevent/include/event2/event-config.h], - [libevent_basedir="opal/mca/event/libevent2022" - libevent_file="$libevent_basedir/libevent/include/event2/event-config.h" + [opal_event_libevent2022_basedir="opal/mca/event/libevent2022" + libevent_file="$opal_event_libevent2022_basedir/libevent/include/event2/event-config.h" rm -f "$libevent_file.new" cat > "$libevent_file.new" <> "$libevent_file.new" + -e 's/#ifndef /#ifndef _EVENT_/' < "$opal_event_libevent2022_basedir/libevent/config.h" >> "$libevent_file.new" echo "#endif" >> "$libevent_file.new" # Only make a new .h libevent_file if the @@ -75,7 +75,7 @@ EOF # Add some stuff to CPPFLAGS so that the rest of the source # tree can be built - libevent_file=$libevent_basedir/libevent + libevent_file=$opal_event_libevent2022_basedir/libevent CPPFLAGS="-I$OPAL_TOP_SRCDIR/$libevent_file -I$OPAL_TOP_SRCDIR/$libevent_file/include $CPPFLAGS" AS_IF([test "$OPAL_TOP_BUILDDIR" != "$OPAL_TOP_SRCDIR"], [CPPFLAGS="-I$OPAL_TOP_BUILDDIR/$libevent_file/include $CPPFLAGS"]) @@ -87,6 +87,9 @@ dnl MCA_event_libevent2022_CONFIG([action-if-can-compile], dnl [action-if-cant-compile]) dnl ------------------------------------------------ AC_DEFUN([MCA_opal_event_libevent2022_CONFIG],[ + AC_CONFIG_FILES([opal/mca/event/libevent2022/Makefile]) + opal_event_libevent2022_basedir="opal/mca/event/libevent2022" + # We know that the external event component will be configured # before this one because of its priority. This component is only # needed if the external component was not successful in selecting @@ -94,18 +97,37 @@ AC_DEFUN([MCA_opal_event_libevent2022_CONFIG],[ AC_MSG_CHECKING([if event external component succeeded]) AS_IF([test "$opal_event_external_support" = "yes"], [AC_MSG_RESULT([yes]) - AC_MSG_NOTICE([event:external succeeded, so this component will be skipped]) - $2], + AC_MSG_NOTICE([event:external succeeded, so this component will be configured, but then will be skipped]) + MCA_opal_event_libevent2022_FAKE_CONFIG($2)], [AC_MSG_RESULT([no]) AC_MSG_NOTICE([event:external failed, so this component will be used]) - MCA_opal_event_libevent2022_BACKEND_CONFIG($1, $2)]) + MCA_opal_event_libevent2022_REAL_CONFIG($1, $2)]) ]) -AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[ - OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save libevent_file event_args libevent_happy]) +dnl +dnl This macro is invoked when event:external is going to be used (and +dnl this component is *not* going to be used). +dnl +dnl $1: action if this component can compile +dnl (we still invoke $1 so that "make distclean" and friends will work) +dnl +AC_DEFUN([MCA_opal_event_libevent2022_FAKE_CONFIG],[ + MCA_opal_event_libevent2022_SUB_CONFIGURE([], [], []) + AC_MSG_NOTICE([remember: event:external will be used; this component was configured, but will be skipped]) + $1 +]) - AC_CONFIG_FILES([opal/mca/event/libevent2022/Makefile]) - libevent_basedir="opal/mca/event/libevent2022" +dnl +dnl This macro has a bunch of side effects. It is only meant to be +dnl invoked when this component is going to be used (i.e., when +dnl event:external is *not* going to be used). If this macro is invoked +dnl when event:external is used, Terrible Things will happen. +dnl +dnl $1: action if this component can compile +dnl $2: action if this component cannot compile +dnl +AC_DEFUN([MCA_opal_event_libevent2022_REAL_CONFIG],[ + OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save libevent_file event_args libevent_happy]) CFLAGS_save="$CFLAGS" CFLAGS="$OPAL_CFLAGS_BEFORE_PICKY $OPAL_VISIBILITY_CFLAGS" @@ -175,14 +197,14 @@ AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[ AC_MSG_RESULT([$event_args]) + # Invoke the embedded configure script. # We define "random" to be "opal_random" so that Libevent will not # use random(3) internally (and potentially unexpectedly perturb # values returned by rand(3) to the application). - CPPFLAGS="$CPPFLAGS -Drandom=opal_random" - OPAL_CONFIG_SUBDIR([$libevent_basedir/libevent], - [$event_args $opal_subdir_args 'CPPFLAGS=$CPPFLAGS'], - [libevent_happy="yes"], [libevent_happy="no"]) + MCA_opal_event_libevent2022_SUB_CONFIGURE([$event_args], + [libevent_happy="yes"], + [libevent_happy="no"]) if test "$libevent_happy" = "no"; then AC_MSG_WARN([Event library failed to configure]) AC_MSG_ERROR([Cannot continue]) @@ -200,26 +222,34 @@ AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[ # the value in the generated libevent/config.h (NOT # libevent/include/event2/event-config.h!). Otherwise, set it to # 0. - libevent_file=$libevent_basedir/libevent/config.h - - # If we are not building the internal libevent, then indicate that - # this component should not be built. NOTE: we still did all the - # above configury so that all the proper GNU Autotools - # infrastructure is setup properly (e.g., w.r.t. SUBDIRS=libevent in - # this directory's Makefile.am, we still need the Autotools "make - # distclean" infrastructure to work properly). - - AS_IF([test "$with_libevent" != "internal" && test -n "$with_libevent" && test "$with_libevent" != "yes"], - [AC_MSG_WARN([using an external libevent; disqualifying this component]) - libevent_happy=no], - - [AS_IF([test "$libevent_happy" = "yes" && test -r $libevent_file], - [OPAL_HAVE_WORKING_EVENTOPS=`grep HAVE_WORKING_EVENTOPS $libevent_file | awk '{print [$]3 }'` - $1], - [$2 - OPAL_HAVE_WORKING_EVENTOPS=0]) - ] - ) + libevent_file=$opal_event_libevent2022_basedir/libevent/config.h + + AS_IF([test "$libevent_happy" = "yes" && test -r $libevent_file], + [OPAL_HAVE_WORKING_EVENTOPS=`grep HAVE_WORKING_EVENTOPS $libevent_file | awk '{print [$]3 }'` + $1], + [$2 + OPAL_HAVE_WORKING_EVENTOPS=0]) OPAL_VAR_SCOPE_POP ]) + +dnl Call configure in the embedded libevent. +dnl +dnl We still do this so that all the proper GNU Autotools +dnl infrastructure is setup properly (e.g., w.r.t. SUBDIRS=libevent in +dnl this directorys Makefile.am, we still need the Autotools "make +dnl distclean" infrastructure to work properly). +dnl +dnl $1: extra configure arguments +dnl $2: action on success +dnl $3: action on failure +dnl +AC_DEFUN([MCA_opal_event_libevent2022_SUB_CONFIGURE],[ + # We define "random" to be "opal_random" so that Libevent will not + # use random(3) internally (and potentially unexpectedly perturb + # values returned by rand(3) to the application). + + OPAL_CONFIG_SUBDIR([$opal_event_libevent2022_basedir/libevent], + [$1 $opal_subdir_args 'CPPFLAGS=$CPPFLAGS'], + [$2], [$3]) +]) From 72e5766a56de9532a79be7002b6583acdf4e1673 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 11 Aug 2018 06:04:06 -0700 Subject: [PATCH 10/10] hwloc201/configure.m4: make it safe when used with hwloc:external The Autoconf AC_CONFIG_* macros can only be instantiated exacly once for any given file, *and* they must be in a code execution path at run time for the target file to be generated at the end of configure. For example, if you want to generate file ABC at the end of configure, you must invoke the AC_CONFIG_FILES(ABC) macro in a code path that will get executed when configure is run. That's pretty straightforward. What's not straightforward is two corner cases: 1. You cannot invoke the AC_CONFIG_FILES(ABC) macro for the same file more than once. If you do, autoreconf will fail (even before you can run configure). 2. If AC_CONFIG_FILES(ABC) is not in a code path that is executed by configure, the file ABC is not registered properly, and ABC will not be generated at the end of configure. This applies to hwloc because hwloc's HWLOC_SETUP_CORE macro calls both AC_CONFIG_FILES and AC_CONFIG_HEADER to setup its Makefiles (etc.) so that targets like "make distclean" and "make distcheck" will work properly. Hence, we *have* to invoke HWLOC_SETUP_CORE. However, the MCA_opal_hwloc_hwloc201_CONFIG macro has a few side effects. It would be nice to do able to do something like this: ``` if hwloc:extern is going to be used: Invoke minimal HWLOC_SETUP_CORE (with no side effects) else Invoke full HWLOC_SETUP_CORE (with side effects) fi ``` But we can't, because autoreconf will detect that AC_CONFIG_FILES has been invoked on the same files more than once (regardless of whether those code paths will be executed at run time or not). Kaboom. Similarly, we can't do this: ``` if hwloc:extern is not going to be used: Invoke full HWLOC_SETUP_CORE (with side effects) fi ``` Because then hwloc's AC_CONFIG_FILES won't be registered properly when hwloc:external *is* used (i.e., when the HWLOC_SETUP_CORE macro is not in a code path that is executed at run time), and targets like "make distclean" will fail because hwloc's Makefiles won't have been setup. Kaboom. But remember that the hwloc framework is a bit special: there will only ever be 2 comoponents: external and internal. External is guaranteed to be configured first because of its priority. So the internal component (i.e., this component) immediately knows if it is going to be used or not based on whether the external component configuration succeeded or failed. Specifically: regardless of whether the internal component (i.e., this component) is going to be used, we have to invoke HWLOC_SETUP_CORE. But we can manage the side effects: allow the side effects when this/internal component is going to be used, and avoid the side effects when this/internal component is not going to be used. This is a little less clean than I would have liked, but because of Autoconf's oddity about its AC_CONFIG_* macros, this is the only solution I could come up with. Signed-off-by: Jeff Squyres (cherry picked from commit 01e4570af759b113b965b63df7bfc72a78d69654) --- opal/mca/hwloc/hwloc201/configure.m4 | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/opal/mca/hwloc/hwloc201/configure.m4 b/opal/mca/hwloc/hwloc201/configure.m4 index 9da91b2c958..78b1b9856fb 100644 --- a/opal/mca/hwloc/hwloc201/configure.m4 +++ b/opal/mca/hwloc/hwloc201/configure.m4 @@ -69,27 +69,23 @@ AC_DEFUN([MCA_opal_hwloc_hwloc201_POST_CONFIG],[ # MCA_hwloc_hwloc201_CONFIG([action-if-found], [action-if-not-found]) # -------------------------------------------------------------------- AC_DEFUN([MCA_opal_hwloc_hwloc201_CONFIG],[ + # Hwloc needs to know if we have Verbs support + AC_REQUIRE([OPAL_CHECK_VERBS_DIR]) + + AC_CONFIG_FILES([opal/mca/hwloc/hwloc201/Makefile]) + + OPAL_VAR_SCOPE_PUSH([HWLOC_VERSION opal_hwloc_hwloc201_save_CPPFLAGS opal_hwloc_hwloc201_save_LDFLAGS opal_hwloc_hwloc201_save_LIBS opal_hwloc_hwloc201_save_cairo opal_hwloc_hwloc201_save_xml opal_hwloc_hwloc201_save_mode opal_hwloc_hwloc201_basedir opal_hwloc_hwloc201_file opal_hwloc_hwloc201_save_cflags CPPFLAGS_save LIBS_save opal_hwloc_external]) + # We know that the external hwloc component will be configured # before this one because of its priority. This component is only # needed if the external component was not successful in selecting - # itself. + # itself. Print out a message explaining this. AC_MSG_CHECKING([if hwloc external component succeeded]) AS_IF([test "$opal_hwloc_external_support" = "yes"], [AC_MSG_RESULT([yes]) - AC_MSG_NOTICE([hwloc:external succeeded, so this component will be skipped]) - $2], + AC_MSG_NOTICE([hwloc:external succeeded, so this component will be configured, but then will be skipped])], [AC_MSG_RESULT([no]) - AC_MSG_NOTICE([hwloc:external failed, so this component will be used]) - MCA_opal_hwloc_hwloc201_BACKEND_CONFIG($1, $2)]) -]) - -AC_DEFUN([MCA_opal_hwloc_hwloc201_BACKEND_CONFIG],[ - # Hwloc needs to know if we have Verbs support - AC_REQUIRE([OPAL_CHECK_VERBS_DIR]) - - AC_CONFIG_FILES([opal/mca/hwloc/hwloc201/Makefile]) - - OPAL_VAR_SCOPE_PUSH([HWLOC_VERSION opal_hwloc_hwloc201_save_CPPFLAGS opal_hwloc_hwloc201_save_LDFLAGS opal_hwloc_hwloc201_save_LIBS opal_hwloc_hwloc201_save_cairo opal_hwloc_hwloc201_save_xml opal_hwloc_hwloc201_save_mode opal_hwloc_hwloc201_basedir opal_hwloc_hwloc201_file opal_hwloc_hwloc201_save_cflags CPPFLAGS_save LIBS_save opal_hwloc_external]) + AC_MSG_NOTICE([hwloc:external failed, so this component will be used])]) # default to this component not providing support opal_hwloc_hwloc201_basedir=opal/mca/hwloc/hwloc201 @@ -99,8 +95,6 @@ AC_DEFUN([MCA_opal_hwloc_hwloc201_BACKEND_CONFIG],[ opal_hwloc_hwloc201_save_LDFLAGS=$LDFLAGS opal_hwloc_hwloc201_save_LIBS=$LIBS - HWLOC_SET_SYMBOL_PREFIX([opal_hwloc201_]) - # save XML or graphical options opal_hwloc_hwloc201_save_cairo=$enable_cairo opal_hwloc_hwloc201_save_xml=$enable_xml @@ -143,6 +137,12 @@ AC_DEFUN([MCA_opal_hwloc_hwloc201_BACKEND_CONFIG],[ AS_IF([test -n "$opal_datatype_cuda_CPPFLAGS"], [CPPFLAGS="$CPPFLAGS $opal_datatype_cuda_CPPFLAGS"]) + # Only set the symbol prefix if this component is being used + # (i.e., if the external component is not being used). + AS_IF([test "$opal_hwloc_external_support" = "no"], + [HWLOC_SET_SYMBOL_PREFIX([opal_hwloc201_])]) + + # Do the bulk of the hwloc core setup HWLOC_SETUP_CORE([opal/mca/hwloc/hwloc201/hwloc], [AC_MSG_CHECKING([whether hwloc configure succeeded]) AC_MSG_RESULT([yes]) @@ -202,8 +202,8 @@ AC_DEFUN([MCA_opal_hwloc_hwloc201_BACKEND_CONFIG],[ # infrastructure is setup properly (e.g., w.r.t. SUBDIRS=hwloc in # this directory's Makefile.am, we still need the Autotools "make # distclean" infrastructure to work properly). - AS_IF([test "$opal_hwloc_external" = "yes"], - [AC_MSG_WARN([using an external hwloc; disqualifying this component]) + AS_IF([test "$opal_hwloc_external_support" = "yes"], + [AC_MSG_NOTICE([using an external hwloc; disqualifying this component]) opal_hwloc_hwloc201_support=no], [AC_DEFINE([HAVE_DECL_HWLOC_OBJ_OSDEV_COPROC], [1]) AC_DEFINE([HAVE_HWLOC_TOPOLOGY_DUP], [1])])