-
Notifications
You must be signed in to change notification settings - Fork 710
Access to the last used GHC flags #6203
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
Does #5954 not give you the information you require? |
@fendor I think build-info provides a bunch of useful information that I can use for other kinds of tooling. e.g. I could use the component name mappings to generate commands and I can use the source directories (combined with component names) to automate the generation of test files. But for this particular usecase of programmatically using
|
@DanielG I'm not completely opposed to having to parse JSON, although I'd rather if there was no parsing involved (I have to do the parsing in the editor and there are many reasons why JSON parsing is a PITA there). But I would request that at least one of the fields is the full set of ghc flags so I don't have to regenerate it from different sections. A workaround I was considering was having a compiler plugin dump the compiler version and flags to a hidden file at the base of the source directory. |
I don't think it would be a problem to also provide a slimmed down version for easy parsing as long as you don't expect it to mirror all the info in build.json exactly. Alternatively we can also dump One thing about your requirements I don't really understand is why you're so adamant about getting exactly the options of the last invocation. The way the workflow is supposed to work is that you use As a user of your tool I might actually be slightly irritated about it using whatever I used last to run |
If it's just the compiler and flags, that'd good enough for me!
🤣 totally agree, but unfortunately I want the unenlightened to be able to use my tool as well. I'm ok parsing JSON from emacs for additional (optional) feature sets, so no need for s-expression output. BTW there is one more hack that @rahulmutt suggested, which is to write a binary parser for the
I would be very surprised if the example you can come up with was a common situation. It can be easily worked around by issuing a command using your regular compiler version. One of the overriding design constraints of haskell-tng and hsinspect is to work for 99% of the time and to make it easy to correct the remaining 1%. Working around that final 1% is a rabbit hole I am not interested in (unless somebody wants to pay me). Aside: the cache miss cost is so high on larger projects that I'd personally like cabal to require an additional flag so that I have to confirm "yes I really mean for you to wipe out the resolution cache that takes 60 seconds to create". |
This comment has been minimized.
This comment has been minimized.
I didn't really mean just anything that's not emacs, but s-expressions really are super easy to parse and I bet you can find a 20loc parser for any editor you want to support but honestly the same can be said of json.
That's fair just so long as the user is informed about whats going on and that it's different from the default behavior of the build-tool.
Haha, that's funny. I started working on ghc-mod and cabal-helper and all that because I was pissed about how tools only used to work in like 80% of cases and vowed to make them work 100% of the time. Well 95% so far but trending upwards ;)
I'll be waiting for your PR to add a |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have a (very slow) workaround to this problem that uses a heavily modified version of the https://gitlab.com/tseenshe/haskell-tng.el/blob/tng/cabal-ghcflags.sh This dumps out It's really really slow, and it doesn't support when the user changes their compilation preferences, and it requires the user to keep it in sync with the build definition. If cabal generated these files automatically (instead of the |
I have an even better workaround to this problem, I have a compiler plugin called There are some rough edges to work out, e.g. I still do not handle incremental compilations and it is difficult to install without #2965 and #6307. It would still be better if |
Doesn't |
@phadej that's discussed above |
This is a question / discussion that can hopefully turn into a well defined feature request, rather than a bug report. I hope it's ok to do it in this format 😅
I am implementing tooling on top of the ghc api (see https://gitlab.com/tseenshe/hsinspect) and I am unfortunately unable to find the correct ghc version and flags to use for any given haskell source file.
I orginally wanted to use the envfiles generated by
v2-exec
but that 1) requires knowing which flags were last used 2) requires the project to have successfully compiled to get the inplace packages 3) doesn't let me know which ghc flags were used (e.g. lang extensions, preprocessor flags, etc).I have had a discussion with the
cabal-helper
author at DanielG/cabal-helper#75 where we concluded thatcabal-helper
currently doesn't do what I need, and I have had an offline discussion with thehie-bios
authors where we concluded that it is not possible to get what I need from thecabal
executable by hackingv2-repl
(although it's possible to get close, see notes at the end).I am watching #5954 by @fendor from a distance but I still don't think it gives me what I need, although it might give some useful information.
For any given source file I need to know the ghc version and ghcflags that were last used to compile that file. e.g. if a user is swapping compiler version or optimisation flags, I need access to the most recent. Ideally I'd like to get the information back in a really simple format that doesn't require further processing (e.g. so that I can script it in a launcher script). For example, this UX would be ideal
If there is no cache hit (e.g. if the user hasn't called v2-build or v2-run yet), then it is ok to exit with a failure.
Appendix 1:
hie-bios
uses a hack that ultimately doesn't work. It uses a wrapper script to masquerade asghc
. But 1) there is no way to find out which parameters the user last used 2) the cache will always miss because the ghc hash will change.Appendix 2: I would love it if we got into trading features like old fashioned hippies. e.g. if you implement this feature in cabal-install, I will prioritise your feature request in haskell-tng/hsinspect.
The text was updated successfully, but these errors were encountered: