unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41508: GHC retains references to Perl, GCC, and others
@ 2020-05-24 14:28 Ricardo Wurmus
  2020-05-26  7:07 ` Ricardo Wurmus
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Wurmus @ 2020-05-24 14:28 UTC (permalink / raw)
  To: 41508

GHC installs a lib/settings file with references to build-time tools,
such as Perl, GCC, and others.

I tried building with a phase that removed those references:

     (match (find-files (string-append (assoc-ref outputs "out") "/lib")
                        "settings")
       ((settings)
        (remove-store-references settings))
       (_ #f))

Unfortunately, this breaks all Haskell packages as GHC always first
tries to set up its build environment.  Any Haskell package’s configure
phase fails as GHC fails to find GCC.

It seems to me that the only way around this is to patch GHC to allow
looking up of GCC and Perl through environment variables, but perhaps
this is unrealistic.

For comparison, this is the size of the broken GHC:

--8<---------------cut here---------------start------------->8---
$ guix size /gnu/store/x2rv5wz3d9z35p93sjv42gxs34y18ky3-ghc-8.6.5
store item                                                       total    self
/gnu/store/x2rv5wz3d9z35p93sjv42gxs34y18ky3-ghc-8.6.5             1639.2  1358.0  82.8%
/gnu/store/g8x8isxfg7in2w4jrmmh9r4zb9c8vfwn-ghc-8.6.5-doc          165.7   126.3   7.7%
/gnu/store/8zvc5mvk0xm3ygrxsgpyy5ilxb5rzjry-perl-5.30.2            146.2    57.1   3.5%
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31              38.4    36.7   2.2%
/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib           71.0    32.6   2.0%
/gnu/store/57xj5gcy1jbl9ai2lnrqnpr0dald9i65-coreutils-8.32          88.0    17.0   1.0%
/gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2             76.9     5.9   0.4%
/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0               73.8     2.7   0.2%
/gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16       1.6     1.6   0.1%
/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16     39.4     1.0   0.1%
/gnu/store/bw15z9kh9c65ycc2vbhl2izwfwfva7p1-libffi-3.3              71.2     0.2   0.0%
total: 1639.2 MiB
--8<---------------cut here---------------end--------------->8---

and this is the size of the unpatched GHC:

--8<---------------cut here---------------start------------->8---
$ guix size $(guix build ghc)
store item                                                       total    self
/gnu/store/vdwkplh23jr54bg9mqvym26l8fv6x6kw-ghc-8.6.5             1862.1  1346.9  72.3%
/gnu/store/6yx0cw49561iyikkvb37hd0li6hkcg8z-ghc-8.6.5-doc          176.7   137.3   7.4%
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0              178.5   107.3   5.8%
/gnu/store/8zvc5mvk0xm3ygrxsgpyy5ilxb5rzjry-perl-5.30.2            146.2    57.1   3.1%
/gnu/store/m1z7cdbqsqyp9xnjw5cvlb4a7gkcg3m4-binutils-2.34           93.0    54.6   2.9%
/gnu/store/0m0vd873jp61lcm4xa3ljdgx381qa782-guile-3.0.2            132.8    53.2   2.9%
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31              38.4    36.7   2.0%
/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib           71.0    32.6   1.8%
/gnu/store/57xj5gcy1jbl9ai2lnrqnpr0dald9i65-coreutils-8.32          88.0    17.0   0.9%
/gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2             76.9     5.9   0.3%
/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0               73.8     2.7   0.1%
/gnu/store/6fvqsjy4m5zbkipwh8grv94snlhnsnag-gmp-6.2.0               73.8     2.7   0.1%
/gnu/store/rip41jax9swcx356sj43h5xqads9fih5-libunistring-0.9.10     73.4     2.4   0.1%
/gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16       1.6     1.6   0.1%
/gnu/store/58aqsgnc8sz70zkqp6ad9k72s7vy2fk5-pkg-config-0.29.2       72.3     1.3   0.1%
/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16     39.4     1.0   0.1%
/gnu/store/hg5z55cy28qxq3v2s9d9lw6dkhyfya84-libgc-8.0.4             71.8     0.8   0.0%
/gnu/store/g2s5jfkfd4k973wb58476b1bbv9zpm6m-zlib-1.2.11             38.6     0.2   0.0%
/gnu/store/bw15z9kh9c65ycc2vbhl2izwfwfva7p1-libffi-3.3              71.2     0.2   0.0%
/gnu/store/vd0876ky3ip8zgl5m15l23vqnpqx7y5v-libffi-3.3              71.2     0.2   0.0%
/gnu/store/vv9j7pi05daplyv61jv9yhj5vpmn0p2n-libltdl-2.4.6           71.2     0.2   0.0%
/gnu/store/mpa04aq8lblbcviyxywxcsb1zbi0mf39-ld-wrapper-0           187.5     0.1   0.0%
total: 1862.1 MiB
--8<---------------cut here---------------end--------------->8---

This is what the settings file looks like:

--8<---------------cut here---------------start------------->8---
[("GCC extra via C opts", " -fwrapv -fno-builtin"),
 ("C compiler command", "/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/bin/gcc"),
 ("C compiler flags", " -fno-stack-protector"),
 ("C compiler link flags", " "),
 ("C compiler supports -no-pie", "YES"),
 ("Haskell CPP command","/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/bin/gcc"),
 ("Haskell CPP flags","-E -undef -traditional"),
 ("ld command", "/gnu/store/mpa04aq8lblbcviyxywxcsb1zbi0mf39-ld-wrapper-0/bin/ld"),
 ("ld flags", ""),
 ("ld supports compact unwind", "YES"),
 ("ld supports build-id", "YES"),
 ("ld supports filelist", "NO"),
 ("ld is GNU ld", "YES"),
 ("ar command", "/gnu/store/m1z7cdbqsqyp9xnjw5cvlb4a7gkcg3m4-binutils-2.34/bin/ar"),
 ("ar flags", "q"),
 ("ar supports at file", "YES"),
 ("ranlib command", "/gnu/store/m1z7cdbqsqyp9xnjw5cvlb4a7gkcg3m4-binutils-2.34/bin/ranlib"),
 ("touch command", "touch"),
 ("dllwrap command", "/bin/false"),
 ("windres command", "/bin/false"),
 ("libtool command", "libtool"),
 ("perl command", "/gnu/store/8zvc5mvk0xm3ygrxsgpyy5ilxb5rzjry-perl-5.30.2/bin/perl"),
 ("cross compiling", "NO"),
 ("target os", "OSLinux"),
 ("target arch", "ArchX86_64"),
 ("target word size", "8"),
 ("target has GNU nonexec stack", "True"),
 ("target has .ident directive", "True"),
 ("target has subsections via symbols", "False"),
 ("target has RTS linker", "YES"),
 ("Unregisterised", "NO"),
 ("LLVM llc command", "llc"),
 ("LLVM opt command", "opt"),
 ("LLVM clang command", "clang")
 ]

--8<---------------cut here---------------end--------------->8---


-- 
Ricardo




^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#41508: GHC retains references to Perl, GCC, and others
  2020-05-24 14:28 bug#41508: GHC retains references to Perl, GCC, and others Ricardo Wurmus
@ 2020-05-26  7:07 ` Ricardo Wurmus
  0 siblings, 0 replies; 2+ messages in thread
From: Ricardo Wurmus @ 2020-05-26  7:07 UTC (permalink / raw)
  To: 41508


Ricardo Wurmus <rekado@elephly.net> writes:

> GHC installs a lib/settings file with references to build-time tools,
> such as Perl, GCC, and others.
>
> I tried building with a phase that removed those references:
>
>      (match (find-files (string-append (assoc-ref outputs "out") "/lib")
>                         "settings")
>        ((settings)
>         (remove-store-references settings))
>        (_ #f))
>
> Unfortunately, this breaks all Haskell packages as GHC always first
> tries to set up its build environment.  Any Haskell package’s configure
> phase fails as GHC fails to find GCC.
>
> It seems to me that the only way around this is to patch GHC to allow
> looking up of GCC and Perl through environment variables, but perhaps
> this is unrealistic.

When I looked at that settings file again, I noticed that the LLVM tools
are named without an absolute file name.  So I patched it to refer to
its tools by the basename (“gcc” instead of “/gnu/store/…/bin/gcc”, etc)
and that did the trick.

--8<---------------cut here---------------start------------->8---
   (substitute* (find-files (string-append (assoc-ref outputs "out") "/lib/")
                            "settings")
     (("/gnu/store/.*/bin/(.*)" m program) program))
--8<---------------cut here---------------end--------------->8---

This means, however, that people who install GHC to compile things will
need to also install gcc-toolchain (and perhaps perl), as GHC will try
to invoke them.  Not propagating these tools means that users of Haskell
packages providing an executable (such as Pandoc) will benefit from a
smaller package closure.

Perhaps it would be better not to mess with the “settings” file and
instead work on cutting references from Haskell packages to GHC itself.
The main reason why Haskell packages retain references to GHC is due to
the set of Haskell packages that GHC provides.  If we could separate GHC
from the set of core packages it provides then Haskell packages could
reference the packages they depend on without also dragging in GHC
itself.

-- 
Ricardo




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-26  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24 14:28 bug#41508: GHC retains references to Perl, GCC, and others Ricardo Wurmus
2020-05-26  7:07 ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).