ghc cannot find libraries of ghc-comonad

  • Open
  • quality assurance status badge
Details
2 participants
  • Christoph Schumacher
  • Lars-Dominik Braun
Owner
unassigned
Submitted by
Christoph Schumacher
Severity
normal
C
C
Christoph Schumacher wrote on 29 Apr 2022 03:39
(address . bug-guix@gnu.org)
27d96a4a345b1d66cb4108dbfa27e79e@mathematik.tu-dortmund.de
I found several bugs with the ghc and ghc-comonad packages:

- ghc needs gcc-toolchain in order to work. This has already been
reported:
- In the store, ghc-libraries seem to have the version appended to their
name.
The linker does not know this and cannot find the libraries.
- I created soft links with the names ghc expects in the current working
directory
and extended LIBRARY_PATH to include the current working directory.
Then linking succeeds.
- But the executable again fails to find the libraries.
It knows about the appended version strings, but it cannot find the
files anyway.
So I created more soft links, and now the simple test program runs.
- But as soon as I try to use a Comonad, the executable crashes.

Here is a minimal example:

Toggle quote (1 lines)
> ls
LinkMe.hs
Main.hs

Toggle quote (1 lines)
> cat LinkMe.hs
import Control.Comonad
main = putStrLn "Congratulations!"

Toggle quote (1 lines)
> guix shell --pure ghc ghc-comonad -- ghc LinkMe.hs
[1 of 1] Compiling Main ( LinkMe.hs, LinkMe.o )

<no location info>: error:
Warning: Couldn't figure out C compiler information!
Make sure you're using GNU gcc, or clang
ghc: could not execute: gcc

Toggle quote (1 lines)
> guix shell --pure ghc ghc-comonad gcc-toolchain -- ghc LinkMe.hs
[1 of 1] Compiling Main ( LinkMe.hs, LinkMe.o )
Linking LinkMe ...
ld: cannot find -lHScomonad-5.0.8-KDPzf2kORSz9Qeif8nQH6d
ld: cannot find -lHStransformers-compat-0.6.6-9ADqfwGTALm8Nq2ZeUpa4p
ld: cannot find -lHSindexed-traversable-0.1.1-Dfr00dUbJtB3rFEVdhtcE9
ld: cannot find -lHSdistributive-0.6.2.1-L7rr3EplzD03NITUnJxmCO
ld: cannot find -lHStagged-0.8.6.1-EiQY3za6Q5HE9cdvqupke2
ld: cannot find -lHSbase-orphans-0.8.5-Iz1X6ZIULaHC76vf03czEu
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

Toggle quote (21 lines)
> ln -s
> /gnu/store/7xfvafaxbpc88bjmvijg38pr8djjx465-ghc-base-orphans-0.8.5/lib/x86_64-linux-ghc-8.10.7/libHSbase-orphans-0.8.5-Iz1X6ZIULaHC76vf03czEu-ghc8.10.7.so
> libHSbase-orphans-0.8.5-Iz1X6ZIULaHC76vf03czEu.so
> ln -s
> /gnu/store/rjkyixykafdhbf67aa3zlhappxl1dgai-ghc-comonad-5.0.8/lib/x86_64-linux-ghc-8.10.7/libHScomonad-5.0.8-KDPzf2kORSz9Qeif8nQH6d-ghc8.10.7.so
> libHScomonad-5.0.8-KDPzf2kORSz9Qeif8nQH6d.so
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHSdistributive-0.6.2.1-L7rr3EplzD03NITUnJxmCO-ghc8.10.7.so
> libHSdistributive-0.6.2.1-L7rr3EplzD03NITUnJxmCO.so
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHSindexed-traversable-0.1.1-Dfr00dUbJtB3rFEVdhtcE9-ghc8.10.7.so
> libHSindexed-traversable-0.1.1-Dfr00dUbJtB3rFEVdhtcE9.so
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHStagged-0.8.6.1-EiQY3za6Q5HE9cdvqupke2-ghc8.10.7.so
> libHStagged-0.8.6.1-EiQY3za6Q5HE9cdvqupke2.so
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHStransformers-compat-0.6.6-9ADqfwGTALm8Nq2ZeUpa4p-ghc8.10.7.so
> libHStransformers-compat-0.6.6-9ADqfwGTALm8Nq2ZeUpa4p.so

> guix shell --pure ghc ghc-comonad gcc-toolchain coreutils -- env
> LIBRARY_PATH=$LIBRARY_PATH:. ghc LinkMe.hs
Linking LinkMe ...

Toggle quote (1 lines)
> ./LinkMe
./LinkMe: error while loading shared libraries:
libHScomonad-5.0.8-KDPzf2kORSz9Qeif8nQH6d-ghc8.10.7.so: cannot open
shared object file: No such file or directory

Toggle quote (5 lines)
> ln -s
> /gnu/store/rjkyixykafdhbf67aa3zlhappxl1dgai-ghc-comonad-5.0.8/lib/x86_64-linux-ghc-8.10.7/libHScomonad-5.0.8-KDPzf2kORSz9Qeif8nQH6d-ghc8.10.7.so
> ./

> ./LinkMe
./LinkMe: error while loading shared libraries:
libHStransformers-compat-0.6.6-9ADqfwGTALm8Nq2ZeUpa4p-ghc8.10.7.so:
cannot open shared object file: No such file or directory

Toggle quote (5 lines)
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHStransformers-compat-0.6.6-9ADqfwGTALm8Nq2ZeUpa4p-ghc8.10.7.so
> ./

> ./LinkMe
./LinkMe: error while loading shared libraries:
libHSindexed-traversable-0.1.1-Dfr00dUbJtB3rFEVdhtcE9-ghc8.10.7.so:
cannot open shared object file: No such file or directory

Toggle quote (4 lines)
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHSindexed-traversable-0.1.1-Dfr00dUbJtB3rFEVdhtcE9-ghc8.10.7.so
> ./

./LinkMe
./LinkMe: error while loading shared libraries:
libHSdistributive-0.6.2.1-L7rr3EplzD03NITUnJxmCO-ghc8.10.7.so: cannot
open shared object file: No such file or directory

Toggle quote (5 lines)
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHSdistributive-0.6.2.1-L7rr3EplzD03NITUnJxmCO-ghc8.10.7.so
> ./

> ./LinkMe
./LinkMe: error while loading shared libraries:
libHStagged-0.8.6.1-EiQY3za6Q5HE9cdvqupke2-ghc8.10.7.so: cannot open
shared object file: No such file or directory

Toggle quote (5 lines)
> ln -s
> /gnu/store/4jfs13lg5g93ssbfdr4hqqadw2iadir7-profile/lib/x86_64-linux-ghc-8.10.7/libHStagged-0.8.6.1-EiQY3za6Q5HE9cdvqupke2-ghc8.10.7.so
> ./

> ./LinkMe
./LinkMe: error while loading shared libraries:
libHSbase-orphans-0.8.5-Iz1X6ZIULaHC76vf03czEu-ghc8.10.7.so: cannot open
shared object file: No such file or directory

Toggle quote (5 lines)
> ln -s
> /gnu/store/7xfvafaxbpc88bjmvijg38pr8djjx465-ghc-base-orphans-0.8.5/lib/x86_64-linux-ghc-8.10.7/libHSbase-orphans-0.8.5-Iz1X6ZIULaHC76vf03czEu-ghc8.10.7.so
> ./

> ./LinkMe
Congratulations!

Toggle quote (1 lines)
> cat Main.hs
{-# LANGUAGE DeriveFunctor #-}

import Control.Comonad (Comonad(..), extend)

data C a = C a deriving (Show, Functor)

instance Comonad C where
extract (C a) = a
duplicate x = C x

main :: IO ()
main = print $ extend id (C 0)

Toggle quote (2 lines)
> guix shell --pure ghc ghc-comonad gcc-toolchain coreutils -- env
> LIBRARY_PATH=$LIBRARY_PATH:. ghc Main.hs
[1 of 1] Compiling Main ( Main.hs, Main.o )
Linking Main ...

Toggle quote (2 lines)
> guix shell --pure ghc ghc-comonad gcc-toolchain coreutils -- env
> LIBRARY_PATH=$LIBRARY_PATH:. ./Main
Main: internal error: stg_ap_p_ret
(GHC version 8.10.7 for x86_64_unknown_linux)
Please report this as a GHC bug:
L
L
Lars-Dominik Braun wrote on 21 Jan 13:49 +0100
(address . christoph.schumacher@mathematik.tu-dortmund.de)(address . 55178@debbugs.gnu.org)
Y8vfWWxaFlPPJu6s@noor.fritz.box
Hi,

Toggle quote (11 lines)
> > guix shell --pure ghc ghc-comonad gcc-toolchain -- ghc LinkMe.hs
> [1 of 1] Compiling Main ( LinkMe.hs, LinkMe.o )
> Linking LinkMe ...
> ld: cannot find -lHScomonad-5.0.8-KDPzf2kORSz9Qeif8nQH6d
> ld: cannot find -lHStransformers-compat-0.6.6-9ADqfwGTALm8Nq2ZeUpa4p
> ld: cannot find -lHSindexed-traversable-0.1.1-Dfr00dUbJtB3rFEVdhtcE9
> ld: cannot find -lHSdistributive-0.6.2.1-L7rr3EplzD03NITUnJxmCO
> ld: cannot find -lHStagged-0.8.6.1-EiQY3za6Q5HE9cdvqupke2
> ld: cannot find -lHSbase-orphans-0.8.5-Iz1X6ZIULaHC76vf03czEu
> collect2: error: ld returned 1 exit status
> `gcc' failed in phase `Linker'. (Exit code: 1)
the problem here is that in Guix we link Haskell executables dynamically
and sometimes move static libraries to a separate output without updating
the config file (because otherwise it would create a reference, which
we’re trying to avoid to save space).

It works fine for me using

guix shell --pure ghc ghc-comonad gcc-toolchain@10 -- ghc --make -dynamic -v LinkMe.hs

Cheers,
Lars
?