From 17aa64e43825dd27148fc47d3f8f5694fc091d38 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Aug 2018 10:30:04 -0700 Subject: [PATCH 1/4] libevent2022/configure.m4: minor comment cleanup Change # -> dnl. No code or logic changes. Signed-off-by: Jeff Squyres --- 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 80df3f040be2b26162df9cc73a0cfd9e3d11732d Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Aug 2018 10:30:45 -0700 Subject: [PATCH 2/4] libevent2022/configure.m4: trivial cleanup Put argument to AM_CONDITIONAL inside []. No code or logic changes. Signed-off-by: Jeff Squyres --- 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 69aa46e1676c00bb41e54b95bbcf1df3b00dc9c1 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Aug 2018 10:38:12 -0700 Subject: [PATCH 3/4] 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 --- 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 01e4570af759b113b965b63df7bfc72a78d69654 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 11 Aug 2018 06:04:06 -0700 Subject: [PATCH 4/4] 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 --- 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])])