Jeffrey Walton on Fri, 01 Jan 2021 03:43:26 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
libpari-gmp.so.2.13.0 not being built with RUNPATH |
Hi Everyone, I'm trying to perform some testing of PARI/GP. I'm building the pari-2.13.0 release tarball from sources. In particular, I am working on Asan testing looking for memory errors. CFLAGS, CXXFLAGS and LDFLAGS include -fsanitize=address. CFLAGS and CXXFLAGS include -fno-omit-frame-pointer. I've also built Gzip, Ncurses, Readline and GMP with the same Asan flags. Here's the rub... The Asan builds are installed at --prefix=$HOME/ok2delete-asan. To facilitate Asan, Here are the interesting flags. Everything gets built with the same flags. CPPFLAGS: -I/home/jwalton/ok2delete-asan/include -DNDEBUG -DTEST_ASAN=1 CFLAGS: -g2 -O2 -fsanitize=address -fno-omit-frame-pointer -march=native -fPIC -pthread CXXFLAGS: -g2 -O2 -fsanitize=address -fno-omit-frame-pointer -march=native -fPIC -pthread LDFLAGS: -L/home/jwalton/ok2delete-asan/lib -fsanitize=address -Wl,-R,'$ORIGIN/../lib' -Wl,-R,/home/jwalton/ok2delete-asan/lib -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,origin -Wl,-R + -Wl,--enable-new-dtags sets a RUNPATH. -Wl,-R sets a RPATH. The difference is, a RUNPATH allows a LD_LIBRARY_PATH override. It is what we are supposed to use nowadays on Linux. Now, when 'make all' is run, libpari-gmp.so.2.13.0 is missing its RUNPATH (-Wl,-R,<loc> + -Wl,--enable-new-dtags): gcc -o "/home/jwalton/Build-Scripts/pari-2.13.0/Olinux-x86_64"/libpari-gmp.so.2.13.0 -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -g2 -O2 -fsanitize=address -fno-omit-frame-pointer -march=native -fPIC -pthread -I/home/jwalton/ok2delete-asan/include -DNDEBUG -DTEST_ASAN=1 -fPIC -Wl,-shared,-soname=libpari-gmp.so.7 mpker.o mpinl.o alglin1.o alglin2.o alglin3.o aprcl.o arith1.o arith2.o base1.o base2.o base3.o base4.o base5.o bb_group.o bb_hnf.o bern.o bibli1.o bibli2.o bit.o bnflog.o bnfunits.o buch1.o buch2.o buch3.o buch4.o char.o concat.o crvwtors.o dirichlet.o ecpp.o ellanal.o elliptic.o ellisog.o ellpadic.o ellpadiclambdamu.o ellsea.o elltors.o F2v.o F2x.o F2xqE.o FF.o Fle.o Flv.o Flx.o FlxqE.o Flxq_log.o FlxX.o FpE.o FpV.o FpX.o FpX_factor.o FpXQX_factor.o FpXX.o galconj.o gen1.o gen2.o gen3.o Hensel.o hnf_snf.o hyperell.o hypergeom.o ifactor1.o kummer.o lfun.o lfunquad.o lfunutils.o lll.o map.o matperm.o mellininv.o mftrace.o modsym.o msfarey.o nffactor.o perm.o polarit1.o polarit2.o polarit3.o polclass.o polmodular.o prime.o Qfb.o qfisom.o qfsolve.o QX_factor.o random.o RgV.o RgX.o rootpol.o Ser.o subcyclo.o subfield.o subgroup.o trans1.o trans2.o trans3.o volcano.o zetamult.o ZG.o ZV.o ZX.o anal.o compile.o default.o es.o eval.o forprime.o gplib.o hash.o init.o intnum.o members.o paricfg.o pariinl.o parse.o readline.o str.o sumiter.o algebras.o elldata.o ellfromeqn.o forperm.o forsubset.o galois.o galpol.o genus2red.o groupid.o krasner.o mpqs.o part.o ratpoints.o stark.o thue.o mt.o single.o plotport.o plottty.o -lc -lm -L/home/jwalton/ok2delete-asan/lib -lgmp -lm And: $ find . -name libpari-gmp.so.2.13.0 ./pari-2.13.0/Olinux-x86_64/libpari-gmp.so.2.13.0 $ readelf -d pari-2.13.0/Olinux-x86_64/libpari-gmp.so.2.13.0 | grep -E 'RPATH|RUNPATH' $ No RPATH or RUNPATH. Without the RPATH or RUNPATH, then the wrong libraries will be loaded at runtime by the dynamic linker. Here's what I expect to see (using GMP as an example): $ readelf -d ~/ok2delete-asan/lib/libgmp.so.10.4.1 | grep -E 'RPATH|RUNPATH' 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../lib:/home/jwalton/ok2delete-asan/lib] I think that leads to the next failure. When 'make test-all' is run, the linker encounters a failure: Making test-all in Olinux-x86_64 make[1]: Entering directory '/home/jwalton/Build-Scripts/pari-2.13.0/Olinux-x86_64' rm -f gp-sta gcc -o gp-sta -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -g2 -O2 -fsanitize=address -fno-omit-frame-pointer -march=native -fPIC -pthread -I/home/jwalton/ok2delete-asan/include -DNDEBUG -DTEST_ASAN=1 -Wl,--export-dynamic -L/home/jwalton/ok2delete-asan/lib -fsanitize=address -Wl,-R,'$ORIGIN/../lib' -Wl,-R,/home/jwalton/ok2delete-asan/lib -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,origin mpker.o mpinl.o alglin1.o alglin2.o alglin3.o aprcl.o arith1.o arith2.o base1.o base2.o base3.o base4.o base5.o bb_group.o bb_hnf.o bern.o bibli1.o bibli2.o bit.o bnflog.o bnfunits.o buch1.o buch2.o buch3.o buch4.o char.o concat.o crvwtors.o dirichlet.o ecpp.o ellanal.o elliptic.o ellisog.o ellpadic.o ellpadiclambdamu.o ellsea.o elltors.o F2v.o F2x.o F2xqE.o FF.o Fle.o Flv.o Flx.o FlxqE.o Flxq_log.o FlxX.o FpE.o FpV.o FpX.o FpX_factor.o FpXQX_factor.o FpXX.o galconj.o gen1.o gen2.o gen3.o Hensel.o hnf_snf.o hyperell.o hypergeom.o ifactor1.o kummer.o lfun.o lfunquad.o lfunutils.o lll.o map.o matperm.o mellininv.o mftrace.o modsym.o msfarey.o nffactor.o perm.o polarit1.o polarit2.o polarit3.o polclass.o polmodular.o prime.o Qfb.o qfisom.o qfsolve.o QX_factor.o random.o RgV.o RgX.o rootpol.o Ser.o subcyclo.o subfield.o subgroup.o trans1.o trans2.o trans3.o volcano.o zetamult.o ZG.o ZV.o ZX.o anal.o compile.o default.o es.o eval.o forprime.o gplib.o hash.o init.o intnum.o members.o paricfg.o pariinl.o parse.o readline.o str.o sumiter.o algebras.o elldata.o ellfromeqn.o forperm.o forsubset.o galois.o galpol.o genus2red.o groupid.o krasner.o mpqs.o part.o ratpoints.o stark.o thue.o mt.o single.o plotport.o plottty.o emacs.o gp.o gp_rl.o texmacs.o whatnow.o plotnone.o -Wl,-rpath,"/home/jwalton/Build-Scripts/pari-2.13.0"/Olinux-x86_64:"/home/jwalton/ok2delete-asan/lib":/home/jwalton/ok2delete-asan/lib -L/home/jwalton/ok2delete-asan/lib -lreadline -ltinfo -L/home/jwalton/ok2delete-asan/lib -lgmp -lm /usr/bin/ld: es.o: undefined reference to symbol 'dlsym@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line I also don't see anything special about es.o. It looks OK: gcc -c -I. -I../src/headers -fPIC -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -g2 -O2 -fsanitize=address -fno-omit-frame-pointer -march=native -fPIC -pthread -I/home/jwalton/ok2delete-asan/include -DNDEBUG -DTEST_ASAN=1 -o es.o ../src/language/es.c I am fairly certain the recipe for libpari-gmp.so.2.13.0 needs to be fixed. It must use LDFLAGS. There may be other problems, but this one is the first that needs to be fixed. Jeff