Opened 6 months ago

Last modified 2 months ago

#8666 new bug

integer-gmp fails to compile on Debian Squeeze

Reported by: jstolarek Owned by:
Priority: normal Milestone:
Component: libraries (other) Version: 7.7
Keywords: Cc: tibbe
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I get an error when compiling recent HEAD on Debian Squeeze:

"inplace/bin/ghc-stage1" -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -H64m -O0 -fasm    -package-name integer-gmp-0.5.1.0 -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/.    -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.3.1.0 -Wall -package-name integer-gmp -XHaskell2010 -O -fasm  -no-user-package-db -rtsopts -Ilibraries/integer-gmp/mkGmpDerivedConstants/dist     -odir libraries/integer-gmp/dist-install/build -hidir libraries/integer-gmp/dist-install/build -stubdir libraries/integer-gmp/dist-install/build   -fno-use-rpaths -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-prim-0.3.1.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../rts-1.0' -optl-Wl,-zorigin libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Prim.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o  libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o   libraries/integer-gmp/gmp/objs/*.o -shared -dynamic -dynload deploy   -no-auto-link-packages -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.7.20140113.so
Warning: -rtsopts and -with-rtsopts have no effect with -shared.
    Call hs_init_ghc() from your main() function to set these options.
/usr/bin/ld: libraries/integer-gmp/gmp/objs/aors.o: relocation R_X86_64_32 against `__gmpz_sub' can not be used when making a shared object; recompile with -fPIC
libraries/integer-gmp/gmp/objs/aors.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.7.20140113.so] Error 1
make: *** [all] Error 2

I can build in-tree libgmp by extracting it and running ./configure make. Following Austin's and Herbert's suggestions I tried adding -fPIC to command line options but with no result - see attachements.

Attachments (2)

make.log (19.2 KB) - added by jstolarek 6 months ago.
Build log for integer-gmp with gmp_CC_OPTS += -fPIC added in gmp/ghc.mk
readelf.txt (2.4 KB) - added by jstolarek 6 months ago.
readelf dump for aors.o

Download all attachments as: .zip

Change History (11)

Changed 6 months ago by jstolarek

Build log for integer-gmp with gmp_CC_OPTS += -fPIC added in gmp/ghc.mk

Changed 6 months ago by jstolarek

readelf dump for aors.o

comment:1 Changed 5 months ago by jstolarek

Another user reports the same problem with GHC 7.8.1-RC1:

http://www.haskell.org/pipermail/glasgow-haskell-users/2014-February/024641.html

comment:2 Changed 5 months ago by iduhetonas

I had this issue when compiling with libgmp3-dev 2:4.3.2, which was in the repository of Ubuntu 10.04 Lucid.

I upgraded to libgmp3-dev 2:5.0.2 in Ubuntu 12.04 Precise, did "make distclean && make maintainer-clean", and recompiled from scratch, which fixed the issue.

I assume the error lies between these two versions, so make sure you're using libgmp3-dev 2:5.0.2 at least.

comment:3 Changed 5 months ago by iduhetonas

  • Resolution set to fixed
  • Status changed from new to closed

User claims to no longer be experiencing the issue.

http://www.haskell.org/pipermail/ghc-devs/2014-February/004051.html

Marking as fixed.

comment:4 Changed 5 months ago by jstolarek

  • Resolution fixed deleted
  • Status changed from closed to new

User claims to no longer be experiencing the issue

Wow, wait a sec. I'm not experiencing the issue because I upgraded to new Debian, not because the issue was fixed. I'm reopening the ticket. We should either have a real fix or mark this as wontfix - but the latter is not for me to decide (Herbert?).

comment:5 Changed 5 months ago by Austin Seipp <austin@…>

In d7bff4dddfa10389156ca11f75a5a23e78cf3ab0/integer-gmp:

Fix GMP v4 compatibility.

We had started relying on GMP 5.x (for usage of mpz_powm_sec), but this
is pretty painful on RHEL-esque targets, which still use GMP 4.x.

In the mean time while we're still supporting this, it's easier to just
fallback to mpz_powm when _sec is unavailable, and emit a WARNING for
using the primitive.

This also installs a header, HsIntegerGmp.h, which clients could use for
a fallback.

As a side note, this will probably also help Debian oldstable users who
might have outdated GMP versions (which I believe is the cause for #8666.)

Reviewed-by: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Austin Seipp <austin@well-typed.com>

comment:6 Changed 5 months ago by thoughtpolice

After looking at this, the reason for this is probably because the in-tree GMP is a bit broken, and doesn't compile correctly dynamically.

In the mean time, I have pushed a patch to restore compatibility with (much) older GMP versions, meaning as long as your Debian Squeeze machines have libgmp-dev installed, everything should be fine.

I'd appreciate it if someone could test this on HEAD (or the upcoming RC2).

comment:7 Changed 5 months ago by thoughtpolice

(I mean, test it on Debian - I have confirmed that RHEL can use gmp 4 from the regular repositories, and GHC compiles without issue).

comment:8 Changed 4 months ago by tibbe

  • Cc tibbe added

comment:9 Changed 2 months ago by ocharles

I believe I am running into this bug:

ollie@nixos ~/w/ghc> nix-shell --pure -I /home/ollie -p haskellPackages_ghc782.ghc haskellPackages.cabalInstall -p haskellPackages_ghc782.happy haskellPackages_ghc782.alex -p ncurses -p gnum4

[nix-shell:~/work/ghc/libraries/base]$ make
make -C ../.. all_libraries/base 
make[1]: Entering directory `/home/ollie/work/ghc'
===--- building phase 0
make -r --no-print-directory -f ghc.mk phase=0 phase_0_builds
make[2]: Nothing to be done for `phase_0_builds'.
===--- building phase 1
make -r --no-print-directory -f ghc.mk phase=1 phase_1_builds
make[2]: Nothing to be done for `phase_1_builds'.
===--- building final phase
make -r --no-print-directory -f ghc.mk phase=final all_libraries/base
"inplace/bin/ghc-stage1" -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -H64m -O0 -fasm    -package-name integer-gmp-0.5.1.0 -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/include    -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.3.1.0 -Wall -package-name integer-gmp -XHaskell2010 -O -fasm  -no-user-package-db -rtsopts -Ilibraries/integer-gmp/mkGmpDerivedConstants/dist     -odir libraries/integer-gmp/dist-install/build -hidir libraries/integer-gmp/dist-install/build -stubdir libraries/integer-gmp/dist-install/build   -optl-L'/home/ollie/work/ghc/libraries/ghc-prim/dist-install/build' -optl-L'/home/ollie/work/ghc/rts/dist/build' -optl-lm -optl-lrt -optl-ldl -fPIC -dynamic  -H64m -O0 -fasm    -package-name integer-gmp-0.5.1.0 -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/include    -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.3.1.0 -Wall -package-name integer-gmp -XHaskell2010 -O -fasm  -no-user-package-db -rtsopts -Ilibraries/integer-gmp/mkGmpDerivedConstants/dist     -fno-use-rpaths -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-prim-0.3.1.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../rts-1.0' -optl-Wl,-zorigin libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Prim.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o  libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o   libraries/integer-gmp/gmp/objs/*.o -shared -dynamic -dynload deploy   -no-auto-link-packages -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.9.20140430.so
Warning: -rtsopts and -with-rtsopts have no effect with -shared.
    Call hs_init_ghc() from your main() function to set these options.
/nix/store/xjvdpqgn2kd4rg0k30z020kxylvlbpx0-binutils-2.23.1/bin/ld: libraries/integer-gmp/gmp/objs/aors.o: relocation R_X86_64_32 against `__gmpz_add' can not be used when making a shared object; recompile with -fPIC
libraries/integer-gmp/gmp/objs/aors.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.9.20140430.so] Error 1
make[1]: *** [all_libraries/base] Error 2
make[1]: Leaving directory `/home/ollie/work/ghc'
make: *** [all] Error 2

If anyone has anything they'd like me to try - suggest away!

I'm at revision 34db5ccf52ec2a1b5e953c282d0c52a7fc82c02a (at least in the root of the source tree), and my nixpkgs is e001ac6a9ee3e3f1d755c16d1a27e5ce75a76902

Note: See TracTickets for help on using tickets.