OpenMPI 4.0.3 forgets to link open-pal

Bug #1941786 reported by Axel Huebl
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openmpi (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hi,

I am trying to compile a C++ program with CMake 3.16.3 on Ubuntu 20.04 LTS, which ships OpenMPI 4.0.3.

I realized that the
  mpic++ --showme:link
flags forget to link `-lopen-pal`, which is part of the OpenMPI lib dir.
  -pthread -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi

Following that, a CMake CXX program compiled with clang++ that checks for `find_package(MPI REQUIRED)` will error out with:
```
-- Found MPI_C: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so (found version "3.1")
-- Could NOT find MPI_CXX (missing: MPI_CXX_WORKS)
CMake Error at /usr/local/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
-- Configuring incomplete, errors occurred!
  Could NOT find MPI (missing: MPI_CXX_FOUND CXX) (found version "3.1")
```

The reason for that is in the compile check
```
/opt/rocm/llvm/bin/clang++ -pthread CMakeFiles/cmTC_abf94.dir/test_mpi.cpp.o -o cmTC_abf94 -Wl,-rpath,/usr/lib/x86_64-linux-gnu/openmpi/lib /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so
ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_class_init_epoch [--no-allow-shlib-undefined]
ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_list_item_t_class [--no-allow-shlib-undefined]
ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_class_initialize [--no-allow-shlib-undefined]
ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_uses_threads [--no-allow-shlib-undefined]
```

where the linker refuses the missing lib and fails the check.

The solution to this is to make sure that
  mpic++ --showme:link
appends
  -lopen-pal
as well.

User-side work-around until fix is applied:
  export LDFLAGS="-lopen-pal"

Revision history for this message
Axel Huebl (axel-huebl) wrote :
Revision history for this message
Axel Huebl (axel-huebl) wrote :

There is a patch available in
  https://github.com/open-mpi/ompi/pull/9077
which will be part of OpenMPI 4.0.7

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.