[Pkg-cmake-team] Bug#1085509: cmake: FindMPI.cmake with openmpi 5.0.5-3 always results in RUNPATH added to shared libraries

Markus Blatt markus at dr-blatt.de
Sun Oct 20 11:09:27 BST 2024


Source: cmake
Version: 3.30.5
Severity: important

Dear Maintainer,

I have been hunting this down for a few days, as I got lintian errors in my
packges telling me that there is an rapth to /usr/lib/x86_64-linux-
gnu/openmpi/lib in the shared libraries of my packages. This happened in
experimental, but there is the same problem in sid.

The packages are using CMake as a build system, use it to search for MPI and
link to that. One use "cmake -DCMAKE_SKIP_RPATH" to tell cmake to never add any
rpath anywhere. Unfortunately this does not work for the current openmpi
version 5.0.5-3 (it worked for version 4.1.6-13.

To reproduce unpack the attached example project and execute the following
there
apt-get install chrpath mpi-default-dev cmake g++
mkdir mpi/build;
cd mpi/build;
cmake -DCMAKE_SKIP_RPATH=ON ..
make VERBOSE=1
chrpath mpi_test

In current sid/experimental you will see:

$ cmake -DCMAKE_SKIP_RPATH=ON ..
CMake Warning (dev) at CMakeLists.txt:1 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The CXX compiler identification is GNU 14.2.0
-- The C compiler identification is GNU 14.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found MPI_C: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so (found suitable
version "3.1", minimum required is "3.0")
-- Found MPI: TRUE (found suitable version "3.1", minimum required is "3.0")
found components: C
in=
INTERFACE_LINK_OPTIONS=$<HOST_LINK:SHELL:-Wl$<COMMA>-rpath
-Wl$<COMMA>/usr/lib/x86_64-linux-gnu/openmpi/lib>
INTERFACE_LINK_LIBRARIES=/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so
INTERFACE_LINK_OPTIONS=$<HOST_LINK:SHELL:-Wl$<COMMA>-rpath
-Wl$<COMMA>/usr/lib/x86_64-linux-gnu/openmpi/lib>
INTERFACE_INCLUDE_DIRECTORIES=/usr/lib/x86_64-linux-
gnu/openmpi/include;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi
INTERFACE_LINK_DIRECTORIES=
INTERFACE_COMPILE_OPTIONS=
INTERFACE_COMPILE_DEFINITIONS=
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /mpi/build-new
$ make VERBOSE=1
/usr/bin/cmake -S/mpi -B/mpi/build-new --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /mpi/build-new/CMakeFiles /mpi/build-
new//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/mpi/build-new'
make  -f CMakeFiles/mpi_test.dir/build.make
CMakeFiles/mpi_test.dir/dependmake[2]: Entering directory '/mpi/build-new'
cd /mpi/build-new && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /mpi /mpi
/mpi/build-new /mpi/build-new /mpi/build-
new/CMakeFiles/mpi_test.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/mpi/build-new'
make  -f CMakeFiles/mpi_test.dir/build.make CMakeFiles/mpi_test.dir/build
make[2]: Entering directory '/mpi/build-new'
[ 50%] Building CXX object CMakeFiles/mpi_test.dir/mpi_test.cpp.o
/usr/bin/c++ -DHAVE_MPI=1 -DMPICH_SKIP_MPICXX=1 -DMPIPP_H -DMPI_NO_CPPBIND=1
-DOMPI_SKIP_MPICXX=1 -D_MPICC_H -isystem /usr/lib/x86_64-linux-
gnu/openmpi/include -isystem /usr/lib/x86_64-linux-gnu/openmpi/include/openmpi
-MD -MT CMakeFiles/mpi_test.dir/mpi_test.cpp.o -MF
CMakeFiles/mpi_test.dir/mpi_test.cpp.o.d -o
CMakeFiles/mpi_test.dir/mpi_test.cpp.o -c /mpi/mpi_test.cpp
[100%] Linking CXX executable mpi_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/mpi_test.dir/link.txt
--verbose=1
/usr/bin/c++ -Wl,-rpath -Wl,/usr/lib/x86_64-linux-gnu/openmpi/lib
CMakeFiles/mpi_test.dir/mpi_test.cpp.o -o mpi_test  /usr/lib/x86_64-linux-
gnu/openmpi/lib/libmpi.so
make[2]: Leaving directory '/mpi/build-new'
[100%] Built target mpi_test
make[1]: Leaving directory '/mpi/build-new'
/usr/bin/cmake -E cmake_progress_start /mpi/build-new/CMakeFiles 0
chrpath mpi_test
mpi_test: RUNPATH=/usr/lib/x86_64-linux-gnu/openmpi/lib

Normally (and on stable that is the case) one would expect
INTERFACE_LINK_OPTIONS to be empty and no rpath in the built binary.

On sid this is printed:
INTERFACE_LINK_OPTIONS=$<HOST_LINK:SHELL:-Wl$<COMMA>-rpath
-Wl$<COMMA>/usr/lib/x86_64-linux-gnu/openmpi/lib>

On stable the variable is empty:
INTERFACE_LINK_OPTIONS=

My guess is that this variable on the MPI::MPI_C target results in the RUNPATH
added regardless of the value of CMAKE_SKIP_RPATH.

Note that this situation is highly problematic as any packages using cmake and
openmpi will now have an RUNPATH from openmpi in their libraries and binaries.
Lintian will report this as an error. CUrrently the only workaround seems to be
to use chrpath to remove the RUNPATH before installation.

Thanks a lot for fixing this.


-- System Information:
Debian Release: 12.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-26-amd64 (SMP w/64 CPU threads; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- no debconf information
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpi_cmake.xz
Type: application/x-tar
Size: 10240 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-cmake-team/attachments/20241020/b6322111/attachment-0001.tar>


More information about the Pkg-cmake-team mailing list