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 pax fixes #21163

Closed
wants to merge 2 commits into from
Closed

GHC pax fixes #21163

wants to merge 2 commits into from

Conversation

dtzWill
Copy link
Member

@dtzWill dtzWill commented Dec 15, 2016

Motivation for this change

These changes fix the GHC versions used for building and using pandoc.

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.

@mention-bot
Copy link

@dtzWill, thanks for your PR! By analyzing the history of the files in this pull request, we identified @peti, @pikajude and @obadz to be potential reviewers.

@dtzWill
Copy link
Member Author

dtzWill commented Dec 15, 2016

These work for me on my local branch, rebuilding against master (using commits in this PR) currently and will report on that once it finishes (I believe it took an hour or two previously).

@dtzWill
Copy link
Member Author

dtzWill commented Dec 15, 2016

While I have the information in my head:

Just to make sure this is intentional/known, the GHC build process on the way to 8.0.x goes:
7.4.2-binary -> 7.8.4 -> 7.10.3 -> 8.0.1
(Where "a -> b" means "a is used to build b")
(bummer parallel building has to be disabled, haha)

Additionally, I'll note that I left 7.8.4 and 7.10.3 alone pax-wise since their usage to build the next stage seems to not be problematic, and I figured I'd let someone who at least encounters a problem propose weakening protections for those.... but as a result the versions that are pax-friendly and those that aren't is somewhat arbitrary. This isn't really that big of a change from the current situation where 7.6.3 is the only one given needed PaX touchups.

@@ -57,6 +74,15 @@ stdenv.mkDerivation rec {
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";

postInstall = ''
# ghci uses mmap with rwx protection at it implements dynamic
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: "at it"

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, I copied it verbatim from the existing PaX bits applied to 7.6.3...
Which in turn seem to be based on Gentoo's ebuilds.... which looks to originate with this commit (from 2010).

I'll fix the typo in our tree instead of propagating it 👍

# - https://ghc.haskell.org/trac/ghc/ticket/4244
# Therefore, we have to pax-mark the resulting binary.
# Haddock also seems to run with ghci, so mark it as well.
paxmark m $out/lib/${name}/bin/{ghc,haddock}
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment talks about ghci, but the mark applies to the ghc binary. Is that intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also wonder whether it'd make sense to put this commentary somewhere else rather than having to repeat it below.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe the ghci reference is indeed intentional, it matches the discussions on the referenced gentoo bug and haskell ticket, reproduced below for convenience:

See also: https://ghc.haskell.org/trac/ghc/ticket/12657

I'm not sure where the commentary belongs, but it does seem unfortunate to have multiple copies of it. I'll poke at this some more, thanks for the review.

@dtzWill
Copy link
Member Author

dtzWill commented Dec 15, 2016

  • Patch 'ghcHEAD' as well
  • Looks like 8.x only need to paxmark the ghc/haddock binaries (not the bits about non-executable stack)

I believe this is good to go now.

@@ -57,6 +57,8 @@ stdenv.mkDerivation rec {
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";

postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock}
Copy link
Member

Choose a reason for hiding this comment

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

What will this command do when it's run on a platform other than Linux? Do Macs have paxmark? Do all variants of Linux have it and is it always in $PATH like it's assumed here?

Copy link
Contributor

Choose a reason for hiding this comment

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

paxmark is defined as a stub function which is overridden by paxctl's setup-hook; on non-linux paxmark is a no-op.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, cool. I didn't know that.

@peti
Copy link
Member

peti commented Dec 18, 2016

Merged to haskell-updates in 21c88c00a83c25a19c92d76153cd875abeab56db and 6e123a44dbafa6ffd750a7c60d59755d2dfbb1af. The patches will go to master as soon as the test builds at http://hydra.nixos.org/jobset/nixpkgs/haskell-updates show that nothing unexpected happened because of the changes.

@joachifm
Copy link
Contributor

@peti great, thank you! paxctl is generally safe in my experience, but it can conflict with patchelf when dealing with pre-compiled binaries (per what I've personally seen, fwiw).

@peti
Copy link
Member

peti commented Dec 19, 2016

Merged to master.

@peti peti closed this Dec 19, 2016
@dtzWill
Copy link
Member Author

dtzWill commented Dec 19, 2016

Awesome, thanks!

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

Successfully merging this pull request may close these issues.

None yet

4 participants