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

Native-static foreign libraries #9637

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

alt-romes
Copy link
Collaborator

@alt-romes alt-romes commented Jan 20, 2024

Please read Github PR Conventions and then fill in one of these two templates.

Sits on top of the refactor from #9602


Template Α: This PR modifies cabal behaviour

Include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • Manual QA notes have been included.
  • Tests have been added. (Ask for help if you don’t know how to write them! Ask for an exemption if tests are too complex for too little coverage!)

Template Β: This PR does not modify cabal behaviour (documentation, tests, refactoring, etc.)

Include the following checklist in your PR:

Introduces 'BuildM', a monad for actions defined in the context of
building a component. Actions in the 'BuildM' monad have access to
'PreBuildComponentInputs', which is the information necessary and
available to a build right before building a component (hence the name).

Introduces as well 'BuildingWhat', a type that distinguishes the kind of
build we are doing (Normal vs Repl vs Haddock vs Hscolour) and the
different flags available for each kind of build.
Refactors the duplicated `buildExtraSources` function from `gbuild` and
`buildOrReplLib` into a standalone monadic computation in the context of
building a component (namely, a 'BuildM' action). This refactor allows
us to share the code for building an extra source amongst the two
functions, and paves the way to fixing haskell#9389.

A standalong part of the refactor of gbuild and buildOrReplLib (haskell#9389)
Creates a new module Distribution.Simple.GHC.Build.Modules which, in the
same spirit as ...GHC.Build.ExtraModules, defines a 'BuildM' action
which builds all the Haskell modules of the component being built.

This function clarifies and re-implements the logic of building Haskell
modules in the different possible ways, while accounting for
Template Haskell special "way requirements", which was previously
duplicated in a non-obvious manner in gbuild and buildOrReplLib.

The Note [Building Haskell modules accounting for TH] in that module
explains the big picture, and the implementation is re-done in light of
it.

A standalone part of the refactor of gbuild vs buildOrReplLib (haskell#9389)
This is the third part of the refactor of gbuild and buildOrReplLib (haskell#9389).
It re-works the linker invocations, focusing on preserving existing
behaviour before simplifying or fixing bugs any further.

Follows the spirit of the two previous commits, with the end goal of (haskell#9389)
@Kleidukos
Copy link
Member

@alt-romes interesting PR! Would you mind clarifying a bit in the manual what this implies? I thought fully static was highly conditional on the libc used for compilation, because glibc cannot be compiled as static (and thus musl has to be used).

Moreover may I interest you in changelog entry? :)

@alt-romes
Copy link
Collaborator Author

@Kleidukos That's a good question. The "fully static" in this patch is determined by GHC, and is as fully static as a fully static executable also produced by cabal, which may well be up-to system libs on macOS, and perhaps glibc remains dynamic (would be simple to check).

I'll handle the changelogs and such Monday. I just wrote the code for it on a whim this morning.

@alt-romes alt-romes changed the title Fully static foreign libraries Native-static foreign libraries Jan 20, 2024
@alt-romes
Copy link
Collaborator Author

@edsko what was your vision of foreign-lib type: native-static originally?

@Kleidukos
Copy link
Member

@alt-romes wonderful, thanks for the clarification. I appreciate the introduction of the term "native-static", it will be interesting to generalise its use where we mean "we try our best".

@andreabedini
Copy link
Collaborator

Is this related to #9320 in anyway?

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

3 participants