SAGE_FAT_BINARY fails on Debian 9 64-bit
vbraun opened this issue · 10 comments
When building ecm there are lots of errors of the form
[ecm-7.0.4.p0] /home/buildbot/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidmas391yaj2/local/lib/libgmp.a(fat_entry.o): In function `__gmpn_mod_34lsub1':
[ecm-7.0.4.p0] /home/buildbot/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidmas391yaj2/local/var/tmp/sage/build/mpir-3.0.0.p0/src/mpn/tmp-fat_entry.s:202: multiple definition of `__gmpn_mod_34lsub1'
[ecm-7.0.4.p0] ./.libs/libecm.a(libecm_la-schoen_strass.o):/home/buildbot/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidmas391yaj2/local/var/tmp/sage/build/ecm-7.0.4.p0/src/schoen_strass.c:61: first defined here
[ecm-7.0.4.p0] /usr/bin/ld: /home/buildbot/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidmas391yaj2/local/lib/libgmp.a(fat_entry.o): relocation R_X86_64_32S against symbol `__gmpn_cpuvec' can not be used when making a shared object; recompile with -fPIC
[ecm-7.0.4.p0] /usr/bin/ld: final link failed: Nonrepresentable section on output
[ecm-7.0.4.p0] collect2: error: ld returned 1 exit status
CC: @wbhart @slel @NathanDunfield @mkoeppe @kliem
Component: build
Issue created by migration from https://trac.sagemath.org/ticket/23519
__gmpn_cpuvec in libgmp.a... possibly related to our recent MPIR upgrade?
It says to rebuild libgmp.a with -fPIC. My personal feeling is that insisting on linking ecm against libgmp.a for a little bit of performance is misguided at best.
Two sage-devel postings about this:
https://groups.google.com/d/msg/sage-devel/Jl071EqambM/yr4_RvjbBQAJ
https://groups.google.com/d/msg/sage-devel/W9iVNPsIJVA/3EQO__OxAwAJ
Seems some of this was already known in mpir and ecm:
(sage-sh) jan@muizenberg:sage-8.0$ grep SAGE_FAT_BINARY build/pkgs/*/spkg-install|grep not
build/pkgs/ecm/spkg-install: echo >&2 "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
build/pkgs/mpir/spkg-install: echo "Cannot build with SAGE_FAT_BINARY=yes."
(sage-sh) jan@muizenberg:sage-8.0$
This is possibly gcc 6.2 related:
https://mail.coreboot.org/pipermail/coreboot/2016-December/082739.html
And a possible solution is Build GMP --with-pic, (only) if GCC defaults to -pie (preferred solution from reading the rest of above thread to the end).
UPDATE: --with-pic did not work for me; trying now with CFLAGS="-fPIC"
UPDATE2:
export CFLAGS="--with-pic"; ./sage -f mpir; make # failed to build
export CFLAGS="-fPIC"; ./sage -f mpir; make # completed build (well most packages except doc-html eventually failed to build with OSError: [Errno 12] Cannot allocate memory in a 4G Virtual Machine.
UPDATE 3: From scratch start with
export CFLAGS="-fPIC" CXXFLAGS="-fPIC" SAGE_FAT_BINARY=yes
make # ecm failed to build
It seems a binary successfully built on sage 8.1 on Debian 9. Not sure what changed and whether this can be closed.
This is still an issue, per mailing list discussion at https://groups.google.com/d/msg/sage-devel/isGlUdvsYo8/Ldy5wVFKAAAJ
I added --with-pic to the MPIR build when using SAGE_FAT_BINARY=yes (just for 64-bit) and it seems to be happy with that.
I'm seeing this with Ubuntu 18.04.3 (the latest 18.04 on DockerHub). I'm working around it sadly by building sage twice, once after deleting libgmp.a. Search for the word "stupid" in https://github.com/sagemathinc/cocalc-docker/blob/master/scripts/install_sage.sh