Skip to content

[WIP] Always reconfigure automatically - #2829

Closed
ttuegel wants to merge 32 commits into
haskell:masterfrom
ttuegel:reconfigure
Closed

ttuegel wants to merge 32 commits into
haskell:masterfrom
ttuegel:reconfigure

Conversation

@ttuegel

@ttuegel ttuegel commented Sep 20, 2015

Copy link
Copy Markdown
Member

This is a work-in-progress preview of my solution to #2214.

Already implemented:

  • Cabal saves the arguments to configure in dist/setup-config-args in a version-independent way.
  • A new command, setup reconfigure, that calls configure with the last arguments used. It can also take additional arguments and mappend them to the command line.
  • Whenever dist/setup-config is outdated, reconfigure is automatically called.
  • As a side effect, setup test and setup bench reconfigure and rebuild as necessary.

Not yet implemented:

  • Additional tests
  • Replacing cabal-install's own reconfigure logic with this one.
  • Better interoperability for cabal-install with external Setup programs

Again, this is a work-in-progess, please do not merge yet.

@BardurArantsson

Copy link
Copy Markdown
Collaborator

I may have missed something and I haven't looked through much of the code, but I must say that I think that we should really be aiming for a more stateless approach (over all) such as #2631 instead of trying to fix these state-induced bugs. I'm well aware that this may be controversial.

It looks like some these commits could be useful on their own in terms of advancing the state of the code base independently of this partiular PR/Issue. Is that right? EDIT: Maybe file separate PRs for those?

(Obviously, I don't have any authority on the project, I just wanted to offer my opinion. EDIT: Yes, I realize that you are a long-time contributor :))

@ttuegel

ttuegel commented Oct 16, 2015

Copy link
Copy Markdown
Member Author

I may have missed something and I haven't looked through much of the code, but I must say that I think that we should really be aiming for a more stateless approach (over all) such as #2631 instead of trying to fix these state-induced bugs. I'm well aware that this may be controversial.

Yes, I agree we should aim for statelessness to the degree possible, and that's what I'm really doing here. Let me elaborate on my philosophy of state. There are two sources of state, Cabal and the surrounding system (OS, GHC, foreign libraries, ...). The former should introduce as little state as possible. The latter is inherently stateful and we need to query that state from time to time. These queries are expensive, and the environment only changes slowly, so it is appropriate to cache these queries. Furthermore, it makes sense to build the cache of environment data up-front rather than on-the-fly: you may do work that is not required, but that's preferable to getting half-way through compilation to find that ar doesn't work (for example). That's the approach I'm taking: make Cabal as stateless as possible, while still dealing with the state of the environment.

It looks like some these commits could be useful on their own in terms of advancing the state of the code base independently of this partiular PR/Issue. Is that right?

Yes, I'm cleaning things up as I go along.

@BardurArantsson

Copy link
Copy Markdown
Collaborator

Kewl! :)

@23Skidoo

Copy link
Copy Markdown
Member

@ttuegel What's the status of this? I'm going to create the 1.24 branch soon, do you want this to go in?

@ttuegel

ttuegel commented Dec 17, 2015

Copy link
Copy Markdown
Member Author

Yes, I think I can finish this over the weekend.

@23Skidoo

Copy link
Copy Markdown
Member

Nice!

@ttuegel
ttuegel force-pushed the reconfigure branch 2 times, most recently from d667137 to e6a408a Compare December 19, 2015 23:28
The 'setup test' and 'setup bench' commands will now automatically build
tests and benchmarks, if needed.
This moves some utilities for dealing with UserHooks into that module to
avoid circular imports.
Fix the cabal-install build with Cabal's new reconfigure feature. Does
not yet take advantage of it, just builds correctly.
Redundant imports were introduced by merge conflicts.
Redundant imports were introduced by merge conflicts.
It is not actually possible to determine which of the individual flags
passed to `reconfigure` is responsible for triggering the
reconfiguration.
@ttuegel

ttuegel commented Dec 21, 2015

Copy link
Copy Markdown
Member Author

I can't have this finished in time for the next release; it requires more extensive changes to cabal-install than I previously believed.

@23Skidoo

Copy link
Copy Markdown
Member

OK, noted.

@dcoutts

dcoutts commented Jan 14, 2016

Copy link
Copy Markdown
Contributor

@ttuegel perhaps we should confer here on how to include these things in the nix-local-build branch. In that branch I do all the state tracking at the cabal-install level, so at the package level, nothing within Cabal at the component level.

@ttuegel

ttuegel commented Jan 14, 2016

Copy link
Copy Markdown
Member Author

In that branch I do all the state tracking at the cabal-install level, so at the package level, nothing within Cabal at the component level.

Which state tracking are we talking about? All this does is remember what arguments configure was called with. (I think it should also remember environment variables, but I haven't done that yet.) Since cabal configure and Setup configure take different arguments, I plan to save those states separately, but I haven't touched cabal-install yet.

There is one thing holding me back from finishing this: I need to change SetupWrapper in cabal-install. I need control to be inverted with respect to its current arrangement; I need the version of Cabal being used in the wrapper before I determine which commands to run. In its current incarnation, it will only let me use the version to determine the flags passed to the command, not the actual command itself.

@23Skidoo

Copy link
Copy Markdown
Member

@ttuegel
BTW, I'm actually considering implementing something similar for #3138. Basically, I want to make cabal configure save the arguments it was called with (probably in ~/.cabal/config format) under dist, so that in the onNoBuildConfig branch of reconfigure we'd know how to invoke the setup script and whether -w was used.

@23Skidoo 23Skidoo added this to the Cabal 1.26 milestone May 7, 2016
@23Skidoo 23Skidoo removed the post-1.24 label May 7, 2016
@ezyang

ezyang commented Jul 11, 2016

Copy link
Copy Markdown
Contributor

Since this is self-marked as WIP, I'm going to close the PR for now. Please open a new one if you make more progress / need to RFC more stuff!

@ezyang ezyang closed this Jul 11, 2016
@ezyang ezyang modified the milestones: Cabal 2.0, 2.0 (planned for next feature release) Sep 6, 2016
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.

5 participants