-
Notifications
You must be signed in to change notification settings - Fork 711
cabal test
mishandles autogenerated modules
#3529
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
Comments
Thanks for the report. As a quick question, which version of Cabal are you using? |
Oops, forgot to mention specs :). Gentoo amd64, GHC 7.10.3, Cabal 1.22.8.0, cabal-install 1.22.9.0. |
So, I can't say this is entirely Cabal's fault because of the Custom setup script. But there is a bit of nastiness in pre Cabal-1.24 component handling. Is forcing Cabal-1.24 for your custom script possible? If so there might be a way to do this in a nice way. |
I'd rather have a lower Cabal bound; it looks like most distros are still <=1.22 (is This came up because I just moved my generated sources out of
I'll try Cabal 1.24 and see if it helps. Should switching to 1.24 be sufficient, or do I need to make some other changes too? Does Cabal expose the |
No you will need to make other changes. So let's talk about how this works in Cabal 1.24, because that is the version of Cabal when this all started making sense. How do I get the directory where autogenerated modules go? Use Wait, this takes a ComponentLocalBuildInfo, why do I need this, and where does that come from? OK, get ready to run for the hills. First, why do we need this? The answer is that in Cabal 1.24, we now maintain a separate autogenerated module directory for EACH component (e.g., test suite). So, to get the directory, we need to know what component we are building, which is identified by ComponentLocalBuildInfo. OK, so how do we get this? If you have a LocalBuildInfo, you can get a ComponentLocalBuildInfo if you know the name of the component you want to generate files for. But what should you generate files for? This is an interesting question. Currently, you are generating the files after configuration. But Cabal itself writes autogenerated files (writeAutogenFiles) immediately prior to building. Cabal is probably wrong and should generate the files after configuration. So, you should probably loop through every component in your post-configure hook (I guess dist/build/autogen isn't just another hsSourceDirs? Well, the autogenerated module path is hard-coded into the GHC command line we invoke. Honestly it's an implementation detail of Cabal and you're not supposed to rely on it. The contract the API gives you is that GHC will see Will this fix your problem? Yes probably, because in Cabal 1.24 we no longer put the build files for each component in the same place (which caused your proximal problem.) |
Thanks for the detailed explanation! I'm glad to see things are improving (and getting more documentation) in Cabal land. (Had to upgrade to git master to check this out, looks like it didn't quite make it into 1.24; I gave using Although, since the
|
Oh! I blithely assumed you wanted a different Box for each component but reading your ticket more carefully that's what you DON'T want. So then the fix is very simple: ONLY generate Box for the library. It's as simple as using |
Ah yes, great! Then this is the best kind of bug, EALREADY, and the fix for me is actually just (I don't know where I got
, must have had a stale file lying around.) |
Cabal (or is this a GHC issue?) rebuilds auto-generated sources when running tests, but doesn't rebuild regular sources. If the regular sources depend on auto-generated sources, then there can be multiple conflicting builds of types, and GHC gets confused.
In this test case, the generated
Box
module exportsnewtype Box = Box Int
, and the regularDebox
provides an unboxing function. The tests fordebox
fail to compile, since theBox
module is recompiled butDebox
isn't:The text was updated successfully, but these errors were encountered: