Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#957 closed bug (fixed)

No way to use -lgmp from a non-standard location

Reported by: trangayesi@… Owned by: igloo
Priority: normal Milestone: 6.6.1
Component: Build System Version: 6.6
Keywords: Cc:
Operating System: FreeBSD Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: N/A Blocked By:
Blocking: Related Tickets:

Description

When building ghc-6.6 from source on FreeBSD 6, I get this error:

== gmake all - --no-print-directory -r;
 in /usr/home/tim/local/src/ghc-6.6/libraries/Cabal/cabal-setup
------------------------------------------------------------------------
../../../compiler/ghc-inplace -o cabal-setup -H16m -O -package Cabal       CabalSetup.o
/usr/bin/ld: cannot find -lgmp
gmake[3]: *** [cabal-setup] Error 1
gmake[2]: *** [all] Error 1
gmake[1]: *** [all] Error 1
gmake[1]: Leaving directory `/usr/home/tim/local/src/ghc-6.6/libraries'
gmake: *** [stage1] Error 2
1:12 ~/local/src/ghc-6.6$ cd libraries/Cabal/cabal-setup
2:01 ~/local/src/ghc-6.6/libraries/Cabal/cabal-setup$ ../../../compiler/ghc-inplace -o cabal-setup -H16m -O -package Cabal CabalSetup.o -L/usr/local/lib
2:02 ~/local/src/ghc-6.6/libraries/Cabal/cabal-setup$ cd -
~/local/src/ghc-6.6
2:02 ~/local/src/ghc-6.6$ gmake
gmake -C utils/mkdependC boot
gmake[1]: Entering directory `/usr/home/tim/local/src/ghc-6.6/utils/mkdependC'
gmake[1]: Leaving directory `/usr/home/tim/local/src/ghc-6.6/utils/mkdependC'

I configured with:

export CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib
./configure --prefix=$HOME/local

My system has /usr/local/lib/libgmp.so; /usr/local/lib is, on FreeBSD, traditionally not in the default search path. It must be specified explicitly to the linker.

Once I compiled cabal-setup by hand, adding -L/usr/local/lib (as shown above), the rest of the build completed normally.

I'm reporting this against ghc 6.6, but I noticed it on 6.4.2 as well.

Change History (6)

comment:1 Changed 7 years ago by trangayesi@…

A brief update: later on in the compilation, a similar error happened:

gmake -f Makefile.ghcbin -wr HS_PROG=stage2/ghc-6.6 stage2/ghc-6.6
gmake[3]: Entering directory `/usr/home/tim/local/src/ghc-6.6/compiler'
../compiler/stage1/ghc-inplace -H16m -O -package ghc -Istage2 -cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -IcodeGen -InativeGen -Iparser -Rghc-timing  -DGHCI -DBREAKPOINT -threaded    -c main/Main.hs -o stage2/main/Main.o  -ohi stage2/main/Main.hi
<<ghc: 231729244 bytes, 428 GCs, 7894881/18966432 avg/max bytes residency (5 samples), 38M in use, 0.00 INIT (0.00 elapsed), 1.20 MUT (3.94 elapsed), 1.16 GC (1.65 elapsed) :ghc>>
../compiler/stage1/ghc-inplace -o stage2/ghc-6.6 -H16m -O -package ghc -Istage2 -cpp -fglasgow-exts -fno-generics -Rghc-timing -I. -IcodeGen -InativeGen -Iparser -Rghc-timing  -DGHCI -DBREAKPOINT -threaded        stage2/main/Main.o   
/usr/bin/ld: cannot find -lgmp
<<ghc: 18037404 bytes, 3 GCs, 101480/101480 avg/max bytes residency (1 samples), 15M in use, 0.00 INIT (0.00 elapsed), 0.04 MUT (7.54 elapsed), 0.02 GC (0.02 elapsed) :ghc>>
gmake[3]: *** [stage2/ghc-6.6] Error 1
gmake[3]: Leaving directory `/usr/home/tim/local/src/ghc-6.6/compiler'
gmake[2]: *** [stage2/ghc-6.6] Error 2
gmake[2]: Leaving directory `/usr/home/tim/local/src/ghc-6.6/compiler'
gmake[1]: *** [stage2] Error 2
gmake[1]: Leaving directory `/usr/home/tim/local/src/ghc-6.6'
gmake: *** [bootstrap2] Error 2

Again, I was able to continue the compilation after manually executing the failing command with an additional -L/usr/local/lib.

comment:2 Changed 7 years ago by igloo

  • Milestone set to 6.6.1
  • Test Case set to N/A

comment:3 Changed 7 years ago by trangayesi@…

The FreeBSD GHC port includes a patch to fix this problem. Basically, it adds "-L/usr/local/lib" to the ld-options config in ghc/rts/package.conf.in.

See the patch here:
http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/ghc/files/

And the post-patch target of the port's Makefile.

I made this change manually, and my build of ghc-6.6 appears to be working properly in this regard.

I hope this is helpful.

Thanks!

comment:4 Changed 7 years ago by simonmar

  • Summary changed from Build failure in Cabal/cabal-setup: -lgmp doesn't honor LDFLAGS to No way to use -lgmp from a non-standard location

Changed title to reflect the real bug: we don't have configure options to select an alternative place to look for -lgmp or gmp.h. See the way we do this for readline, for example, in libraries/readline/configure.ac.

comment:5 Changed 7 years ago by igloo

  • Owner set to igloo

comment:6 Changed 7 years ago by igloo

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

I believe this is fixed by

Have configure take arguments telling it where gmp is; fixes trac #957

in the 6.6 branch and HEAD.

Note: See TracTickets for help on using tickets.