Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Building ghc-pkg: can't find stage0-built libs #27

Closed
quchen opened this issue Dec 23, 2015 · 16 comments
Closed

Building ghc-pkg: can't find stage0-built libs #27

quchen opened this issue Dec 23, 2015 · 16 comments
Assignees
Labels

Comments

@quchen
Copy link
Collaborator

quchen commented Dec 23, 2015

When running the build system, I get the error pasted below. It seems the libraries built by the stage-0 compiler cannot be found. Any pointers would be welcome!

Reproducible on Xubuntu 14.04 and 15.04, although I doubt the OS matters. Stage-0 is GHC 7.10.3.

/usr/bin/ld: cannot find -lHSterminfo-0.4.0.2
/usr/bin/ld: cannot find -lHSghc-boot-0.0.0.0
/usr/bin/ld: cannot find -lHSCabal-1.23.0.0
/usr/bin/ld: cannot find -lHSbinary-0.8.0.0
collect2: error: ld returned 1 exit status
Error when running Shake build system:
* inplace/bin/ghc-pkg
user error (Development.Shake.cmd, system command failed
Command: /home/david/bin/haskell/ghc
    -hisuf hi
    -osuf o
    -hcsuf hc
    -static
    -hide-all-packages
    -no-user-package-db
    -package-db libraries/bootstrapping.conf
    -package-id Cabal-1.23.0.0
    -package-id base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d
    -package-id binary-0.8.0.0
    -package-id bytestring-0.10.6.0-c60f4c543b22c7f7293a06ae48820437
    -package-id containers-0.5.6.2-e59c9b78d840fa743d4169d4bea15592
    -package-id directory-1.2.2.0-f8e14a9d121b76a00a0f669ee724a732
    -package-id filepath-1.4.0.0-f97d1e4aebfd7a03be6980454fe31d6e
    -package-id ghc-boot-0.0.0.0
    -package-id process-1.2.3.0-78f206acb2330ea8066c6c19c87356f0
    -package-id terminfo-0.4.0.2
    -package-id unix-2.7.1.0-343d4f566f30113da92e819f4a148640
    -i
    -iutils/ghc-pkg/stage0/build
    -iutils/ghc-pkg/stage0/build/autogen
    -Iutils/ghc-pkg/stage0/build
    -Iutils/ghc-pkg/stage0/build/autogen
    -iutils/ghc-pkg
    -optP-include
    -optPutils/ghc-pkg/stage0/build/autogen/cabal_macros.h
    -XHaskell2010
    -odir utils/ghc-pkg/stage0/build
    -hidir utils/ghc-pkg/stage0/build
    -stubdir utils/ghc-pkg/stage0/build
    -rtsopts
    -H32m
    -O
    -Wall
    -fwarn-tabs
    -no-auto-link-packages
    -optl-ltinfo
    -optl-lrt
    -optl-lutil
    -optl-ldl
    -optl-lpthread
    -optl-lgmp
    -optl-lm
    -optl-lrt
    -optl-ldl
    -optl-L/home/david/Coding/haskell/ghc/libraries/terminfo/stage0/build
    -optl-L/home/david/Coding/haskell/ghc/libraries/ghc-boot/stage0/build
    -optl-L/home/david/Coding/haskell/ghc/libraries/Cabal/Cabal/stage0/build
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/proce_52AgREEfSrnJLlkGV9YZZJ
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/prett_JItwetRppk1H5Uq3xbjDGC
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/direc_0hFG6ZxK1nk4zsyOqbNHfm
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/unix_KZL8h98IqDM57kQSPo1mKx
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/time_FTheb6LSxyX1UABIbBXRfn
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/filep_Ey7a1in9roBAE8bUFJ5R9m
    -optl-L/home/david/Coding/haskell/ghc/libraries/binary/stage0/build
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/conta_2C3ZI8RgPO2LBMidXKTvIU
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/bytes_6VWy06pWzJq9evDvK2d4w6
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/deeps_6vMKxt5sPFR0XsbRWvvq59
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/array_67iodizgJQIIxYVTp4emlA
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/base_HQfYBxpPvuw8OunzQu6JGM
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/integ_2aU3IZNMF9a7mQ0OzsZ0dS
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/ghcpr_8TmvWUcS1U1IKHT0levwg3
    -optl-L/home/david/Programs/haskell/ghc-7.10.3/lib/ghc-7.10.3/rts utils/ghc-pkg/stage0/build/Main.o utils/ghc-pkg/stage0/build/Version.o
    -o inplace/bin/ghc-pkg
Exit code: 1
Stderr:
/usr/bin/ld: cannot find -lHSterminfo-0.4.0.2
/usr/bin/ld: cannot find -lHSghc-boot-0.0.0.0
/usr/bin/ld: cannot find -lHSCabal-1.23.0.0
/usr/bin/ld: cannot find -lHSbinary-0.8.0.0
collect2: error: ld returned 1 exit status
)
@snowleopard
Copy link
Owner

@quchen Can you check whether the libraries have actually been built already?

I suppose this flag -optl-L/home/david/Coding/haskell/ghc/libraries/binary/stage0/build tells GHC where to find the libHSbinary-0.8.0.0.a library file. On my Windows built the library is indeed there.

@quchen
Copy link
Collaborator Author

quchen commented Dec 23, 2015

@snowleopard that folder has contents, so something has been built. But there's no .a file there.

λ. tree                                                                                                                                                   13:04:41  david@david-tng-laptop 
.
├── autogen
│   ├── cabal_macros.h
│   └── Paths_binary.hs
└── Data
    ├── Binary
    │   ├── Builder
    │   │   ├── Base.hi
    │   │   └── Base.o
    │   ├── Builder.hi
    │   ├── Builder.o
    │   ├── Class.hi
    │   ├── Class.o
    │   ├── Generic.hi
    │   ├── Generic.o
    │   ├── Get
    │   │   ├── Internal.hi
    │   │   └── Internal.o
    │   ├── Get.hi
    │   ├── Get.o
    │   ├── Put.hi
    │   └── Put.o
    ├── Binary.hi
    └── Binary.o

@snowleopard
Copy link
Owner

If you look into Rules/Program.hs, you'll see this line responsible for building all dependencies (such as lib*.a libraries) before a program such as ghc-pkg is built:

need $ binDeps ++ libs

You can add the following debug command to check which libraries were supposed to be built:

need $ binDeps ++ libs
when (pkg == ghcPkg) . putBuild $ "Libraries built: " ++ show libs

Maybe this will help to understand what is going on.

@bgamari
Copy link
Collaborator

bgamari commented Dec 23, 2015

@snowleopard this produces, Libraries built: [] for me.

@quchen
Copy link
Collaborator Author

quchen commented Dec 23, 2015

Same thing for me.

@snowleopard
Copy link
Owner

OK, thanks. I'll have a look at this tonight.

@snowleopard snowleopard self-assigned this Dec 23, 2015
@snowleopard
Copy link
Owner

For the record, when I run it on Windows I get the following output:

libs = [ "libraries/Cabal/Cabal/stage0/build/libHSCabal-1.23.0.0.a"
       , "libraries/binary/stage0/build/libHSbinary-0.8.0.0.a"
       , "libraries/ghc-boot/stage0/build/libHSghc-boot-0.0.0.0.a" ]

This is correct, since terminfo is not built on Windows.

@snowleopard
Copy link
Owner

I've inspected the code and I don't see how the bug could be triggered. This must be something platform specific, beyond just the windowsHost condition being set to False.

Could one of you run the following please?

need $ binDeps ++ libs
when (pkg == ghcPkg) $ do
    putBuild $ "pkgs = " ++ show (sort pkgs)
    putBuild $ "depNames = " ++ show (map PackageName $ sort depNames)
    putBuild $ "deps = " ++ show deps

@bgamari
Copy link
Collaborator

bgamari commented Dec 24, 2015

I see,

pkgs = [Cabal,binary,deriveConstants,dll-split,genapply,genprimopcode,ghc,ghc-bin,ghc-boot,ghc-cabal,ghc-pkg,hoopl,hp2ps,hpc,hsc2hs,template-haskell,terminfo,transformers]
depNames = []
deps = []

It appears that the issue is that TRANSITIVE_DEP_NAMES is no longer produced by ghc-cabal. It seems that the matter of moving away from ghc-cabal is becoming more pressing by the day.

@snowleopard
Copy link
Owner

@bgamari Is there a way to bring back TRANSITIVE_DEP_NAMES? Getting rid of ghc-cabal is a big task and we probably don't want to have it on the critical path.

By the way, it may be possible to use DepNames instead of TransitiveDepNames, however, if I remember correctly this is not accurate. (Logically, DepNames should do fine, but I remember having problems when using it. Maybe worth to investigate.)

@bgamari
Copy link
Collaborator

bgamari commented Dec 24, 2015

Done. See 3017cbc.

@snowleopard
Copy link
Owner

Great!
@quchen, @bgamari Let me know if you have any other problems with stage0 libs. If not we'll close this issue.

@angerman
Copy link
Collaborator

I've run into this issue as well. I'll give this a try on OS X as well, or has anyone else already?
Btw. who's testing on which platforms?

@angerman
Copy link
Collaborator

Can confirm this works on OS X as well. Now I'm at the same point where @bgamari opened #35.

@snowleopard
Copy link
Owner

Thanks @angerman.

I'm testing on Windows, @bgamari & @quchen on Linux, and you on OS X. I think.

@snowleopard
Copy link
Owner

I'll close this now.

If anyone comes across this issue again, the solution is to update to the latest ghc-cabal version which provides the TRANSITIVE_DEP_NAMES fields.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants