Opened 11 years ago

Closed 11 years ago

Last modified 9 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: None/Unknown Test Case: N/A
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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 -
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/; /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 11 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 11 years ago by igloo

Milestone: 6.6.1
Test Case: N/A

comment:3 Changed 11 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/

See the patch here:

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.


comment:4 Changed 11 years ago by simonmar

Summary: Build failure in Cabal/cabal-setup: -lgmp doesn't honor LDFLAGSNo 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/

comment:5 Changed 11 years ago by igloo

Owner: set to igloo

comment:6 Changed 11 years ago by igloo

Resolution: fixed
Status: newclosed

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.