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

ghc: Add enableBootLibPIC option. #29829

Closed
wants to merge 1 commit into from

Conversation

TravisWhitaker
Copy link
Contributor

@TravisWhitaker TravisWhitaker commented Sep 27, 2017

Motivation for this change

This adds an option called enableBootLibPIC to the non-binary GHC derivations. This option simply builds the GHC boot libraries with -fPIC. Providing position-independent boot libraries allows one to easily build Haskell code into shared objects that are statically linked against all Haskell dependencies, including the RTS. This is not possible with the default GHC build. This is principally desirable when providing Haskell libraries that are meant to be called from foreign code, since the calling code's linking process doesn't have to know anything about GHC at all.

This may be a rather niche use case, although it would be nice to add GHCs with this option set true to the binary cache.

Things done
  • [ pending ] 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 via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • [ pending ] 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.

Copy link
Member

@peti peti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like such a niche use-case that I don't want to support it in Nixpkgs, really, especially considering the fact that the patches are so long and repetitive and error-prone. IMHO, users who want this feature should implement it in their local setup by way of override. Also, I don't believe that we would ever offer a binary cache for any package sets with that feature enabled.

@TravisWhitaker
Copy link
Contributor Author

TravisWhitaker commented Sep 27, 2017 via email

@TravisWhitaker
Copy link
Contributor Author

It seems it is possible to get GHC to link against a different set of wired-in packages by simply using the right -L flags, so it should be possible to write ghcWithPICPackages by using a wrapper script.

If there's no interest in supporting position independent code at all, perhaps it would at least be acceptable to refactor these derivations to make it easier to do the requisite override. Each GHC derivation is factored slightly differently; some define buildMK, while others work without even writing the build.mk file. Users would have to write GHC version-specific overrides, unless I'm missing something here.

@TravisWhitaker
Copy link
Contributor Author

GHC derivations now have enableRelocatedStaticLibs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants