Subject: bug#74010: openmpi@5 requires propagated libraries

From: Ludovic Courtès <[email-masked]>
Date: Fri, 25 Oct 2024 12:31:29 +0200

Hello,

Andreas Enge <[email-masked]> skribis:

> when updating openmpi from @4 to @5, my code does not link any more with the
> messages:
> ld: cannot find -lrdmacm: No such file or directory
> ld: cannot find -lefa: No such file or directory
> ld: cannot find -libverbs: No such file or directory
> ld: cannot find -lpsm2: No such file or directory
>
> Installing rdma-core and psm2 solves the problem.
>
> Here is a way to reproduce the problem:
> cd /tmp
> tar xvf `guix build -S cm`

Note that ‘cm’ as currently packaged does not depend on openmpi.

> Hm, I think the culprit is actually libfabric. It has these two packages as
> inputs, and contains this in its libfabric.pc:
> Libs.private:  -lpsm2 -lrdmacm -libverbs -lefa -latomic -lpthread -ldl
>
> I am not familiar with pkgconfig and do not know what distinguishes the Libs
> from the Libs.private field. But the line for linking my binary contains this
> in exactly this order:

It looks like the culprit is not pkg-config but Libtool:

--8<---------------cut here---------------start------------->8---
$ cat $(guix build openmpi@5 |grep -v debug)/lib/libmpi.la |grep ^dependency_libs
dependency_libs=' -L/gnu/store/lqgg509yb3f85ck4k6l0qp7a70bz7daa-libevent-2.1.12/lib -L/gnu/store/j9nkxb0kcx8i6fmjjlg9m5icapdnsvs8-hwloc-2.11.1-lib/lib -L/gnu/store/mqmlzbzarz2s56khlkl7xk20xlsxdf04-openpmix-4.2.8/lib -L/gnu/store/an3mrydqv3x9kzkv45jcay0jh301v06q-libpciaccess-0.16/lib -L/gnu/store/1prv14v6jfnzzg7szm57690b7fr6sx33-zlib-1.3/lib -L/gnu/store/0f6bjfrf9kkdqh27y0bab9x9b4i8w5gi-libfabric-1.22.0/lib -L/gnu/store/0qqy5010by77h33ny3gzmaqx90c93q5v-ucx-1.15.0/lib /gnu/store/1g7npkghs0b25gyk42pgcns8icy29gk3-openmpi-5.0.3/lib/libopen-pal.la /gnu/store/0f6bjfrf9kkdqh27y0bab9x9b4i8w5gi-libfabric-1.22.0/lib/libfabric.la -lrdmacm -lefa -libverbs -lpsm2 /gnu/store/zzpbp6rr43smwxzvzd4qd317z5j7qblj-gcc-11.4.0-lib/lib/libatomic.la -lpthread /gnu/store/0qqy5010by77h33ny3gzmaqx90c93q5v-ucx-1.15.0/lib/libucp.la /gnu/store/0qqy5010by77h33ny3gzmaqx90c93q5v-ucx-1.15.0/lib/libuct.la /gnu/store/0qqy5010by77h33ny3gzmaqx90c93q5v-ucx-1.15.0/lib/libucs.la /gnu/store/0qqy5010by77h33ny3gzmaqx90c93q5v-ucx-1.15.0/lib/libucm.la -lrt /gnu/store/mqmlzbzarz2s56khlkl7xk20xlsxdf04-openpmix-4.2.8/lib/libpmix.la -ldl /gnu/store/lqgg509yb3f85ck4k6l0qp7a70bz7daa-libevent-2.1.12/lib/libevent_core.la /gnu/store/lqgg509yb3f85ck4k6l0qp7a70bz7daa-libevent-2.1.12/lib/libevent_pthreads.la /gnu/store/j9nkxb0kcx8i6fmjjlg9m5icapdnsvs8-hwloc-2.11.1-lib/lib/libhwloc.la -lm /gnu/store/an3mrydqv3x9kzkv45jcay0jh301v06q-libpciaccess-0.16/lib/libpciaccess.la -lz'
$ cat $(guix build openmpi@4 |grep -v debug)/lib/libmpi.la |grep ^dependency_libs
dependency_libs=' -L/gnu/store/an3mrydqv3x9kzkv45jcay0jh301v06q-libpciaccess-0.16/lib -L/gnu/store/1prv14v6jfnzzg7szm57690b7fr6sx33-zlib-1.3/lib /gnu/store/gaip8ig4yv0hx5s60hbka6h8lkh6747y-openmpi-4.1.6/lib/libopen-rte.la /gnu/store/gaip8ig4yv0hx5s60hbka6h8lkh6747y-openmpi-4.1.6/lib/libopen-pal.la /gnu/store/j9nkxb0kcx8i6fmjjlg9m5icapdnsvs8-hwloc-2.11.1-lib/lib/libhwloc.la -lm /gnu/store/an3mrydqv3x9kzkv45jcay0jh301v06q-libpciaccess-0.16/lib/libpciaccess.la -lz /gnu/store/lqgg509yb3f85ck4k6l0qp7a70bz7daa-libevent-2.1.12/lib/libevent_core.la /gnu/store/lqgg509yb3f85ck4k6l0qp7a70bz7daa-libevent-2.1.12/lib/libevent_pthreads.la'
--8<---------------cut here---------------end--------------->8---

We need to check the build process of openmpi to see where all these
extra ‘-l’ in libmpi.la come from.

Thanks,
Ludo’.