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

Alex/library dirs static and extra libraries static #7536

Conversation

alexbiehl
Copy link
Member

@alexbiehl alexbiehl commented Aug 12, 2021

This PR is the continuation of #6935, in particular the next step in the plan laid out by nh2/static-haskell-nix#62 (comment).

The commits in this PR were kindly developed by @nh2, I just rebased and adjusted here and there for recent Cabal developments.

We need to see how much adjustment we need for the testsuite to pass. Once that's done the I would prepare a patch for GHC honouring the new fields for static linking.


Please include the following checklist in your PR:

Please also shortly describe how you tested your change. Bonus points for added tests!

@alexbiehl alexbiehl force-pushed the alex/library-dirs-static-and-extra-libraries-static branch 11 times, most recently from 00f772e to de15a94 Compare August 13, 2021 05:59
@Mikolaj Mikolaj self-requested a review August 13, 2021 07:51
@alexbiehl alexbiehl marked this pull request as ready for review August 13, 2021 14:33
@alexbiehl
Copy link
Member Author

@Mikolaj I think this is ready for review!

@Mikolaj
Copy link
Member

Mikolaj commented Aug 13, 2021

Splendid. Am I right guessing this is supposed to help in situations like this:

cabal new-build --enable-executable-static --ghc-options="-optl-lfreetype -optl-lpng -optl-lbz2 -optl-lbrotlidec-static -optl-lbrotlicommon-static"

which is what I needed to write in order to link SDL [edit; SDL2_TTF to be precise] application statically? (and failed, see see utdemir/ghc-musl#14 (comment))

Copy link
Member

@emilypi emilypi left a comment

Choose a reason for hiding this comment

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

This is really complete. Thanks @alexbiehl

@emilypi
Copy link
Member

emilypi commented Aug 14, 2021

Also, do you mind adding a changelog entry?

nh2 and others added 4 commits August 14, 2021 10:07
This improves static building of packages with pkg-config depends,
by using the pkg-config feature designed for just that.
It results in more `-l` flags being emitted by `pkg-config --libs`,
namely those of all recursive `.a` file dependencies.
* WIP: Still need to update ghc to use the new `libraryDirsStatic` and
       `extraLibrariesStatic` fields in `InstalledPackageInfo` for linking.
* WIP: Adding -L paths to .a libs in .conf files will likely increase nix
       closure size for dynamically linked Haskell packages because if pkg-config
       finds an `-a` file, the path to it will be remembered.
       (That only has an impact if the .a file is in a split-output from the .so file.)
       Perhaps we make the feature that `pkg-config --static` is called
       opt-outable.
       On the other hand Haskell libs always carry their .a files, so pulling
       a few system `.a` files more shouldn't make much of a difference.
       So this opt-out should probably be an extra feature for later, if at all.
@alexbiehl alexbiehl force-pushed the alex/library-dirs-static-and-extra-libraries-static branch from de15a94 to 81f98c4 Compare August 14, 2021 08:08
@alexbiehl
Copy link
Member Author

Also, do you mind adding a changelog entry?

@emilypi Done!

@alexbiehl
Copy link
Member Author

alexbiehl commented Aug 14, 2021

@Mikolaj That's exactly right. For now this PR doesn't do very much. Once merged, I will bump Cabal for GHC, add a new flag to create static exes where I will make use of the newly added field in the InstalledPackageInfo. Only then we will have full end-to-end support for more convenient static linking. We are so close!!

@alexbiehl alexbiehl requested a review from emilypi August 14, 2021 08:13
@Mikolaj
Copy link
Member

Mikolaj commented Aug 14, 2021

@alexbiehl: I think @emilypi meant something like that: https://github.com/Mikolaj/cabal/blob/91195e844e44f585298c0cb78806103904c4f9bb/changelog.d/pr-7510

But perhaps your way of adding the changelog is fine, too, can't tell.

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

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

Great job. Looking forward to GHC changes.

@alexbiehl alexbiehl merged commit b53386d into haskell:master Aug 14, 2021
@alexbiehl alexbiehl deleted the alex/library-dirs-static-and-extra-libraries-static branch August 14, 2021 11:58
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.

4 participants