Ticket #4112 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

Building GHC with local libgmp.a fails

Reported by: Itkovian Owned by: igloo
Priority: high Milestone: 7.0.1
Component: Build System Version: 6.13
Keywords: libgmp, hsc2hs, hsc Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Building GHC failed Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

I am trying to build the darcs head of GHC on a platform where I have no root privileges and which is lacking libgmp.a -- it does come with the .so files for libgmp. Hence, I built my own libgmp, installed in ${HOME}/data, i.e., path to libgmp.a is ${HOME}/data/lib.

Options passed to the configure script: --with-gmp-includes=${HOME}/data/include/ --with-gmp-libraries=${HOME}/data/lib/

Advice on #ghc taught me to first adjust the ghc script that is part of the (working) ghc that I placed on my system -- locally under $HOME. Adding -L${HOME}/data/lib and -I${HOME}/data/include does alleviate some of the problems -- it allowed ghc-pwd to be build as well as ghc-cabal, and ghc-pkg. After that the build continues until hsc is being built.

The main problem now is that hsc2hs is failing to build stuff, more specifically, libraries/hsc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.

The package-data.mk for libraries/hsc/dist-boot mentions that gmp be added as an extra library (libraries/hpc_dist-boot_DEP_EXTRA_LIBS = rt util dl gmp m rt dl), yet the path to libgmp.a is not found in the command line.

My guess is that the options passed to configure about the location of the gmp library is not making it through to the correct spot.

Contents of package-data.mk:

libraries/hpc_dist-boot_VERSION = 0.5.0.5
libraries/hpc_dist-boot_MODULES = Trace.Hpc.Util Trace.Hpc.Mix Trace.Hpc.Tix Trace.Hpc.Reflect
libraries/hpc_dist-boot_HIDDEN_MODULES = 
libraries/hpc_dist-boot_SYNOPSIS =Code Coverage Library for Haskell
libraries/hpc_dist-boot_HS_SRC_DIRS = .
libraries/hpc_dist-boot_DEPS = base-4.2.0.0 containers-0.3.0.0 directory-1.0.1.0 old-time-1.0.0.3
libraries/hpc_dist-boot_DEP_NAMES = base containers directory old-time
libraries/hpc_dist-boot_INCLUDE_DIRS = 
libraries/hpc_dist-boot_INCLUDES = 
libraries/hpc_dist-boot_INSTALL_INCLUDES = 
libraries/hpc_dist-boot_EXTRA_LIBRARIES = 
libraries/hpc_dist-boot_EXTRA_LIBDIRS = 
libraries/hpc_dist-boot_C_SRCS  = 
libraries/hpc_dist-boot_CMM_SRCS  = $(addprefix cbits/,$(notdir $(wildcard libraries/hpc/cbits/*.cmm)))
libraries/hpc_dist-boot_HC_OPTS = -Wall -XCPP
libraries/hpc_dist-boot_CC_OPTS = 
libraries/hpc_dist-boot_CPP_OPTS = 
libraries/hpc_dist-boot_LD_OPTS = 
libraries/hpc_dist-boot_DEP_INCLUDE_DIRS = '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/directory-1.0.1.0/include' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/unix-2.4.0.0/include' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-time-1.0.0.3/include' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/base-4.2.0.0/include' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/include' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/include'
libraries/hpc_dist-boot_DEP_CC_OPTS = 
libraries/hpc_dist-boot_DEP_LIB_DIRS = '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/directory-1.0.1.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/unix-2.4.0.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-time-1.0.0.3' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-locale-1.0.0.2' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/filepath-1.1.0.3' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/containers-0.3.0.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/array-0.3.0.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/base-4.2.0.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/integer-gmp-0.2.0.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/ghc-prim-0.2.0.0' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1' '/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1'
libraries/hpc_dist-boot_DEP_EXTRA_LIBS = rt util dl gmp m rt dl
libraries/hpc_dist-boot_DEP_LD_OPTS = 

Output from make at second run -- so the rest has been built:

===--- updating makefiles phase 0
make -r --no-print-directory -f ghc.mk phase=0 just-makefiles
===--- updating makefiles phase 1
make -r --no-print-directory -f ghc.mk phase=1 just-makefiles
ghc.mk:694: libraries/hpc/dist-boot/build/.depend-v.haskell: No such file or directory
"inplace/bin/hsc2hs" --cc=/usr/bin/gcc --ld=/usr/bin/gcc   -I/user/home/gent/vsc400/vsc40075/data/include/  --cflag=-D__GLASGOW_HASKELL__=613 '--cflag=-Ilibraries/hpc/.' '--cflag=-isystem/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/directory-1.0.1.0/include' '--cflag=-isystem/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/unix-2.4.0.0/include' '--cflag=-isystem/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-time-1.0.0.3/include' '--cflag=-isystem/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/base-4.2.0.0/include' '--cflag=-isystem/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/include' '--cflag=-isystem/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/include' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/directory-1.0.1.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/unix-2.4.0.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-time-1.0.0.3' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-locale-1.0.0.2' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/filepath-1.1.0.3' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/containers-0.3.0.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/array-0.3.0.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/base-4.2.0.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/integer-gmp-0.2.0.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/ghc-prim-0.2.0.0' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1' '--lflag=-L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1' '--lflag=-lrt' '--lflag=-lutil' '--lflag=-ldl' '--lflag=-lgmp' '--lflag=-lm' '--lflag=-lrt' '--lflag=-ldl'   libraries/hpc/./Trace/Hpc/Reflect.hsc -o libraries/hpc/dist-boot/build/Trace/Hpc/Reflect.hs
/usr/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
linking libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.o failed
command was: /usr/bin/gcc -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/directory-1.0.1.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/unix-2.4.0.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-time-1.0.0.3 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/old-locale-1.0.0.2 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/filepath-1.1.0.3 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/containers-0.3.0.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/array-0.3.0.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/base-4.2.0.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/integer-gmp-0.2.0.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1/ghc-prim-0.2.0.0 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1 -L/user/home/gent/vsc400/vsc40075/data/ghc-release-6.12.1/lib/ghc-6.12.1 -lrt -lutil -ldl -lgmp -lm -lrt -ldl libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.o -o libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make
make[1]: *** [libraries/hpc/dist-boot/build/Trace/Hpc/Reflect.hs] Error 1
make: *** [all] Error 2

Change History

Changed 3 years ago by Itkovian

It seems that adding ${HOME}/data/lib to the DEP_LIB_DIRS variable in the package-data.mk files allows the build to continue. I'm not familiar with the GHC build system, but it seems that this should be where the --with-gmp-libraries option passed to the configure script should finally end up.

Changed 3 years ago by Itkovian

A simple workaround this bug is:

diff -rN old-ghc.darcs/utils/ghc-cabal/ghc-cabal.hs new-ghc.darcs/utils/ghc-cabal/ghc-cabal.hs 335a336,339

-- XXX Ugly hack to get the --config-option=--with-gmp-libraries into the DEP_LIB_DIRS -- This is required when libgmp.a is not residing in the usual place, i.e., /usr/lib let extraGmpLibLocation = catMaybes $ map (stripPrefix "--configure-option=--with-gmp-libraries=") config_args

363c367 < variablePrefix ++ "_DEP_LIB_DIRS = " ++ unwords (wrap $ forDeps Installed.libraryDirs), ---

variablePrefix ++ "_DEP_LIB_DIRS = " ++ unwords (wrap $ forDeps Installed.libraryDirs) ++ " " ++ unwords (wrap extraGmpLibLocation),

Changed 3 years ago by Itkovian

Argh. Now with code block.

diff -rN old-ghc.darcs/utils/ghc-cabal/ghc-cabal.hs new-ghc.darcs/utils/ghc-cabal/ghc-cabal.hs
335a336,339
>       -- XXX Ugly hack to get the --config-option=--with-gmp-libraries into the DEP_LIB_DIRS
>       -- This is required when libgmp.a is not residing in the usual place, i.e., /usr/lib
>       let extraGmpLibLocation = catMaybes $ map (stripPrefix "--configure-option=--with-gmp-libraries=") config_args 
> 
363c367
<                 variablePrefix ++ "_DEP_LIB_DIRS = "   ++ unwords (wrap $ forDeps Installed.libraryDirs),
---
>                 variablePrefix ++ "_DEP_LIB_DIRS = "   ++ unwords (wrap $ forDeps Installed.libraryDirs) ++ " " ++ unwords (wrap extraGmpLibLocation),

Changed 3 years ago by igloo

  • description modified (diff)

Changed 3 years ago by igloo

  • priority changed from normal to high
  • milestone set to 6.14.1

Thanks for the report.

Changed 3 years ago by igloo

  • owner set to igloo

Changed 3 years ago by igloo

  • status changed from new to closed
  • resolution set to invalid

OK, I've taken a look at this, and it looks like the problem is with your bootstrapping compiler. I think the bootstrapping compiler's package.conf will say that some package, probably rts, needs the gmp library, but doesn't give the library path for where to find it.

Note: See TracTickets for help on using tickets.