John Cremona on Mon, 15 May 2023 14:23:35 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: library .tbss mismatches


I think the underlying problem here is that package managers who package sagemath make it dependent on several other packages, including pari -- which makes sense, as pari is a dependency of Sage.  So if you install sagemath using the package manager (in debian in your case) it will install its own pari package, and becuase that is a dependency, it means that uninstalling the pari package will uninstall every other packe it depends on, including sagemath.

I myself install both pari and sage by building from source, so sage can use my ssytem install of pari and there is no conflict.

I am quite ignorant of linux package managing, I think Bill knows a lot more about it than me!

John

On Mon, 15 May 2023 at 05:25, Greg Marks <marks@gmarks.org> wrote:
My problem has been solved.  Many thanks to Dr. Allombert for correctly
diagnosing the issue, and thanks to all who offered suggestions.
Because Internet searches yield very little useful guidance concerning
this problem (along with some irrelevant guidance regarding #include
<errno.h> directives, etc.), for the record I'll post to this list the
issue and the exact steps that resolved it.

The problem was that on a computer running Debian 11, with Pari-GP
installed both from tarball source and from Debian repositories,
compiling a C problem using the Pari libraries produced this error:

$gcc -Wall -O3 -L/usr/local/ -o extgcd extgcd.c -lpari
/usr/bin/ld: PARI_SIGINT_block: TLS definition in /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libpari.so section .tbss mismatches non-TLS reference in /tmp/ccQUa8Wh.o
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libpari.so: error adding symbols: bad value
collect2: error: ld returned 1 exit status

The problem seems to have resulted from various header and shared
object files in unusual locations.  This problem arose on two different
computers, and it emerged that two different solutions were possible.


Solution 1: Reinstall Pari libraries from source.

Check for any suspicious environment variables:

$env

Check for errant files in three subdirectories of /usr/local:

$sudo find /usr/local/lib/ -name "*pari*"
/usr/local/lib/libpari-gmp.so.7
/usr/local/lib/libpari.a
/usr/local/lib/paripriv.h
/usr/local/lib/pari.h
/usr/local/lib/paricast.h
/usr/local/lib/paricom.h
/usr/local/lib/paristio.h
/usr/local/lib/pariold.h
/usr/local/lib/libpari-gmp.so.2.15.3
/usr/local/lib/parimt.h
/usr/local/lib/pariinl.h
/usr/local/lib/parigen.h
/usr/local/lib/pari
/usr/local/lib/pari/pari.cfg
/usr/local/lib/libpari-gmp.so.8
/usr/local/lib/parilvl1.h
/usr/local/lib/paridecl.h
/usr/local/lib/parilvl0.h
/usr/local/lib/libpari.so
/usr/local/lib/paritune.h
/usr/local/lib/parinf.h
/usr/local/lib/parierr.h
/usr/local/lib/parisys.h
/usr/local/lib/libpari-gmp.so.2.13.2
/usr/local/lib/paricfg.h
/usr/local/lib/paridbglvl.h

$sudo find /usr/local/include/ -name "*pari*"
/usr/local/include/pari
/usr/local/include/pari/paripriv.h
/usr/local/include/pari/pari.h
/usr/local/include/pari/paricast.h
/usr/local/include/pari/paricom.h
/usr/local/include/pari/paristio.h
/usr/local/include/pari/pariold.h
/usr/local/include/pari/parimt.h
/usr/local/include/pari/pariinl.h
/usr/local/include/pari/parigen.h
/usr/local/include/pari/paridecl.h
/usr/local/include/pari/paritune.h
/usr/local/include/pari/parinf.h
/usr/local/include/pari/parierr.h
/usr/local/include/pari/parisys.h
/usr/local/include/pari/paricfg.h
/usr/local/include/pari/genpari.h
/usr/local/include/pari/paridbglvl.h

$sudo find /usr/local/share/ -name "*pari*"
/usr/local/share/pari
/usr/local/share/pari/pari.desc
/usr/local/share/pari/doc/paricfg.tex
/usr/local/share/pari/doc/parimacro.tex
/usr/local/share/pari/doc/libpari.dvi
/usr/local/share/man/man1/pari.1

Remove the offending files (inspecting carefully before deletion):

$sudo find /usr/local/lib/ -name "*pari*" -exec rm -i {} +
$sudo rm -r -v /usr/local/include/pari
$sudo rm -r -v /usr/local/share/pari 
$sudo rm /usr/local/share/man/man1/pari.1

Reinstall Pari from source (adjust accordingly depending on your
directory tree, names of future versions of Pari, and whether you want
to install optional PARI/GP packages prior to configuration):

$cd /usr/local/Math_Software/
$wget https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-2.15.3.tar.gz
$if [[ "$(sha256sum pari-2.15.3.tar.gz | sed 's/^\([^ ]\+\) .*/\1/g')" == adf5a58638cdafd72a8b48bc9f444972b23329c8d545a1d3ed1bbeb1b6569268 ]] ; then echo "good" ; fi
$wget https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-2.15.3.tar.gz.asc
$gpg --recv-keys 42028EA404A2E9D80AC453148F0E7C2B4522E387
$gpg --fingerprint 0x8F0E7C2B4522E387
$gpg --edit-key 0x8F0E7C2B4522E387
   gpg> trust
   Your decision? 4
   gpg> quit
$gpg --lsign-key "4202 8EA4 04A2 E9D8 0AC4  5314 8F0E 7C2B 4522 E387"
$gpg --verify pari-2.15.3.tar.gz.asc
$gunzip pari-2.15.3.tar.gz
$tar -xvf pari-2.15.3.tar
$cd /usr/local/Math_Software/pari-2.15.3
$./Configure --prefix=GPDIR --mt=pthread
$make -j4 gp
$make doc
$make statest-all
$make install
$make install-bin-sta
$cd examples
$make TARGET=extgcd

(Note that the "make install" and "make install-bin-sta" commands do not
have to be issued as root.)  This should result in a working "extgcd"
executable file.  Now, to compile your own C program located in some
other directory using the Pari library, use a command such as this:

$gcc -Wall -O3 -o my_program -Wl,-rpath "/usr/local/Math_Software/pari-2.15.3/GPDIR/lib" my_program.c -L"/usr/local/Math_Software/pari-2.15.3/GPDIR/lib" -lpari


Solution 2: Reinstall Pari libraries from Debian repositories.
(Arguably simpler and easier to maintain, but will not provide the
latest version of Pari.)

Initial steps as in Solution 1:

$env
$sudo find /usr/local/lib/ -name "*pari*" -exec rm -i {} +
$sudo rm -v -r /usr/local/lib/pari
$sudo find /usr/local/include/ -name "*pari*" -exec rm -i {} +
$sudo find /usr/local/share/ -name "*pari*" -exec rm -i {} +
$sudo rm -r -v /usr/local/share/pari

Now purge the following packages.  In my case, this deleted a huge
number of additional packages, which fortunately were easily reinstalled.
It's probably wise to keep a record of the warning message listing the
packages to be deleted.

$sudo apt-get purge libpari-gmp-tls7
$sudo apt-get purge pari-gp
$sudo apt-get purge pari-galpol
$sudo apt autoremove

Now reinstall Pari-GP and the Pari libraries:

$sudo apt-get update
$sudo aptitude --verbose safe-upgrade
$sudo apt-get install pari-gp
$sudo apt-get install pari-gp2c

Crucially, this last command should also install the packages
"libpari-dev" and "libpari-gmp-tls7" providing the Pari library.

$sudo apt-get install pari-galpol

Now, to compile your own C program located in some other directory
using the Pari library, use a command such as this:

$gcc -Wall -O3 -o my_program my_program.c -lpari

Finally, in my case, it was necessary to reinstall software deleted
with the preceding "apt-get purge" commands:

$sudo apt-get install sagemath
$sudo apt-get install gap-smallgrp-extra

Fortunately, this process does not alter the $HOME/.sage directory, which
contains one's own data.  Nevertheless, it's probably good practice to
back up this directory.

Best regards,
Greg Marks