Skip to content

Commit 63cc3da

Browse files
authored
Merge pull request #7698 from jjhursey/v4-fix-lsf-libevent
Add checks for libevent.so conflict with LSF
2 parents f562f84 + 76500e6 commit 63cc3da

File tree

2 files changed

+107
-4
lines changed

2 files changed

+107
-4
lines changed

config/orte_check_lsf.m4

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dnl Copyright (c) 2015 Research Organization for Information Science
1515
dnl and Technology (RIST). All rights reserved.
1616
dnl Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1717
dnl reserved.
18-
dnl Copyright (c) 2017 IBM Corporation. All rights reserved.
18+
dnl Copyright (c) 2017-2020 IBM Corporation. All rights reserved.
1919
dnl $COPYRIGHT$
2020
dnl
2121
dnl Additional copyrights may follow
@@ -120,6 +120,79 @@ AC_DEFUN([ORTE_CHECK_LSF],[
120120
[orte_check_lsf_happy="yes"],
121121
[orte_check_lsf_happy="no"])])
122122

123+
124+
# Some versions of LSF ship with a libevent.so in their library path.
125+
# This is _not_ a copy of Libevent, but something specific to their project.
126+
# The Open MPI components should not need to link against LSF's libevent.so
127+
# However, the presence of it in the linker search path can cause a problem
128+
# if there is a system installed Libevent and Open MPI chooses the 'external'
129+
# event component prior to this stage.
130+
#
131+
# Add a check here to see if we are in a scenario where the two are conflicting.
132+
# In which case the earlier checks for successful compile of an LSF program will
133+
# have failed with messages like:
134+
# lib64/libevent_pthreads.so: undefined reference to `evthread_set_condition_callbacks'
135+
# lib64/libevent_pthreads.so: undefined reference to `event_mm_malloc_'
136+
# lib64/libevent_pthreads.so: undefined reference to `event_mm_free_'
137+
# lib64/libevent_pthreads.so: undefined reference to `evthread_set_id_callback'
138+
# lib64/libevent_pthreads.so: undefined reference to `evthread_set_lock_callbacks'
139+
# Because it picked up -levent from LSF, but -levent_pthreads from Libevent.
140+
#
141+
# So look for a function that libevent_pthreads is looking for from libevent.so.
142+
# If it does appears then we have the correct libevent.so, otherwise then we picked
143+
# up the LSF version and a conflict has been detected.
144+
# If the external libevent component used 'event_core' instead of 'event'
145+
orte_check_lsf_event_conflict=na
146+
# Split libs into an array, see if -levent is in that list
147+
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:]]'`
148+
# (1) LSF check must have failed above. We need to know why...
149+
AS_IF([test "$orte_check_lsf_happy" = "no"],
150+
[# (2) If there is a -levent in the $LIBS then that might be the problem
151+
AS_IF([test "$opal_event_external_support" = "yes" && test "$orte_check_lsf_libevent_present" != "0"],
152+
[AS_IF([test "$orte_check_lsf_libdir" = "" ],
153+
[],
154+
[LDFLAGS="$LDFLAGS -L$orte_check_lsf_libdir"])
155+
# Note that we do not want to set LIBS here to include -llsf since
156+
# the check is not for an LSF library, but for the conflict with
157+
# LDFLAGS.
158+
# (3) Check to see if the -levent is from Libevent (check for a symbol it has)
159+
AC_CHECK_LIB([event], [evthread_set_condition_callbacks],
160+
[AC_MSG_CHECKING([for libevent conflict])
161+
AC_MSG_RESULT([No. The correct libevent.so was linked.])
162+
orte_check_lsf_event_conflict=no],
163+
[# (4) The libevent.so is not from Libevent. Warn the user.
164+
AC_MSG_CHECKING([for libevent conflict])
165+
AC_MSG_RESULT([Yes. Detected a libevent.so that is not from Libevent.])
166+
orte_check_lsf_event_conflict=yes])
167+
],
168+
[AC_MSG_CHECKING([for libevent conflict])
169+
AC_MSG_RESULT([No. Internal Libevent or libevent_core is being used.])
170+
orte_check_lsf_event_conflict=na])],
171+
[AC_MSG_CHECKING([for libevent conflict])
172+
AC_MSG_RESULT([No. LSF checks passed.])
173+
orte_check_lsf_event_conflict=na])
174+
175+
AS_IF([test "$orte_check_lsf_event_conflict" = "yes"],
176+
[AC_MSG_WARN([===================================================================])
177+
AC_MSG_WARN([Conflicting libevent.so libraries detected on the system.])
178+
AC_MSG_WARN([])
179+
AC_MSG_WARN([A system-installed Libevent library was detected and the Open MPI])
180+
AC_MSG_WARN([build system chose to use the 'external' component expecting to])
181+
AC_MSG_WARN([link against the Libevent in the linker search path.])
182+
AC_MSG_WARN([If LSF is present on the system and in the default search path then])
183+
AC_MSG_WARN([it _may be_ the source of the conflict.])
184+
AC_MSG_WARN([LSF provides a libevent.so that is not from Libevent in its])
185+
AC_MSG_WARN([library path. At this point the linker is attempting to resolve])
186+
AC_MSG_WARN([Libevent symbols using the LSF library because of the lack of])
187+
AC_MSG_WARN([an explicit linker path pointing to the system-installed Libevent.])
188+
AC_MSG_WARN([])
189+
AC_MSG_WARN([To resolve this issue either (A) explicitly pass the Libevent])
190+
AC_MSG_WARN([library path on the configure line (--with-libevent-libdir), or])
191+
AC_MSG_WARN([(B) use the internal libevent by requesting it from configure ])
192+
AC_MSG_WARN([with the --with-libevent=internal option.])
193+
AC_MSG_WARN([===================================================================])
194+
])
195+
123196
CPPFLAGS="$orte_check_lsf_$1_save_CPPFLAGS"
124197
LDFLAGS="$orte_check_lsf_$1_save_LDFLAGS"
125198
LIBS="$orte_check_lsf_$1_save_LIBS"

opal/mca/event/external/configure.m4

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# and Technology (RIST). All rights reserved.
77
#
88
# Copyright (c) 2017-2018 Intel, Inc. All rights reserved.
9+
# Copyright (c) 2020 IBM Corporation. All rights reserved.
910
# $COPYRIGHT$
1011
#
1112
# Additional copyrights may follow
@@ -107,20 +108,49 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[
107108

108109
OPAL_CHECK_PACKAGE([opal_event_external],
109110
[event2/event.h],
110-
[event],
111+
[event_core],
111112
[event_config_new],
112113
[-levent_pthreads],
113114
[$opal_event_dir],
114115
[$opal_event_libdir],
115116
[opal_event_external_support=yes],
116117
[opal_event_external_support=no])
117118

119+
# Check to see if the above check failed because it conflicted with LSF's libevent.so
120+
# This can happen if LSF's library is in the LDFLAGS envar or default search
121+
# path. The 'event_getcode4name' function is only defined in LSF's libevent.so and not
122+
# in Libevent's libevent.so
123+
AS_IF([test "$opal_event_external_support" = "no"],
124+
[AC_CHECK_LIB([event], [event_getcode4name],
125+
[AC_MSG_WARN([===================================================================])
126+
AC_MSG_WARN([Possible conflicting libevent.so libraries detected on the system.])
127+
AC_MSG_WARN([])
128+
AC_MSG_WARN([LSF provides a libevent.so that is not from Libevent in its])
129+
AC_MSG_WARN([library path. It is possible that you have installed Libevent])
130+
AC_MSG_WARN([on the system, but the linker is picking up the wrong version.])
131+
AC_MSG_WARN([])
132+
AC_MSG_WARN([Configure may continue and attempt to use the 'internal' libevent])
133+
AC_MSG_WARN([instead of the 'external' libevent if you did not explicitly request])
134+
AC_MSG_WARN([the 'external' component.])
135+
AC_MSG_WARN([])
136+
AC_MSG_WARN([If your intention was to use the 'external' libevent then you need])
137+
AC_MSG_WARN([to address this linker path ordering issue. One way to do so is])
138+
AC_MSG_WARN([to make sure the libevent system library path occurs before the])
139+
AC_MSG_WARN([LSF library path.])
140+
AC_MSG_WARN([===================================================================])
141+
opal_event_external_support=no
142+
])
143+
])
144+
145+
AS_IF([test "$opal_event_external_support" = "yes"],
146+
[LDFLAGS="$opal_event_external_LDFLAGS $LDFLAGS"
147+
CPPFLAGS="$opal_event_external_CPPFLAGS $CPPFLAGS"])
148+
118149
AS_IF([test "$opal_event_external_support" = "yes"],
119150
[# Ensure that this libevent has the symbol
120151
# "evthread_set_lock_callbacks", which will only exist if
121152
# libevent was configured with thread support.
122-
LIBS="$opal_event_external_LDFLAGS $LIBS"
123-
AC_CHECK_LIB([event], [evthread_set_lock_callbacks],
153+
AC_CHECK_LIB([event_core], [evthread_set_lock_callbacks],
124154
[],
125155
[AC_MSG_WARN([External libevent does not have thread support])
126156
AC_MSG_WARN([Open MPI requires libevent to be compiled with])

0 commit comments

Comments
 (0)