Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple outputs for haskell ecosystem #4504

Closed
shlevy opened this issue Oct 13, 2014 · 23 comments
Closed

Multiple outputs for haskell ecosystem #4504

shlevy opened this issue Oct 13, 2014 · 23 comments
Labels
0.kind: enhancement Add something new 6.topic: closure size The final size of a derivation, including its dependencies 6.topic: haskell

Comments

@shlevy
Copy link
Member

shlevy commented Oct 13, 2014

Haskell closures could be greatly reduced if:

a) the shared libraries that come with ghc that all haskell shared libraries link to were in a separate output from the compiler, and
b) documentation were in a separate output from the binary/library being built

cc @peti

@peti
Copy link
Member

peti commented Oct 13, 2014

Yes, I completely agree. It's probably not even hard to implement that in the generic Cabal builder.

@copumpkin
Copy link
Member

👍

@peti peti mentioned this issue Jun 18, 2015
@Profpatsch
Copy link
Member

@peti Maybe this has been fixed already?

@peti
Copy link
Member

peti commented Mar 7, 2016

No, we don't support multiple outputs at the moment.

@peti peti added the 6.topic: closure size The final size of a derivation, including its dependencies label Apr 28, 2016
@peti
Copy link
Member

peti commented Apr 28, 2016

#10541 could also be improved.

@peti
Copy link
Member

peti commented Apr 28, 2016

#8390 has interesting discussion about this subject.

@rasendubi
Copy link
Member

b) is partially addressed at #16167 (at least for 7.10.x and 8.0.1)

@rasendubi
Copy link
Member

rasendubi commented Jun 14, 2016

Testing a patch to move libraries in a separate output now. Will report back soon.

Don't know how to split static and dynamic libraries apart, though.

@shlevy
Copy link
Member Author

shlevy commented Jun 14, 2016

Do we build static libraries by default? Should we? @peti

@peti
Copy link
Member

peti commented Jun 14, 2016 via email

@shlevy
Copy link
Member Author

shlevy commented Jun 14, 2016

Generally in nixpkgs we only build shared and static you have to request specifically, is there a reason haskell is different?

@peti
Copy link
Member

peti commented Jun 14, 2016 via email

@shlevy
Copy link
Member Author

shlevy commented Jun 14, 2016

But if we do this split, that latter won't be an issue, right? Since having the runtime statically linked vs dynamically shouldn't make a huge difference in runtime deps (and will be much less wasteful if you have multiple binaries)

@Profpatsch
Copy link
Member

Profpatsch commented Jun 14, 2016

There is also the issue of cabal-generated source files on build which can be (and are!) referenced by packages to get stuff from different paths, e.g. https://hackage.haskell.org/package/gitit-0.12.1.1/docs/src/Paths_gitit.html.
Those are generated by this brilliant peace of engineering: https://github.com/haskell/cabal/blob/master/Cabal/Distribution/Simple/Build/PathsModule.hs

@shlevy
Copy link
Member Author

shlevy commented Jun 14, 2016

filename_stuff :: String

wow

@sopvop
Copy link
Contributor

sopvop commented Nov 25, 2016

Starting with ghc 8.0.2 ./Setup.hs should support --libdir and --dynlibdir flags, first one is for static libraries and second for dynamic. Docs, and commit - haskell/cabal#4011

@sopvop
Copy link
Contributor

sopvop commented Nov 25, 2016

The Paths_pkgname module problem is real. A lot of haskell packages install data and use Paths_pkgname to access it. So even if you compile executable statically, you can still get 1.5GiB closure if you are not careful.
I propose to add following to generic-builder.nix:
Extra argument which defaults to false

{ args
, splitDataOutput ? false # backwards compatible
}

Conditional mutiple-outputs and configure flags

{
outputs = if splitDataOutput then [ "out" "data"] else ["out"];
defaultConfigureFlags = [
    "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
    (optionalString splitDataOutput "--datadir=$data/\\$datasubdir")
   other stuff ];
}

If it turns out that older cabal or ghc has problems with it, we can always back out.
At first this can be used to manually fix problematic packages, and later maybe cabal2nix
can automate that by examining PackageDescription.dataFiles.

@sopvop
Copy link
Contributor

sopvop commented Nov 25, 2016

Ah, disregard that. Paths_pkgname it also has libdir in there.

@domenkozar
Copy link
Member

I'd hope we can split libdir and prefix.

With dead code elimination, most of the stuff in Paths_pkgname should be stripped out. If libdir is used then in Paths_pkgname is a very edge case we can fix per package.

@domenkozar
Copy link
Member

#27196

@domenkozar
Copy link
Member

There are now separate data and doc outputs in master branch (#27196).

This should fix most of the closure size issues. cabal2nix still needs to be released to turn these flags on given packages have data.

There is an outstanding PR for bin output in #27209

@shlevy
Copy link
Member Author

shlevy commented Jul 27, 2017

Now if only we could do GHC itself... Great work guys!

@domenkozar
Copy link
Member

I think we should close this and open a new issue for GHC if wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 6.topic: closure size The final size of a derivation, including its dependencies 6.topic: haskell
Projects
None yet
Development

No branches or pull requests

7 participants