Closed joscot-linaro closed 3 weeks ago
@joscot-linaro does your system have pkg-config
installed? Our configure script uses it to grab the libfabric dependencies that look to be missing from your link step. Unfortunately there is no warning if pkg-config
is not available, and thus the dependencies are not detected.
I'll also note that even with pkg-config
installed, static linking was still not working in main
because of another change to Makefile.am
. I created #7090 to fix that problem.
does your system have pkg-config installed?
Indeed it did:
$ pkg-config --version
0.29.2
Not sure if it needed a later version etc? I was also building with trunk and it did fail, can try rebuilding mpich 4.2.2 again to just verify static linking is working without https://github.com/pmodels/mpich/pull/7090.
OK. Please send the top-level config.log
file from any build that doesn't work properly. It should have some clues about dependency handling.
Sure here it is: config.log
I do see the deps getting captured:
WRAPPER_LIBS(=' -lpthread ') does not contain '-L/home/joscot01/mpich/mpich-4.2.2/lib -libverbs -lefa -lnl-3 -lnl-route-3 -latomic -lpthread -ldl', appending
Can you add the -show
flag to your compilation like this:
mpif90 -show -static -g -O3 -fno-inline -fno-optimize-sibling-calls -o repro repro.f90 -lm -lrt
That should output the full command being executed, which should provide more clues...
Hey @raffenet,
In retrospect the error I was getting with 4.2.2
was caused when using --static
rather than -static
so might have been an issue on my part. If I use -static
it looks like a file is outputted though I do get these compiler warnings:
$ ../mpich-4.2.2/bin/mpif90 -static -g -O0 -o slow_f ~/git/forge/repo-1/examples/slow.f90 /usr/bin/ld: /home/joscot01/mpich/mpich-4.2.2/lib/libmpi.a(libfabric_la-fabric.o): in function `ofi_reg_dl_prov':
fabric.c:(.text+0x880): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /home/joscot01/mpich/mpich-4.2.2/lib/libmpi.a(src_libfabric_la-rxm_init.o): in function `rxm_getinfo':
rxm_init.c:(.text+0x5df): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libnl-3.a(libnl_3_la-utils.o): in function `nl_ip_proto2str':
(.text+0x14b1): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libnl-3.a(libnl_3_la-utils.o): in function `nl_str2ip_proto':
(.text+0x152d): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Here is the show values for both instances:
$ ../mpich-4.2.2/bin/mpif90 -show -static -g -O0 -o slow_f ~/git/forge/repo-1/examples/slow.f90
gfortran -I /home/joscot01/.conan/data/mpich/4.2.0/warwci/test/package/d2d5b79f94cad3c617bd7bb6e54ff3d8f22d3c6a/include -static -g -O0 -o slow_f /home/joscot01/git/forge/repo-1/examples/slow.f90 -I/home/joscot01/mpich/mpich-4.2.2/include -I/home/joscot01/mpich/mpich-4.2.2/include -L/home/joscot01/mpich/mpich-4.2.2/lib -lmpifort -Wl,-rpath -Wl,/home/joscot01/mpich/mpich-4.2.2/lib -Wl,--enable-new-dtags -lmpi -L/home/joscot01/mpich/mpich-4.2.2/lib -lm -lefa -libverbs -lnl-3 -lnl-route-3 -latomic -lpthread -ldl
and
$ ../mpich-4.2.2/bin/mpif90 -show --static -g -O0 -o slow_f ~/git/forge/repo-1/examples/slow.f90
gfortran -I /home/joscot01/.conan/data/mpich/4.2.0/warwci/test/package/d2d5b79f94cad3c617bd7bb6e54ff3d8f22d3c6a/include --static -g -O0 -o slow_f /home/joscot01/git/forge/repo-1/examples/slow.f90 -I/home/joscot01/mpich/mpich-4.2.2/include -I/home/joscot01/mpich/mpich-4.2.2/include -L/home/joscot01/mpich/mpich-4.2.2/lib -lmpifort -Wl,-rpath -Wl,/home/joscot01/mpich/mpich-4.2.2/lib -Wl,--enable-new-dtags -lmpi
Note: I discovered this originally on trunk/main where the "undefined references" issues do occur with -static
also, might be fixed with https://github.com/pmodels/mpich/pull/7090 though not tested
I believe #7090 fixes this issue. If it persists, please reopen.
Thanks, tested with trunk and apart from the compiler warning mentioned above, it appears static linking is no longer an issue. Thanks
Summary
This might be a configuration/install error but I am unable to compile Fortran MPI programs with the
-static
option. When attempting to do so I get the following linker errors:Affected Version
MPICH 4.2.2 built with GCC 11.4.0 on Ubuntu 22.04.
Configure line:
Reproducer
Compile the above program with the
-static
option:Worth noting this also occurs when using the
mpi_f08
interface.