Skip to content

purescript: fix closure size on OSX #26550

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

Merged
merged 1 commit into from
Jun 14, 2017
Merged

Conversation

cleverca22
Copy link
Contributor

Motivation for this change

cabal generates a Warp_paths module for warp, which contains a bindir variable, pointing to warp's /bin/ folder

without deadcode elimination, that string winds up in the final purs binary, which causes a dependency on warp, which depends on all of ghc, bringing the closure up to 2.9gig

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@domenkozar
Copy link
Member

Does this work if justStaticExecutables is not enabled?

@cleverca22
Copy link
Contributor Author

cleverca22 commented Jun 13, 2017

dang!, yeah, it only works if justStaticExecutables is also ran over it

i'm not sure if anything can be done about that, things like libHSpurescript-0.11.5-ELQ93PZ2tNq8ropwfk7fQs-ghc8.0.2.dylib are referencing ghc

@domenkozar
Copy link
Member

That's what static means, it compiles haskell packages statically. Otherwise it does need to depend on warp.

So we should only enable reference stripping for pkgs.purescript.

@LnL7 LnL7 added the 6.topic: darwin Running or building packages on Darwin label Jun 13, 2017
@cleverca22
Copy link
Contributor Author

when cabal auto-generates the Paths_warp[1] module, it creates a bindir variable, pointing to ${warp}/bin/, which lands in the ${warp}/lib/ghc-8.0.2/warp-3.2.11.2/Paths_warp.hi

using [2] i can then see

  bindir :: FilePath
  {- Unfolding: (unpackCString#
                   "/nix/store/6i6bs80l129d6mlij6zdd63m1gydgfxw-warp-3.2.11.2/bin"#) -}

but under linux, when dead-code elimination is working, that path vanishes from the final ${purescript}/bin/purs binary

[1] https://github.com/yesodweb/wai/blob/master/warp/warp.cabal#L102
[2] https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/IfaceFiles

@cleverca22
Copy link
Contributor Author

this fix may also work for #21200

@cleverca22
Copy link
Contributor Author

the latest commit enables -dead-strip for justStaticExecutables, which shrinks the closure for purescript, and also shrinks the main output for things like hlint from 30mb to 19mb and pandoc from 129mb to 106mb

@domenkozar domenkozar merged commit 8198cc1 into NixOS:master Jun 14, 2017
@cleverca22 cleverca22 deleted the purescript branch June 14, 2017 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants