Version node not found for symbol when static linking libgomp.a compiled with fPIC

190 views Asked by At

I'm trying to recompile gcc/gfortran with -fPIC so that I will be able to statically link the libraries with position-independent compiled objects using

# gcc/gfortran configured and compiled with
./configure --disable-multilib --with-pic CFLAGS=-fPIC CXXFLAGS=-fPIC FFLAGS=-fPIC

but run into issues with libgomp OpenMP during linking:

# linking final binary
gcc -shared -Wl,-t -Wl,--no-undefined -Wl,-rpath='$ORIGIN' foo.o \
-Wl,-Bstatic -Imumps-5.5.1/include -Lmumps-5.5.1/lib -ldmumps -lmumps_common \
-Imumps-5.5.1/libseq -Lmumps-5.5.1/libseq -lmpiseq -Lmumps-5.5.1/PORD/lib -lpord \
-llapack -lblas -lgomp -lgfortran -lquadmath \
-Wl,-Bdynamic -lm -lpthread -o foo

...

(/home/user/gcc-7.5.0/lib64/libgomp.a)oacc-host.o
/lib/x86_64-linux-gnu/libpthread.so.0
/lib/x86_64-linux-gnu/libm.so.6
/lib/x86_64-linux-gnu/libmvec.so.1
/lib/x86_64-linux-gnu/libmvec.so.1
-ldl (/usr/lib/x86_64-linux-gnu/libdl.so)
(/home/user/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/libgcc.a)sfp-exceptions.o
(/home/user/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/libgcc_eh.a)unwind-dw2-fde-dip.o
/lib/x86_64-linux-gnu/libc.so.6
(/usr/lib/x86_64-linux-gnu/libc_nonshared.a)atexit.oS
/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
/home/user/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/crtendS.o
/usr/lib/x86_64-linux-gnu/crtn.o

...

/usr/bin/ld: version node not found for symbol omp_set_nest_lock@@OMP_3.0
/usr/bin/ld: failed to set dynamic section sizes: Bad value

...

> nm -s libgomp.a | grep omp_set_nest_lock
gomp_set_nest_lock_30 in lock.o
gomp_set_nest_lock_25 in lock.o
omp_set_nest_lock@@OMP_3.0 in lock.o
omp_set_nest_lock@OMP_1.0 in lock.o
gomp_set_nest_lock__30 in fortran.o
gomp_set_nest_lock__25 in fortran.o
omp_set_nest_lock_@@OMP_3.0 in fortran.o
omp_set_nest_lock_@OMP_1.0 in fortran.o
00000000000001d0 T gomp_set_nest_lock_25
00000000000000a0 T gomp_set_nest_lock_30
00000000000000a0 T omp_set_nest_lock@@OMP_3.0
00000000000001d0 T omp_set_nest_lock@OMP_1.0
                 U gomp_set_nest_lock_25
                 U gomp_set_nest_lock_30
0000000000000110 T gomp_set_nest_lock__25
0000000000000070 T gomp_set_nest_lock__30
0000000000000070 T omp_set_nest_lock_@@OMP_3.0
0000000000000110 T omp_set_nest_lock_@OMP_1.0

if I check the symbols in libgomp then omp_set_nest_lock@@OMP_3.0 is definitely defined, and libgomp not multiply linked either. I have tried both with gcc 7.5 and 12.2, and dynamic linking (.so) works, but not the static one (.a) so I'm not quite sure what the issue could be here?

0

There are 0 answers