From 22d8fa197b73eff7afc6d5fd11a99ced396c388a Mon Sep 17 00:00:00 2001 From: Joshua Hursey Date: Tue, 5 May 2020 12:08:52 -0400 Subject: [PATCH 1/5] event/external: Fix typo in LDFLAGS vs LIBS var before check * This should have been `LDFLAGS` not `LIBS`. Either works, but `LDFLAGS` is more correct. We should also include `CPPFLAGS` just in case the header is important to the check. Signed-off-by: Joshua Hursey --- opal/mca/event/external/configure.m4 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/opal/mca/event/external/configure.m4 b/opal/mca/event/external/configure.m4 index 15313db50a3..0bdd87c8b20 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -6,6 +6,7 @@ # and Technology (RIST). All rights reserved. # # Copyright (c) 2017-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2020 IBM Corporation. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -115,11 +116,15 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ [opal_event_external_support=yes], [opal_event_external_support=no]) + AS_IF([test "$opal_event_external_support" = "yes"], + [LDFLAGS="$opal_event_external_LDFLAGS $LDFLAGS" + CPPFLAGS="$opal_event_external_CPPFLAGS $CPPFLAGS"], + []) + 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]) From fc4199e3ba567a672ce1da0dc46efbfd996d71f6 Mon Sep 17 00:00:00 2001 From: Joshua Hursey Date: Tue, 5 May 2020 11:51:51 -0400 Subject: [PATCH 2/5] Add checks for libevent.so conflict with LSF * LSF ships a `libevent.so` that is no related to the `libevent.so` shipped with Libevent. * Add some checks to the configure logic to detect scenarios where this conflict can be detected, and provide the user with a descriptive warning message. - When detected by `event/external` this is just a warning since the internal component may be able to be used instead. - This happens when the user supplies the LSF path via the `LDFLAGS` envar instead of via `--with-lsf-libdir`. - When detected by a LSF component and LSF was explicitly requested then this becomes an error. Otherwise it will just print the warning and that component will fail to build. Signed-off-by: Joshua Hursey --- config/orte_check_lsf.m4 | 69 +++++++++++++++++++++++++++- opal/mca/event/external/configure.m4 | 29 +++++++++++- 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/config/orte_check_lsf.m4 b/config/orte_check_lsf.m4 index 0de332ca566..eefc819852d 100644 --- a/config/orte_check_lsf.m4 +++ b/config/orte_check_lsf.m4 @@ -15,7 +15,7 @@ dnl Copyright (c) 2015 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. dnl Copyright (c) 2016 Los Alamos National Security, LLC. All rights dnl reserved. -dnl Copyright (c) 2017 IBM Corporation. All rights reserved. +dnl Copyright (c) 2017-2020 IBM Corporation. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -120,6 +120,73 @@ AC_DEFUN([ORTE_CHECK_LSF],[ [orte_check_lsf_happy="yes"], [orte_check_lsf_happy="no"])]) + + # Some versions of LSF ship with a libevent.so in their library path. + # This is _not_ a copy of Libevent, but something specific to their project. + # The Open MPI components should not need to link against LSF's libevent.so + # However, the presence of it in the linker search path can cause a problem + # if there is a system installed Libevent and Open MPI chooses the 'external' + # event component prior to this stage. + # + # Add a check here to see if we are in a scenario where the two are conflicting. + # In which case the earlier checks for successful compile of an LSF program will + # have failed with messages like: + # lib64/libevent_pthreads.so: undefined reference to `evthread_set_condition_callbacks' + # lib64/libevent_pthreads.so: undefined reference to `event_mm_malloc_' + # lib64/libevent_pthreads.so: undefined reference to `event_mm_free_' + # lib64/libevent_pthreads.so: undefined reference to `evthread_set_id_callback' + # lib64/libevent_pthreads.so: undefined reference to `evthread_set_lock_callbacks' + # Because it picked up -levent from LSF, but -levent_pthreads from Libevent. + # + # So look for a function that libevent_pthreads is looking for from libevent.so. + # If it does appears then we have the correct libevent.so, otherwise then we picked + # up the LSF version and a conflict has been detected. + # If the external libevent component used 'event_core' instead of 'event' + orte_check_lsf_event_conflict=na + # Split libs into an array, see if -levent is in that list + orte_check_lsf_libevent_present=`echo $LIBS | awk '{split([$]0, a, " "); {for (k in a) {if (a[[k]] == "-levent") {print a[[k]]}}}}' | wc -l` + AS_IF([test "$orte_check_lsf_happy" = "no"], + [AS_IF([test "$opal_event_external_support" = "yes" && test "$orte_check_lsf_libevent_present" != 0], + [AS_IF([test "$orte_check_lsf_libdir" = "" ], + [], + [LDFLAGS="$LDFLAGS -L$orte_check_lsf_libdir"]) + # Note that we do not want to set LIBS here to include -llsf since + # the check is not for an LSF library, but for the conflict with + # LDFLAGS. + AC_CHECK_LIB([event], [evthread_set_condition_callbacks], + [AC_MSG_CHECKING([for libevent conflict]) + AC_MSG_RESULT([No. The correct libevent.so was linked.]) + orte_check_lsf_event_conflict=no], + [AC_MSG_CHECKING([for libevent conflict]) + AC_MSG_RESULT([Yes. A wrong libevent.so was linked.]) + orte_check_lsf_event_conflict=yes]) + ], + [AC_MSG_CHECKING([for libevent conflict]) + AC_MSG_RESULT([No. Internal Libevent or libevent_core is being used.]) + orte_check_lsf_event_conflict=na])], + [AC_MSG_CHECKING([for libevent conflict]) + AC_MSG_RESULT([No. LSF checks passed.]) + orte_check_lsf_event_conflict=na]) + + AS_IF([test "$orte_check_lsf_event_conflict" = "yes"], + [AC_MSG_WARN([===================================================================]) + AC_MSG_WARN([Conflicting libevent.so libraries detected on the system.]) + AC_MSG_WARN([]) + AC_MSG_WARN([A system-installed Libevent library was detected and the Open MPI]) + AC_MSG_WARN([build system chose to use the 'external' component expecting to]) + AC_MSG_WARN([link against the Libevent in the linker search path.]) + AC_MSG_WARN([LSF provides a libevent.so that is not from Libevent in its]) + AC_MSG_WARN([library path. At this point the linker is attempting to resolve]) + AC_MSG_WARN([Libevent symbols using the LSF library because of the lack of]) + AC_MSG_WARN([an explicit linker path pointing to the system-installed Libevent.]) + AC_MSG_WARN([]) + AC_MSG_WARN([To resolve this issue either (A) explicitly pass the Libevent]) + AC_MSG_WARN([library path on the configure line (--with-libevent-libdir), or]) + AC_MSG_WARN([(B) use the internal libevent by requesting it from configure ]) + AC_MSG_WARN([with the --with-libevent=internal option.]) + AC_MSG_WARN([===================================================================]) + ]) + CPPFLAGS="$orte_check_lsf_$1_save_CPPFLAGS" LDFLAGS="$orte_check_lsf_$1_save_LDFLAGS" LIBS="$orte_check_lsf_$1_save_LIBS" diff --git a/opal/mca/event/external/configure.m4 b/opal/mca/event/external/configure.m4 index 0bdd87c8b20..6e38b7d1e9e 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -116,10 +116,35 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ [opal_event_external_support=yes], [opal_event_external_support=no]) + # Check to see if the above check failed because it conflicted with LSF's libevent.so + # This can happen if LSF's library is in the LDFLAGS envar or default search + # path. The 'event_fini' function is only defined in LSF's libevent.so and not + # in Libevent's libevent.so + AS_IF([test "$opal_event_external_support" = "no"], + [AC_CHECK_LIB([event], [event_fini], + [AC_MSG_WARN([===================================================================]) + AC_MSG_WARN([Possible conflicting libevent.so libraries detected on the system.]) + AC_MSG_WARN([]) + AC_MSG_WARN([LSF provides a libevent.so that is not from Libevent in its]) + AC_MSG_WARN([library path. It is possible that you have installed Libevent]) + AC_MSG_WARN([on the system, but the linker is picking up the wrong version.]) + AC_MSG_WARN([]) + AC_MSG_WARN([Configure may continue and attempt to use the 'internal' libevent]) + AC_MSG_WARN([instead of the 'external' libevent if you did not explicitly request]) + AC_MSG_WARN([the 'external' component.]) + AC_MSG_WARN([]) + AC_MSG_WARN([If your intention was to use the 'external' libevent then you need]) + AC_MSG_WARN([to address this linker path ordering issue. One way to do so is]) + AC_MSG_WARN([to make sure the libevent system library path occurs before the]) + AC_MSG_WARN([LSF library path.]) + AC_MSG_WARN([===================================================================]) + opal_event_external_support=no + ]) + ]) + AS_IF([test "$opal_event_external_support" = "yes"], [LDFLAGS="$opal_event_external_LDFLAGS $LDFLAGS" - CPPFLAGS="$opal_event_external_CPPFLAGS $CPPFLAGS"], - []) + CPPFLAGS="$opal_event_external_CPPFLAGS $CPPFLAGS"]) AS_IF([test "$opal_event_external_support" = "yes"], [# Ensure that this libevent has the symbol From 886f41fe3381a338eac215f26360980c612e6bb8 Mon Sep 17 00:00:00 2001 From: Joshua Hursey Date: Wed, 6 May 2020 11:35:22 -0400 Subject: [PATCH 3/5] Move from legacy -levent to recommended -levent_core * `libevent_core.so` contains the core functionality that we depend upon - `libevent.so` library has been identified as the legacy target. - `libevent_core.so` exists as far back as Libevent 2.0.5 (oldest supported by OMPI) * `libevent_pthreads.so` can work with either `-levent` or `-levent_core` Signed-off-by: Joshua Hursey --- 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 6e38b7d1e9e..daaac5fa27b 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -108,7 +108,7 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ OPAL_CHECK_PACKAGE([opal_event_external], [event2/event.h], - [event], + [event_core], [event_config_new], [-levent_pthreads], [$opal_event_dir], @@ -150,7 +150,7 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ [# Ensure that this libevent has the symbol # "evthread_set_lock_callbacks", which will only exist if # libevent was configured with thread support. - AC_CHECK_LIB([event], [evthread_set_lock_callbacks], + AC_CHECK_LIB([event_core], [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]) From 7dba35f78515b1ed17f1d3f504c45f431225247c Mon Sep 17 00:00:00 2001 From: Joshua Hursey Date: Mon, 18 May 2020 15:08:10 -0400 Subject: [PATCH 4/5] A slightly stronger check for LSF's libevent Signed-off-by: Joshua Hursey (cherry picked from commit 05e095a1eef737849750a5f4f649e72c393eeb74) --- 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 daaac5fa27b..826fc880cb9 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -118,10 +118,10 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ # Check to see if the above check failed because it conflicted with LSF's libevent.so # This can happen if LSF's library is in the LDFLAGS envar or default search - # path. The 'event_fini' function is only defined in LSF's libevent.so and not + # path. The 'event_getcode4name' function is only defined in LSF's libevent.so and not # in Libevent's libevent.so AS_IF([test "$opal_event_external_support" = "no"], - [AC_CHECK_LIB([event], [event_fini], + [AC_CHECK_LIB([event], [event_getcode4name], [AC_MSG_WARN([===================================================================]) AC_MSG_WARN([Possible conflicting libevent.so libraries detected on the system.]) AC_MSG_WARN([]) From 76500e6cf87178d5a83fb2b8bde83b49cab7d205 Mon Sep 17 00:00:00 2001 From: Joshua Hursey Date: Mon, 18 May 2020 15:10:46 -0400 Subject: [PATCH 5/5] Fix LSF configure check for libevent conflict * Want to make sure that the result from `wc` is trimmed of spaces, so the `0` check returns properly * Add a few more comments, and fix wording in the warning message. Signed-off-by: Joshua Hursey --- config/orte_check_lsf.m4 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/config/orte_check_lsf.m4 b/config/orte_check_lsf.m4 index eefc819852d..50f269f912a 100644 --- a/config/orte_check_lsf.m4 +++ b/config/orte_check_lsf.m4 @@ -144,21 +144,25 @@ AC_DEFUN([ORTE_CHECK_LSF],[ # If the external libevent component used 'event_core' instead of 'event' orte_check_lsf_event_conflict=na # Split libs into an array, see if -levent is in that list - orte_check_lsf_libevent_present=`echo $LIBS | awk '{split([$]0, a, " "); {for (k in a) {if (a[[k]] == "-levent") {print a[[k]]}}}}' | wc -l` + orte_check_lsf_libevent_present=`echo "$LIBS" | awk '{split([$]0, a, " "); {for (k in a) {if (a[[k]] == "-levent") {print a[[k]]}}}}' | wc -l | tr -d '[[:space:]]'` + # (1) LSF check must have failed above. We need to know why... AS_IF([test "$orte_check_lsf_happy" = "no"], - [AS_IF([test "$opal_event_external_support" = "yes" && test "$orte_check_lsf_libevent_present" != 0], + [# (2) If there is a -levent in the $LIBS then that might be the problem + AS_IF([test "$opal_event_external_support" = "yes" && test "$orte_check_lsf_libevent_present" != "0"], [AS_IF([test "$orte_check_lsf_libdir" = "" ], [], [LDFLAGS="$LDFLAGS -L$orte_check_lsf_libdir"]) # Note that we do not want to set LIBS here to include -llsf since # the check is not for an LSF library, but for the conflict with # LDFLAGS. + # (3) Check to see if the -levent is from Libevent (check for a symbol it has) AC_CHECK_LIB([event], [evthread_set_condition_callbacks], [AC_MSG_CHECKING([for libevent conflict]) AC_MSG_RESULT([No. The correct libevent.so was linked.]) orte_check_lsf_event_conflict=no], - [AC_MSG_CHECKING([for libevent conflict]) - AC_MSG_RESULT([Yes. A wrong libevent.so was linked.]) + [# (4) The libevent.so is not from Libevent. Warn the user. + AC_MSG_CHECKING([for libevent conflict]) + AC_MSG_RESULT([Yes. Detected a libevent.so that is not from Libevent.]) orte_check_lsf_event_conflict=yes]) ], [AC_MSG_CHECKING([for libevent conflict]) @@ -175,6 +179,8 @@ AC_DEFUN([ORTE_CHECK_LSF],[ AC_MSG_WARN([A system-installed Libevent library was detected and the Open MPI]) AC_MSG_WARN([build system chose to use the 'external' component expecting to]) AC_MSG_WARN([link against the Libevent in the linker search path.]) + AC_MSG_WARN([If LSF is present on the system and in the default search path then]) + AC_MSG_WARN([it _may be_ the source of the conflict.]) AC_MSG_WARN([LSF provides a libevent.so that is not from Libevent in its]) AC_MSG_WARN([library path. At this point the linker is attempting to resolve]) AC_MSG_WARN([Libevent symbols using the LSF library because of the lack of])