mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.59k stars 1.63k forks source link

Linking with OpenMPI fails #9422

Open cschwan opened 3 years ago

cschwan commented 3 years ago

Describe the bug Compiling a program with meson and OpenMPI 4.0.5 fails with the following error (I added linebreaks for better visibility):

FAILED: src/libhep-vbs.so
c++  -o src/libhep-vbs.so 
src/libhep-vbs.so.p/a4as2_matrix_elements.cpp.o 
src/libhep-vbs.so.p/a4as3_matrix_elements.cpp.o 
src/libhep-vbs.so.p/a5as1_matrix_elements.cpp.o 
src/libhep-vbs.so.p/a6as0_matrix_elements.cpp.o 
src/libhep-vbs.so.p/a6as1_matrix_elements.cpp.o 
src/libhep-vbs.so.p/cutter.cpp.o 
src/libhep-vbs.so.p/dss_wpwp_distributions.cpp.o 
src/libhep-vbs.so.p/ew_logs.cpp.o src/libhep-vbs.so.p/me_interface.cpp.o 
src/libhep-vbs.so.p/nfpc.cpp.o 
src/libhep-vbs.so.p/pa_matrix_elements.cpp.o 
src/libhep-vbs.so.p/scale_function.cpp.o 
src/libhep-vbs.so.p/set_ol_parameters.cpp.o 
src/libhep-vbs.so.p/settings.cpp.o 
src/libhep-vbs.so.p/wba_matrix_elements.cpp.o 
src/libhep-vbs.so.p/wpwp_cutter.cpp.o 
src/libhep-vbs.so.p/wpwp_distributions.cpp.o 
src/libhep-vbs.so.p/wpz_cutter.cpp.o 
src/libhep-vbs.so.p/wpz_distributions.cpp.o 
src/libhep-vbs.so.p/ww_ww_amp.cpp.o -Wl,--allow-shlib-undefined -shared 
-fPIC -Wl,--start-group -Wl,-soname,libhep-vbs.so src/liblusifer.a 
src/libucwwds.a subprojects/hep-ps/src/libhep-ps.so -lgfortran 
/opt/sw/arch/easybuild/2020b/software/GSL/2.6-GCC-10.2.0/lib/libgsl.so 
/opt/sw/arch/easybuild/2020b/software/GSL/2.6-GCC-10.2.0/lib/libgslcblas.so 
-lm -lpthread

-Wl,-rpath 
-Wl,/opt/sw/arch/easybuild/2020b/software/hwloc/2.2.0-GCCcore-10.2.0/lib 
-Wl,/opt/sw/arch/easybuild/2020b/software/libevent/2.1.12-GCCcore-10.2.0/lib64 
-Wl,/opt/sw/arch/easybuild/2020b/software/OpenMPI/4.0.5-GCC-10.2.0/lib

-Wl,--enable-new-dtags 
/opt/sw/arch/easybuild/2020b/software/OpenMPI/4.0.5-GCC-10.2.0/lib/libmpi.so 
-Wl,--end-group '-Wl,-rpath,$ORIGIN/../subprojects/hep-ps/src' 
-Wl,-rpath-link,/auto/home/users/r/w/rwinter/hep-vbs/build-debug/subprojects/hep-ps/src
/opt/sw/arch/easybuild/2020b/software/binutils/2.35-GCCcore-10.2.0/bin/ld.gold: 
fatal error: 
/opt/sw/arch/easybuild/2020b/software/libevent/2.1.12-GCCcore-10.2.0/lib64: 
pread failed: Is a directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

The output of mpic++ --showme is (again with added linebreaks):

g++
-I/opt/sw/arch/easybuild/2020b/software/OpenMPI/4.0.5-GCC-10.2.0/include
-L/opt/sw/arch/easybuild/2020b/software/hwloc/2.2.0-GCCcore-10.2.0/lib
-L/opt/sw/arch/easybuild/2020b/software/libevent/2.1.12-GCCcore-10.2.0/lib64

-Wl,-rpath
-Wl,/opt/sw/arch/easybuild/2020b/software/hwloc/2.2.0-GCCcore-10.2.0/lib
-Wl,-rpath
-Wl,/opt/sw/arch/easybuild/2020b/software/libevent/2.1.12-GCCcore-10.2.0/lib64
-Wl,-rpath
-Wl,/opt/sw/arch/easybuild/2020b/software/OpenMPI/4.0.5-GCC-10.2.0/lib

-Wl,--enable-new-dtags
-L/opt/sw/arch/easybuild/2020b/software/OpenMPI/4.0.5-GCC-10.2.0/lib
-lmpi

So the problem seems that the second and third -Wl,-rpath is stripped. Adding them manually to build.ninja solves the problem.

system parameters

dcbaker commented 3 years ago

I have a pretty good idea what's happening here.

dcbaker commented 3 years ago

My initial idea didn't pan out, can you provide the full configure output, or at least the MPI output, I want to know whether it's using pkg-config or mpic++

ramonpeter commented 3 years ago

Here is the corresponding meson log-file of the mentioned bug:

meson-log.txt