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 8.0.2: use -split-sections #21589

Merged
merged 1 commit into from Feb 9, 2017
Merged

GHC 8.0.2: use -split-sections #21589

merged 1 commit into from Feb 9, 2017

Conversation

domenkozar
Copy link
Member

@domenkozar domenkozar commented Jan 2, 2017

See the commit for more information.

cc @peti, I haven't tested much (built stack and darcs) but upstream did quite some testing.

@mention-bot
Copy link

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

@domenkozar domenkozar force-pushed the ghc-split-sections branch 2 times, most recently from 647a821 to 29277f1 Compare January 3, 2017 12:55
# For GHC 8.0.2 we use split-sections instead
# Unsupported for Darwin/Clang, see http://hackage.haskell.org/trac/ghc/ticket/4013
, enableSplitObjs ? (!stdenv.isDarwin && (stdenv.lib.versionAtLeast "8.0.1" ghc.version))
, enableSplitSections ? (!stdenv.isDarwin && (stdenv.lib.versionOlder "8.0.1" ghc.version))
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need a new argument enableSplitSections for this change? It seems to me like "split objects" and "split sections" are two different implementations of the same concept, and IMHO it seems fine to control both with one option.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is also dead_strip for OSX, but it doesn't work all the time.

I was thinking of joining these, but based on different situations you might need to turn on/off different implementations of them.

Copy link
Member Author

@domenkozar domenkozar Jan 3, 2017

Choose a reason for hiding this comment

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

We could enable all of these with a single argument and disable those situations that don't work (for -dead_strip). If somone wants a different strategy, they can just disable and pass some --ghc-option flags. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that sounds like a good compromise. We can also abstract the issue somewhat by adding an appropriate haskell.lib.dontDeadStrip function that hides the implementation. If it turns out that we need to control those flags in dozens of packages, then I'm all for (a) adding an appropriate option to the generic builder and (b) teaching cabal2nix to generate them when necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

@peti sounds good. I think we should rename the option though, since objsplit would then imply section split for GHC 8.0.2 and we're overloading the term. Can we error out if enableSplitObjs is set and use general term such as enableDeadCodeElimination?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that's a good solution. I like the name, too.

@peti
Copy link
Member

peti commented Jan 31, 2017

Will you pick up this PR? It's a really nice feature and I'd love to have it in before we're forking off a new release branch.

@domenkozar
Copy link
Member Author

Yes will do. Planning to clean this up very soon.

-split-sections replaced -split-objs with following upsides:

1) -split-objs adds considerable overhead to compile time

2) combined with stripping, it causes issues when cross-compiling

For upstream see https://ghc.haskell.org/trac/ghc/ticket/8405

This is supported only for Linux/Windows using ld linker.

GHC master also turns on -split-sections by default.

Example using stack:

Without splitting

  $ du /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2
  4       /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/share/bash-completion/completions
  4       /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/share/bash-completion
  4       /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/share
  23416   /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/bin
  23420   /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2

With -split-objs

  $ du /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2
  20632   /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/bin
  4 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/share/bash-completion/completions
  4 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/share/bash-completion
  4       /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/share
  20636   /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2

With -split-sections

  $ du /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2
  4       /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/share/bash-completion/completions
  4       /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/share/bash-completion
  4       /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/share
  20672   /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/bin
  20676   /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2

Note: you currently need following overrides to build stack on 802:

   vector-algorithms = dontCheck super.vector-algorithms;
   path-io = doJailbreak super.path-io;
   stack = doJailbreak super.stack;

Note: Should also work on GHC 8.0.1, but I'm being careful here.
      We could backport later on.
@domenkozar
Copy link
Member Author

cc @peti ready for review :)

@peti peti merged commit 055ab6b into master Feb 9, 2017
@peti peti deleted the ghc-split-sections branch February 9, 2017 10:17
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

4 participants