-
Notifications
You must be signed in to change notification settings - Fork 696
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
Explicitly support building with -fno-code #1176
Comments
This even happens when you don't have a configuration as above, but a way more normal one, like hspec's cabal file. A normal build looks like this:
But
Note this only breaks if the code hasn't been built yet (e.g. after
I think this is a bug - |
@23Skidoo Can you reproduce this with some of your packages (or hspec as above)? |
@nh2 I'm a bit swamped right now, will look at this later. |
I was thinking into this direction (nh2@0c51929) but then realized that what I want is not that easy: You could perform a "read-only" typecheck with cabal to build the library, but as soon as you want to typecheck an executable (that depends on your own library and is in a different directory to avoid repeated compilation), you actually need the result of the library compilation. Actually, you only need the *.hi files; it should be possible to generate them without further code generation, but I don't know how (see http://stackoverflow.com/questions/14306934/haskell-how-to-only-generate-hi-file-with-ghc). |
In the mean time, an easy work around would be #1177 - making a full However, this doesn't work as described in my original bug report: ghc reports |
https://github.com/nh2/cabal/compare/no-code-link-shared is a proposal to skip linking on An explicit cabal option to disable this step might be better, though. |
I just added an option -fwrite-interface, to dump interface files precisely when you want to do something like typecheck a library, and then typecheck a dependent executable. |
@ezyang Can you explain a bit more how this is intended to be used? |
If you are planning on doing only typechecking cycles, and you have a library + executable Cabal file, run -fno-code and -fwrite-interface to typecheck the library, and then you will be able to type check the executable (because the library hi files are available.) Needs some UI polish, obviously! |
I also see this error when building even static libraries or executables. Would be happy to hack on it if that's helpful, although I haven't looked at cabal's code before. Not sure if this is a beginner-level problem or not. |
This issue seems to persist, and is currently causing minor frustration in using SublimeHaskell, whose default build mechanism uses two builds: first a standard Here is the relevant SublimeHaskell issue: SublimeHaskell/SublimeHaskell#158 |
A tip from @rwbarton just now on TH works in ghci (due to use of bytecode), so this should be almost as fast as |
I'd like to add another vote for this ticket. I'm not sure what the UI should be ( |
the |
In v1-cabal, this works for just type-checking:
In v2-cabal, it seems that passing new Example: We build ordinarily:
After that, we want to just type-check:
|
@andreasabel I think the issue you mention is #3579: ghc-options is not available in top-level local options (but it still is in per-package options) |
The command toonly typecheck suggested by @andreasabel: is more useful after #7973, cause now @nh2 would be it enough for your use case? how could be it improved to fit it? create a new command would be difficult to get done |
This is a long awaited improvement. I built a shiny new Cabal executable and tried it out today. +It works for a single component:
−It does not work when there are multiple interdependent components:
It seems that Cabal tries to link the dependent components (such as internal libraries), but there is nothing to link because nothing was built! I cannot wait for this improvement to be released! |
If adding a new command
Even though thanks to |
Yes, it should be like |
@andreasabel sorry for a basic question, but why do you need to store |
The typechecking-only build tree contains the cabal configuration, interface files, and even some object files (e.g. |
@Mikolaj you added this issue to the project about replacing So, how about we remove this from the project? |
Yes, I guess the workaround is good enough not to make this issue a blocker (though probably not to close the issue and, in any case, that's for the affected users to opine on). Let me remove this ticket from the https://github.com/haskell/cabal/projects/12 project. Thanks. |
Summary by @ezyang. There is no way to ask Setup to just typecheck a package. It sort of works if you pass
-fno-code
via--ghc-options
but that's purely accidental.I use
cabal build --ghc-options="-Wall -fno-code"
to quickly get all errors/warnings from a project and show them in an editor.However, when I have something like this
in my cabal file that only builds a shared object, I get:
Should we get this warning although we explicitly said
-fno-code
?If yes, can we add an option to disable this kind of warning so that it does not clutter the warnings I am actually interested in (to show in the editor)?
Update:
(The original title was Add option to disable non-linking warnings with -fno-code.)
I just realized that there is an actual bug in this:
After the warning, due to the ghc error cabal will just stop and build no further. This should not happen as there is no code to build!
The text was updated successfully, but these errors were encountered: