Skip to content

Commit def89b6

Browse files
AMPI: Check for RTLD_DEEPBIND at configure time
1 parent 65f27fe commit def89b6

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

cmake/detect-features-c.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ check_symbol_exists(pthread_setaffinity_np pthread.h HAVE_DECL_PTHREAD_SETAFFINI
121121
set(CMK_HAS_PTHREAD_SETAFFINITY ${HAVE_DECL_PTHREAD_SETAFFINITY_NP})
122122
check_symbol_exists(pthread_spin_lock pthread.h CMK_HAS_SPINLOCK)
123123
check_symbol_exists(pvalloc malloc.h CMK_HAS_PVALLOC)
124+
check_symbol_exists(RTLD_DEEPBIND dlfcn.h CMK_HAS_RTLD_DEEPBIND)
124125
check_symbol_exists(RTLD_DEFAULT dlfcn.h CMK_HAS_RTLD_DEFAULT)
125126
check_symbol_exists(RTLD_NEXT dlfcn.h CMK_HAS_RTLD_NEXT)
126127
check_function_exists(readlink CMK_HAS_READLINK)

src/libs/ck-libs/ampi/ampi_globals_pip.C

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ void AMPI_Node_Setup(int numranks)
3939
for (int myrank = 0; myrank < numranks; ++myrank)
4040
{
4141
const Lmid_t lmid = LM_ID_NEWLM;
42-
const int flags = RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND;
42+
int flags = RTLD_NOW|RTLD_LOCAL;
43+
#if CMK_HAS_RTLD_DEEPBIND
44+
flags |= RTLD_DEEPBIND;
45+
#endif
4346
SharedObject myexe = dlmopen(lmid, binary_path.c_str(), flags);
4447

4548
if (myexe == nullptr)

src/scripts/configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,23 @@ then
21772177
AC_DEFINE_UNQUOTED(CMK_DLL_USE_DLOPEN, 1, [dlopen])
21782178
fi
21792179

2180+
cat > $tc <<EOT
2181+
#ifndef _GNU_SOURCE
2182+
# define _GNU_SOURCE
2183+
#endif
2184+
#ifndef __USE_GNU
2185+
# define __USE_GNU
2186+
#endif
2187+
#include <dlfcn.h>
2188+
#include <stddef.h>
2189+
int main()
2190+
{
2191+
return dlopen("", RTLD_DEEPBIND) == NULL;
2192+
}
2193+
EOT
2194+
test_cc "whether has RTLD_DEEPBIND" "yes" "no" ""
2195+
AC_DEFINE_UNQUOTED(CMK_HAS_RTLD_DEEPBIND, $pass, [whether has RTLD_DEEPBIND])
2196+
21802197
cat > $tc <<EOT
21812198
#ifndef _GNU_SOURCE
21822199
# define _GNU_SOURCE

0 commit comments

Comments
 (0)