Re: Using Haskell library packages - linker error

2020-09-07 Thread Timothy Sample
Jakub Kądziołka  writes:

> On Mon, Sep 07, 2020 at 09:50:51AM -0400, Timothy Sample wrote:
>
>> GHC needs a special flag to link shared libraries.  We recently starting
>> building shared libraries for our Haskell packages.  The static ones are
>> still being built, but they go to a separate output.  I think you can
>> fix your problem in one of two ways:
>> 
>> 1. Pass the “-dynamic” flag to GHC (and maybe “-fPIC”);
>> 2. Use “ghc-ieee754:static”.
>
> ghc-ieee754:static doesn't seem to exist, [...]

Right.  It does exist, but it’s hidden from the Guix UI.  This is a
result of the finicky way the output is added.

> [...] but passing -dynamic does indeed work. The workaround also
> translates to Agda, with
>
> $ agda --ghc-flag=-dynamic --compile hello-world.agda

Cool.  That’s good to know.

> I'd really rather this wasn't necessary, though. I can already imagine
> having to figure out how to pass this flag to agda through build systems
> and editor plugins.

Absolutely.  I’ve done some of that work on our more complicated Haskell
packages, and it can get a little tricky.  To be honest, I’m not sure
how to move forward.  I know that Arch takes a similar approach to
packaging Haskell libraries, but I don’t know how they manage the
experience.

> On a related note, shouldn't it be possible to use agda without
> specifying ghc (and transitively, gcc) in your profile?

AIUI, this is following GCC.  GCC by itself doesn’t know how to find the
assembler, but the “gcc-toolchain” package manages this automatically.
Similarly, GHC doesn’t know how to find GCC, and Agda doesn’t know how
to find GHC.  We might need to make “ghc-toolchain” and “agda-toolchain”
packages (this has sorta been discussed before [1, 2]).

At the end of the day, our Haskell ecosystem is in need of some more
attention.  It’s really not far away from being nice, but it needs some
gentle nudges here and there.


-- Tim

[1] https://lists.gnu.org/archive/html/guix-devel/2018-08/msg00175.html
[2] https://lists.gnu.org/archive/html/guix-devel/2020-04/msg00318.html



Re: Using Haskell library packages - linker error

2020-09-07 Thread Jakub Kądziołka
On Mon, Sep 07, 2020 at 09:50:51AM -0400, Timothy Sample wrote:
> Hi Jakub,
> 
> Jakub Kądziołka  writes:
> 
> > I am trying to set up Agda, and I have reduced it to a simpler problem:
> >
> > $ cat test.hs
> > import Numeric.IEEE
> >
> > main = return ()
> > $ genv --pure --ad-hoc ghc@8.6 ghc-ieee754 gcc-toolchain
> > % ghc test.hs
> > Linking test ...
> > ld: cannot find -lHSieee754-0.8.0-IfCS1Dp7pQVIOQRslM6kD
> > collect2: error: ld returned 1 exit status
> > `gcc' failed in phase `Linker'. (Exit code: 1)
> >
> > How can I fix this error? Am I doing something wrong, or is this a
> > packaging bug?
> 
> GHC needs a special flag to link shared libraries.  We recently starting
> building shared libraries for our Haskell packages.  The static ones are
> still being built, but they go to a separate output.  I think you can
> fix your problem in one of two ways:
> 
> 1. Pass the “-dynamic” flag to GHC (and maybe “-fPIC”);
> 2. Use “ghc-ieee754:static”.

ghc-ieee754:static doesn't seem to exist, but passing -dynamic does
indeed work. The workaround also translates to Agda, with

$ agda --ghc-flag=-dynamic --compile hello-world.agda

I'd really rather this wasn't necessary, though. I can already imagine
having to figure out how to pass this flag to agda through build systems
and editor plugins.

On a related note, shouldn't it be possible to use agda without
specifying ghc (and transitively, gcc) in your profile?

Regards,
Jakub Kądziołka


signature.asc
Description: PGP signature


Re: Using Haskell library packages - linker error

2020-09-07 Thread Timothy Sample
Hi Jakub,

Jakub Kądziołka  writes:

> I am trying to set up Agda, and I have reduced it to a simpler problem:
>
> $ cat test.hs
> import Numeric.IEEE
>
> main = return ()
> $ genv --pure --ad-hoc ghc@8.6 ghc-ieee754 gcc-toolchain
> % ghc test.hs
> Linking test ...
> ld: cannot find -lHSieee754-0.8.0-IfCS1Dp7pQVIOQRslM6kD
> collect2: error: ld returned 1 exit status
> `gcc' failed in phase `Linker'. (Exit code: 1)
>
> How can I fix this error? Am I doing something wrong, or is this a
> packaging bug?

GHC needs a special flag to link shared libraries.  We recently starting
building shared libraries for our Haskell packages.  The static ones are
still being built, but they go to a separate output.  I think you can
fix your problem in one of two ways:

1. Pass the “-dynamic” flag to GHC (and maybe “-fPIC”);
2. Use “ghc-ieee754:static”.

The first is preferred because the second could get really tricky if
there are nested dependencies.

The fact that the user experience is so wonky is a bit of packaging bug,
for sure.  I’m not sure how to make it nicer just yet.


-- Tim



Using Haskell library packages - linker error

2020-09-06 Thread Jakub Kądziołka
Hello,

I am trying to set up Agda, and I have reduced it to a simpler problem:

$ cat test.hs
import Numeric.IEEE

main = return ()
$ genv --pure --ad-hoc ghc@8.6 ghc-ieee754 gcc-toolchain
% ghc test.hs
Linking test ...
ld: cannot find -lHSieee754-0.8.0-IfCS1Dp7pQVIOQRslM6kD
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

How can I fix this error? Am I doing something wrong, or is this a
packaging bug?

Regards,
Jakub Kądziołka


signature.asc
Description: PGP signature