Skip to content

Commit c5a0fc7

Browse files
committed
exported symbol name pollution test
This runs from inside a rank and uses ldd on itself to figure out what libraries to examine, then nm on those MPI libraries to look for symbols without some accepted OMPI prefix. Signed-off-by: Mark Allen <[email protected]>
1 parent 14f0066 commit c5a0fc7

File tree

5 files changed

+438
-0
lines changed

5 files changed

+438
-0
lines changed

packaging/Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2020 IBM Corporation. All rights reserved.
3+
#
4+
# $COPYRIGHT$
5+
#
6+
7+
noinst_PROGRAMS = \
8+
run_nmcheck
9+
10+
EXTRA_DIST = nmcheck_prefix.pl

packaging/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Test for exported symbol name pollution
2+
3+
This runs from inside a rank and uses ldd on itself to figure out what
4+
libraries to examine (it looks for a libmpi.so in the ldd output, and
5+
then decides that any other libraries that come from the same directory
6+
as libmpi.so must also be part of OMPI and should be examined too), then
7+
nm on those MPI libraries to look for symbols without some accepted
8+
OMPI prefix.
9+
10+
Example runs with good/bad output::
11+
12+
```
13+
% export OPAL_PREFIX=/some/path
14+
% export OLDPATH=$PATH
15+
% export PATH=$OPAL_PREFIX/bin:${PATH}
16+
% export LD_LIBRARY_PATH=$OPAL_PREFIX/lib
17+
% autoreconf -i
18+
% make
19+
20+
------------------------------------------------
21+
*** Example of a passing run:
22+
23+
% $OPAL_PREFIX/bin/mpirun -np 1 ./run_nmcheck
24+
25+
> Checking for bad symbol names:
26+
> *** checking /some/path/lib/libpmix.so.0
27+
> *** checking /some/path/lib/libopen-pal.so.0
28+
> *** checking /some/path/lib/libmpi.so.0
29+
> *** checking /some/path/lib/libmpi_mpifh.so
30+
> *** checking /some/path/lib/libmpi_usempif08.so
31+
> *** checking /some/path/lib/libmpi_usempi_ignore_tkr.so
32+
33+
------------------------------------------------
34+
*** Example of a failing run:
35+
36+
Then if I edit one of the opal C files to add a couple
37+
extraneous globally exported symbols
38+
int myfunction() { return 0; }
39+
int myglobal = 123;
40+
and rerun the test:
41+
42+
% $OPAL_PREFIX/bin/mpirun -np 1 ./run_nmcheck
43+
44+
> Checking for bad symbol names:
45+
> *** checking /u/markalle/space/Projects/OMPIDev.m/install/lib/libmpi.so.0
46+
> *** checking /u/markalle/space/Projects/OMPIDev.m/install/lib/libpmix.so.0
47+
> *** checking /u/markalle/space/Projects/OMPIDev.m/install/lib/libopen-pal.so.0
48+
> [error] myfunction
49+
> [error] myglobal
50+
> *** checking /u/markalle/space/Projects/OMPIDev.m/install/lib/libmpi_mpifh.so
51+
> *** checking /u/markalle/space/Projects/OMPIDev.m/install/lib/libmpi_usempif08.so
52+
> *** checking /u/markalle/space/Projects/OMPIDev.m/install/lib/libmpi_usempi_ignore_tkr.so
53+
> --------------------------------------------------------------------------
54+
> MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
55+
> Proc: [[27901,1],0]
56+
> Errorcode: 16
57+
>
58+
> NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
59+
> You may or may not see output from other processes, depending on
60+
> exactly when Open MPI kills them.
61+
> --------------------------------------------------------------------------
62+
```

packaging/configure.ac

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2012-2020 Cisco Systems, Inc. All rights reserved.
4+
# Copyright (c) 2020 IBM Corporatio. All rights reserved.
5+
#
6+
# $COPYRIGHT$
7+
#
8+
9+
dnl
10+
dnl Init autoconf
11+
dnl
12+
13+
AC_PREREQ([2.67])
14+
AC_INIT([packaging-test], [1.0], [http://www.open-mpi.org])
15+
AC_CONFIG_AUX_DIR([config])
16+
AC_CONFIG_MACRO_DIR([config])
17+
AC_CONFIG_SRCDIR([.])
18+
19+
echo "Configuring packaging test"
20+
21+
AM_INIT_AUTOMAKE([1.11 foreign -Wall -Werror])
22+
23+
# If Automake supports silent rules, enable them.
24+
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25+
26+
AH_TOP([/* -*- c -*-
27+
*
28+
* ompitest test suite configuation header file.
29+
* See the top-level LICENSE file for license and copyright
30+
* information.
31+
*/
32+
33+
#ifndef OMPITEST_CONFIG_H
34+
#define OMPITEST_CONFIG_H
35+
])
36+
AH_BOTTOM([#endif /* OMPITEST_CONFIG_H */])
37+
38+
dnl
39+
dnl Make automake clean emacs ~ files for "make clean"
40+
dnl
41+
42+
CLEANFILES="*~"
43+
AC_SUBST(CLEANFILES)
44+
45+
dnl
46+
dnl Get various programs
47+
dnl Bias towards mpicc/mpic++/mpif77
48+
dnl C compiler
49+
dnl
50+
51+
if test "$CC" != ""; then
52+
BASE="`basename $CC`"
53+
else
54+
BASE=
55+
fi
56+
if test "$BASE" = "" -o "$BASE" = "." -o "$BASE" = "cc" -o \
57+
"$BASE" = "gcc" -o "$BASE" = "xlc" -o "$BASE" = "pgcc" -o \
58+
"$BASE" = "icc"; then
59+
AC_CHECK_PROG(HAVE_MPICC, mpicc, yes, no)
60+
if test "$HAVE_MPICC" = "yes"; then
61+
CC=mpicc
62+
export CC
63+
fi
64+
fi
65+
66+
CFLAGS_save=$CFLAGS
67+
AC_PROG_CC
68+
CFLAGS=$CFLAGS_save
69+
70+
dnl
71+
dnl Fortran compiler
72+
dnl
73+
74+
if test "$FC" != ""; then
75+
BASE="`basename $FC`"
76+
else
77+
BASE=
78+
fi
79+
if test "$BASE" = "" -o "$BASE" = "." -o "$BASE" = "f77" -o \
80+
"$BASE" = "g77" -o "$BASE" = "f90" -o "$BASE" = "g90" -o \
81+
"$BASE" = "xlf" -o "$BASE" = "ifc" -o "$BASE" = "pgf77"; then
82+
AC_CHECK_PROG(HAVE_MPIFORT, mpifort, yes, no)
83+
AS_IF([test "$HAVE_MPIFORT" = "yes"],
84+
[FC=mpifort],
85+
[AC_CHECK_PROG([HAVE_MPIF90], mpif90, yes, no)
86+
AS_IF([test "$HAVE_MPIF90" = "yes"],
87+
[FC=mpif90],
88+
[AC_CHECK_PROG([HAVE_MPIF77], mpif77, yes, no)
89+
AS_IF([test "$HAVE_MPIF77" = "yes"],
90+
[FC=mpif77],
91+
[AC_MSG_WARN([Cannot find a suitable MPI compiler])
92+
AC_MSG_ERROR([Cannot continue])
93+
])
94+
])
95+
])
96+
export FC
97+
fi
98+
99+
FCFLAGS_save=$FCFLAGS
100+
AC_PROG_FC
101+
FCFLAGS=$FCFLAGS_save
102+
103+
dnl
104+
dnl Because these are meant to be used for debugging, after all
105+
dnl
106+
107+
if test -z "$CFLAGS"; then
108+
CFLAGS="-g"
109+
fi
110+
if test -z "$FCFLAGS"; then
111+
FCFLAGS="-g";
112+
fi
113+
AC_SUBST(FCFLAGS)
114+
if test -z "$FFLAGS"; then
115+
FFLAGS="-g";
116+
fi
117+
AC_SUBST(FFLAGS)
118+
119+
dnl
120+
dnl Ensure that we can compile and link a C MPI program
121+
dnl
122+
123+
AC_LANG_PUSH([C])
124+
AC_CHECK_HEADERS(mpi.h)
125+
126+
AC_MSG_CHECKING([if linking MPI program works])
127+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>
128+
]],
129+
[[MPI_Comm a = MPI_COMM_WORLD]])],
130+
[AC_MSG_RESULT([yes])],
131+
[AC_MSG_RESULT([no])
132+
AC_MSG_WARN([Simple MPI program fails to link])
133+
AC_MSG_ERROR([Cannot continue])
134+
])
135+
AC_LANG_POP([C])
136+
137+
dnl
138+
dnl Party on
139+
dnl
140+
141+
AC_CONFIG_FILES([
142+
Makefile
143+
])
144+
AC_OUTPUT

0 commit comments

Comments
 (0)