Created
July 28, 2020 16:09
-
-
Save fendor/7fb12ef1fed8c59fdd48958867d831b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jul 27 21:04:52 <fendor> Hi! I have a question regarding per-component builds. In the context of my gsoc, I am trying to extend Cabal/cabal-install to open a repl session for multiple components at once, e.g. it should support `caal repl <lib> <exe>`. My first step was to allow in Cabal `runghc Setup.hs repl <lib> <exe>` which works if the project is configured via `cabal configure`, which seems to be the old way of doing stuff. As far as I can tell, cabal | |
Jul 27 21:04:52 <fendor> uses per-component builds, e.g. it configures a component, then builds it immediately. The problem now is that I can not call Cabal directly via `runghc Setup.hs repl <lib> <exe>` because the library component is not configured. | |
Jul 27 21:05:46 <fendor> It is not configured, since <exe> got configured after building the lib, which causes lib to be un-configured, afaict. | |
Jul 27 21:07:48 <fendor> My first question is, are these findings correct? If yes, the follow-up question is how can we change Cabal or cabal, to either allow to configure multiple components at once, so that `runghc Setup.hs repl <lib> <exe>` works | |
Jul 27 21:08:07 <fendor> or maybe the solution can be in cabal-install land altogether | |
Jul 27 21:15:53 <phadej> - you cannot configure `exe` if `lib` is not built, if exe depends on lib. Configuring exe will check that lib is built, and otherwise say "cannot satisfy dependencies" or something like that. | |
Jul 27 21:16:50 <phadej> - Don't complicate ./Setup interface, IMO it's fine to exclude `build-type: Custom` etc "special treatment" required packages from this functionality | |
Jul 27 21:17:12 <phadej> - then `cabal-install` can do whatever needed | |
Jul 27 21:19:17 <fendor> but after configuring exe successfully, I can not open a repl session for the lib, right? | |
Jul 27 21:19:36 <fendor> phadej, would it be ok for cabal-install to call ghc directly? | |
Jul 27 21:20:22 <fendor> also, how can cabal-install obtain the required options from Cabal? Or could I avoid Cabal altogether? | |
Jul 27 21:27:23 <phadej> you don't need to configure, you need to run preprocessors and maybe do other stuff | |
Jul 27 21:27:30 <phadej> which is infact part of "build" phase | |
Jul 27 21:28:09 <phadej> and `cabal-install` can call GHC directly, through Cabal library. Which is different then through `./Setup` cli interface. | |
Jul 27 21:29:28 <phadej> key point: you do need to some preparations steps, but those aren't "./Setup configure", as it does stuff you don't need, and also does stuff you don't need. | |
Jul 27 21:29:35 <phadej> doesn't do stuff you need* | |
Jul 27 21:30:50 <fendor> Should these preparations steps be done in Cabal, e.g. factor out a new command, or can they be performed by cabal-install? | |
Jul 27 21:32:17 <phadej> I'm 100% against teaching ./Setup anything not-related to "building packages" | |
Jul 27 21:32:28 <phadej> if it doesn't need to be there, it shouldn't. | |
Jul 27 21:32:39 <fendor> that is fine by me, I am just asking for a possible implementation plan | |
Jul 27 21:32:52 <fendor> I am not insisting on changing anything in Cabal | |
Jul 27 21:33:13 <phadej> it would be also easier to not touch anything in Cabal external cli interface | |
Jul 27 21:33:28 * fendor_ has quit (Ping timeout: 246 seconds) | |
Jul 27 21:33:29 <phadej> otherwise you will run out of time figuring out all the corner cases | |
Jul 27 21:33:45 <phadej> so it's both cleaner, and faster. | |
Jul 27 21:33:48 <phadej> win-wn | |
Jul 27 21:34:53 <phadej> (AND IMO, excluding `build-type: Custom` packages - which require interaction via `./Setup` is fine, otherwise you'll also need to specify what hooks are run and when) | |
Jul 27 21:34:58 <fendor> ok, nice. So, I just heard the nix-infrastructure might be all I need. Does that sound reasonable? | |
Jul 27 21:35:12 <phadej> nix-infrastructure? | |
Jul 27 21:36:10 <fendor> nix-build infrastructure | |
Jul 27 21:36:27 <fendor> but I may have misunderstood. | |
Jul 27 21:38:26 <fendor> so, I should not use Cabal's repl to open the multi component repl session? | |
Jul 27 21:40:08 <fendor> but rather call ghc via the Cabal lib interface | |
Jul 27 21:41:37 <phadej> no. Teaching `./Cabal` about multi-component repl session would mean teaching Cabal about multi-component builds | |
Jul 27 21:42:03 <phadej> which is, I'm not exaggerrating, would require very big rewrite - as it is very single-component centered | |
Jul 27 21:43:18 <fendor> it seems, all that needs to be done is to have code path that runs the relevant preprocessors (which can be essentially a build for now), then obtain relevant compilation options and call ghc directly, right? | |
Jul 27 21:45:15 <phadej> yes, for your needs just doing a build is probably fine - except when it fails | |
Jul 27 21:45:25 <phadej> but good start | |
Jul 27 21:45:53 <fendor> ok, sounds nice, thank you! last question, do you know how I obtain the compilation options per component? | |
Jul 27 21:51:09 <phadej> you have to look up how componentlocalbuildinfo is conjured and where | |
Jul 27 21:51:18 <fendor> thanks! | |
Jul 27 21:51:23 <phadej> and how you can execute the same codepaths | |
Jul 27 21:51:29 <phadej> (as it's probably constructed during configure) | |
Jul 27 21:51:41 <phadej> though, if you `build` you `./Setup configure`... | |
Jul 27 21:58:56 <fendor> that sounds doable, thank you for the help! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment