GHC cannot find lrt

  • Open
  • quality assurance status badge
Details
3 participants
  • Antero Mejr
  • Josselin Poiret
  • Mekeor Melire
Owner
unassigned
Submitted by
Antero Mejr
Severity
normal
Merged with
A
A
Antero Mejr wrote on 26 May 2023 00:25
(address . bug-guix@gnu.org)
877cswaw12.fsf@mailbox.org
Attempting to build a trivial Haskell program using ghc fails, as the
linker cannot find the rt library:

```
~ $ ghc -O2 test.hs
Linking test ...
/home/a/.guix-profile/bin/ld: cannot find -lrt: No such file or directory
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
```

Glibc and gcc-toolchain are installed in the profile, and
~/.guix-profile/lib/librt.so.1 exists.

Maybe this is related to this new bug, or the recent core-updates merge?
M
M
Mekeor Melire wrote on 26 May 2023 11:17
(name . Antero Mejr)(address . antero@mailbox.org)(address . 63728@debbugs.gnu.org)
87zg5rpi0b.fsf@posteo.de
2023-05-25 22:25 bug-guix@gnu.org:

Toggle quote (3 lines)
> Attempting to build a trivial Haskell program using ghc fails,
> as the linker cannot find the rt library:

Does installing gcc-toolchain:static help as a work-around?
M
M
Mekeor Melire wrote on 26 May 2023 11:21
(name . Antero Mejr)(address . antero@mailbox.org)(address . 63728@debbugs.gnu.org)
87v8gfphu9.fsf@posteo.de
2023-05-25 22:25 bug-guix@gnu.org:

Toggle quote (18 lines)
> Attempting to build a trivial Haskell program using ghc fails,
> as the linker cannot find the rt library:
>
> ```
> ~ $ ghc -O2 test.hs
> Linking test ...
> /home/a/.guix-profile/bin/ld: cannot find -lrt: No such file or
> directory
> collect2: error: ld returned 1 exit status
> `gcc' failed in phase `Linker'. (Exit code: 1)
> ```
>
> Glibc and gcc-toolchain are installed in the profile, and
> ~/.guix-profile/lib/librt.so.1 exists.
>
> Maybe this is related to this new bug, or the recent
> core-updates merge? https://issues.guix.gnu.org/63238

There is also this bug I had reported:


I suggest to merge this bug (63728) and the bug I just linked
(63258). What do you think?
A
A
Antero Mejr wrote on 26 May 2023 17:16
(no subject)
(address . control@debbugs.gnu.org)(address . 63728@debbugs.gnu.org)
87lehbw2bj.fsf@mailbox.org
merge 63258 63728
A
A
Antero Mejr wrote on 26 May 2023 17:44
Re: bug#63728: GHC cannot find lrt
(name . Mekeor Melire)(address . mekeor@posteo.de)(address . 63728@debbugs.gnu.org)
87edn3w10l.fsf@mailbox.org
Mekeor Melire <mekeor@posteo.de> writes:

Toggle quote (7 lines)
> 2023-05-25 22:25 bug-guix@gnu.org:
>
>> Attempting to build a trivial Haskell program using ghc fails, as the linker
>> cannot find the rt library:
>
> Does installing gcc-toolchain:static help as a work-around?

I merged this bug with #63258.

The gcc-toolchain:static workaround fixes the rt problem, but now the
binaries aren't linked to libgmp and libffi, even though gmp and libffi
packages are installed in the profile:

Toggle snippet (11 lines)
~$ ghc -O2 test.hs
~$ ldd ./test
linux-vdso.so.1 (0x00007ffe0956f000)
libgmp.so.10 => not found
libc.so.6 => /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libc.so.6 (0x00007fbe27e3f000)
libm.so.6 => /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libm.so.6 (0x00007fbe27d62000)
libffi.so.8 => not found
libgcc_s.so.1 => /gnu/store/qcg59v4yg239jj1k0xvqqqkqv6l8q6ll-gcc-12.2.0-lib/lib/libgcc_s.so.1 (0x00007fbe27d41000)
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/ld-linux-x86-64.so.2 => /gnu/store/ip9mj1pwymxi1yq32zbhwp3n3bycy6yi-glibc-2.35/lib/ld-linux-x86-64.so.2 (0x00007fbe2803d000)

Maybe there should be a ghc-toolchain package that has libgmp and
libffi as inputs, and makes sure GHC links them correctly?
M
M
Mekeor Melire wrote on 29 May 2023 22:04
(name . Antero Mejr)(address . antero@mailbox.org)(address . 63728@debbugs.gnu.org)
87edmyewcd.fsf@posteo.de
2023-05-26 15:44 antero@mailbox.org:

Toggle quote (7 lines)
> The gcc-toolchain:static workaround fixes the rt problem, but
> now the binaries aren't linked to libgmp and libffi, even though
> gmp and libffi packages are installed in the profile:
>
> Maybe there should be a ghc-toolchain package that has libgmp
> and libffi as inputs, and makes sure GHC links them correctly?

Hm. Alternatively, we could just fix gcc-toolchain (so that it
includes rt). But maintainers (understandably) hesitate because
this will trigger a world rebuild.
J
J
Josselin Poiret wrote on 31 May 2023 20:40
(address . 63728@debbugs.gnu.org)
87bki0qr8j.fsf@jpoiret.xyz
Hi everyone,

Mekeor Melire <mekeor@posteo.de> writes:

Toggle quote (4 lines)
> Hm. Alternatively, we could just fix gcc-toolchain (so that it
> includes rt). But maintainers (understandably) hesitate because
> this will trigger a world rebuild.

Yet another alternative would be to patch GHC to not include `-lrt` in
its flags. Yet another big rebuild though! The proper fix in the
meantime is as you mentioned: add ghc-toolchain to contain everything
that's needed. I find it weird though, since I've never had to do
anything of the sort when building Agda locally since the core-updates
merge though.

Best,
--
Josselin Poiret
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmR3lJwQHGRldkBqcG9p
cmV0Lnh5egAKCRBQXkC5FhcaiiEWDACKah3+zxZnAl5asNRg6BzEO/t2lq0DV/pI
T7ljd9El1kUK0skilvT+0V65rzNAtorRm/92CID8YjIanRKnj/NwcalrjJ2zs8RC
IVfVqNnC7SHCRauy2E7YaxlixYIzvhiVOueuz2axs83FWBuO+5LnWE7bDGYQlUCA
ocnUrNJzsImzvBg+cqqgIIXxcRhBsaBHXJ3lZo6cvDvZh2gGisqbE/9Ua3hVfQoT
21GKzLgvkdRxcFgHdMlMXplJ0r0ERgEYI6nY01szMrUSR5JSzRQY8q4m+zXUEiRt
M44wHNwegy5nm2bwMqX3PDXKUfcEQ4aEkA1w5FZQVI7i/9gUBzWBH3BLm7y9adTM
+XktWS7dPxoNN7wZVHPfXCBAnWpNRfr2YJeEki4K1+a2Xsm0jbhvYhAbyybzxt5+
brWIAED0dLtbo8SpYMGVdS0uwoPtG5lUez++FwvL85/CC+yiwqONHtQ688/1AVT9
MF/aUXfSPdcfzFPgkvo1ogdZ54OX1UA=
=SyQy
-----END PGP SIGNATURE-----

?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 63728@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 63728
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch