Skip to content
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

direct cradle: weird errors on static GHC flags #432

Open
lyokha opened this issue Apr 14, 2024 · 2 comments
Open

direct cradle: weird errors on static GHC flags #432

lyokha opened this issue Apr 14, 2024 · 2 comments

Comments

@lyokha
Copy link

lyokha commented Apr 14, 2024

Direct cradles accept only dynamic GHC flags, static flags are considered targets. Configuration

cradle:
  direct:
    arguments: ["-Wall", "-O2", "--make"]

gives

$ hie-bios check aaa_bb.hs
[Debug] ghc --print-libdir
[Info] Cradle: Cradle{ cradleRootDir = "/home/lyokha/devel/nginx-haskell-module/haskell/ngx-export-distribution/test-nhm", cradleOptsProg = CradleAction: Direct}
[Info] invoking build tool to determine build flags (this may take some time depending on the cache)
hie-bios: target ‘--make’ is not a module name or a source file

It is not stated in documentation that only dynamic flags are accepted as flags, so I had to clone the project to find out what happens (in addCmdOpts).

IMHO, it seems to make sense to

  1. Clearly state in documentation that direct cradles accepts dynamic flags only.
  2. (Probably) Catch static flags in addCmdOpts and warn about them not trying to consider them targets.
@fendor
Copy link
Collaborator

fendor commented Apr 14, 2024

Both of these sound like good improvements, and I'd be happy to merge PRs that improve the docs and addCmdOpts.

@lyokha
Copy link
Author

lyokha commented Apr 14, 2024

It's look that it's not simple to extract mode options (--make etc.) as the corresponding parser parseModeFlags is only available in the GHC Main.hs (see https://github.com/ghc/ghc/blob/5e4f4ba835fd24135759ee7a2d0d5c636a8a1505/ghc/Main.hs#L577), so the point 1 still survives while point 2 is fading. While it's still possible to catch all option-like arguments (i.e. those starting with a dash) and give it another message (other than not a module name or source file), it has less sense than using existing API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants