-
Notifications
You must be signed in to change notification settings - Fork 712
Directly call in-library functions to build packages #9871
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
base: master
Are you sure you want to change the base?
Conversation
I tried compiling this with
but it fails because |
253e4d5
to
d4a6532
Compare
I've updated the PR now, but please note that this PR is still work in progress and there are quite a few issues that I have yet to resolve. I didn't know about |
17278dc
to
c209ca5
Compare
7392807
to
bbc2418
Compare
e34ac10
to
0085999
Compare
2469702
to
c3554cd
Compare
I have successfully built all of the |
ee74d63
to
243f1c8
Compare
bae1f9d
to
f826f9d
Compare
840f8d4
to
d822b63
Compare
Are there any related issues to that effort? I am trying to figure out at when (broadly, of course) this PR here may land. |
This commit updates the logic in cabal-install's 'elaborateInstallPlan' function to ensure that we don't try to build a profiled dynamic executable if the compiler doesn't support the profiling dynamic way. This brings the logic in cabal-install in sync with the Cabal 'configureProfiling' function, which sets 'withDynExe' to false if the user wants a profiled executable but prof+dyn is not supported by the compiler.
This commit splits up the logic in configureCompiler into two parts: 1. Configuring the compiler proper, e.g. finding the location and version of GHC. 2. Creating a program database of attendant programs such as ghc-pkg, haddock, and build tools such as ar, ld. This is done using information about the compiler, such as its location on the filesystem and toolchain information from its settings file.
This commit fixes an oversight in runPreProcessorWithHsBootHack, which did not correctly take into account the working directory. This could lead to situations in which we failed to apply the hack. Recall that this hack is for situations when one has both an hs-boot file and a file in need of preprocessing, such as: Foo.y Foo.hs-boot or Bar.hsc Bar.hs-boot Failing to apply the hack essentially meant that GHC would not be able to see the hs-boot file, which caused build failures.
d822b63
to
6016670
Compare
I implemented the refactoring I was talking about in that comment in this PR, by refactoring the I've been thoroughly testing this PR by diffing the behaviour between HEAD and this patch when building all of stackage. I've eliminated all the inconsistencies I could find, so I think this work is about ready for another round of review. |
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
The `hooks-exe` package enables `SetupHooks` values to be converted into a `Setup.hs` executable which can be executed independently of Cabal. The `Setup.hs` executable wrapping `SetupHooks` is quite important to preserve the interface used by other tools when packages migrate to `Hooks` from `Custom`. Even though `hooks-exe` is an internal dependency required by the `Setup.hs` wrapper around `SetupHooks`, it is a dependency nonetheless. Given the internal nature of `hooks-exe`, we don't want to impose on our users the obligation to add a dependency on `hooks-exe` in their setup-depends field. Instead, we want `hooks-exe` to be implicitly added to the setup dependencies. This commit does that exactly.
This commit updates the bootstrap plans to account for the new local hooks-exe package, which cabal-install depends on.
6016670
to
8f65ab9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not real confident that I understood everything (or that I covered everything given the size of the diffs).
@sheaf: would it be possible to merge the other PRs this one depend on first, to make reviewing easier? In particular, it's hard to see if the test changes indicate there are behaviour changes or not. Thanks! |
Template Β: This PR does not modify
cabal
behaviour (documentation, tests, refactoring, etc.)This PR modifies
cabal-install
to directly go through theCabal
library when building packages, instead of theSetup
interface (except of course forbuild-type: Custom
packages).Overview of changes:
LibraryMethod
toSetupMethod
(*), in which we directly invoke theCabal
configure
,build
, ... functions.configure
returns aLocalBuildInfo
which must then be passed to subsequent phases, while with the oldSetup
interface everything returnsIO ()
and communication is done through the filesystem (e.g. the local build info file).hooks-exe
, provisioning:CallHooksExe
: the API for communicating with an external hooks executable (cabal-install
depends on this)HooksExe
: the necessary functions for creating a hooks executable (cabal-install
adds a dependency on this when compiling a package withbuild-type: Hooks
).CommunicationHandle
functionality fromprocess
PR #308.(*) NB:
SetupMethod
/SetupWrapper
is now a bit of a misnomer, because the whole aim of this PR is to no longer go through theSetup
interface (and its oldUserHooks
incarnations such asdefaultMainWithHooks
). New naming conventions welcome!The main change is in
Distribution.Client.SetupWrapper
: we add a newSetupMethod
(probably a misnomer at this point because we no longer go throughSetup
; new names for this datatype are welcome) in which we directly invoke theCabal
configure
,build
etc functions rather than going throughSetup
(or the equivalentdefaultMainWithUserHooks
interface).TODO:
process
PR #308.hooks-exe
library when compiling the hooks executable for a package withbuild-type: Hooks
.SetupHooks.hs
.LocalBuildInfo
obtained at the end of configuring, between using the in-library method and going throughSetup
, and make them as consistent as it makes sense to make them.build-tool-depends: blah
in whichblah
needs to access its data directories. This is important, as data directories are another part of process-global state (like the working directory) that is set upon invoking an externalSetup
executable (seeDistribution.Client.SetupWrapper.internalSetupMethod
).BuildToolPaths
test which currently occasionally triggersopenBinaryFile: invalid argument (Bad file descriptor)
hsc2hs
.Setup
forbuild-type: Hooks
unless we absolutely need it.