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

--ghc-options only takes a single option #3315

Closed
mgsloan opened this issue Aug 6, 2017 · 6 comments
Closed

--ghc-options only takes a single option #3315

mgsloan opened this issue Aug 6, 2017 · 6 comments

Comments

@mgsloan
Copy link
Contributor

mgsloan commented Aug 6, 2017

From the comment here #758 (comment) :

$ stack ghci --ghc-options="-ddump-simpl -dsuppress-idinfo"
Configuring GHCi with the following packages:
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
ghc.EXE: unrecognised flag: -ddump-simpl -dsuppress-idinfo

Usage: For basic information, try the `--help' option.

Curiously, the documentation on the argsOption function that handles this mentions --ghc-options, but it isn't currently used:

-- | An option which accepts a list of arguments e.g. @--ghc-options="-X P.hs \"this\""@.
argsOption :: O.Mod O.OptionFields [String] -> O.Parser [String]

Fix is to use this for ghc-options and make sure it's also used for other similar options fields

@decentral1se
Copy link
Member

Done in 9e2bd40.

@mgsloan
Copy link
Contributor Author

mgsloan commented Oct 23, 2017

Re-opening this. Here's what happened:

  • The fix broke another usecase - A way to pass RTS options to the GHC #3353

  • We want to do a release soon.

  • I don't want to try implementing any complex solution this close to release, so I reverted the fix to this.

Note that any future fix to this should also consider the usecase in #3353. It is also worthwhile to take a look at how ghc-options and ghcjs-options work in the stack configuration, and have it be consistent with the CLI in its parsing.

@sclausen
Copy link

@mgsloan I would be glad, if you could tell, what the status of this is.

@mgsloan
Copy link
Contributor Author

mgsloan commented Jan 30, 2018

@sclausen I think the proper steps forward were in the other issue #3353 (comment) . Copying what I said there:

Actually, I think that this was never a problem for configure-options, just an issue when invoking ghci directly with multi-ghc-options. I noticed that the configuration parsing code for stack.yaml uses argument parsing for "ghc-options", when it probably shouldn't. So, steps would be:

  • Use parseArgs for options passed to ghci
  • Remove use of parseArgs for --ghc-options in cli and ghc-options: in config

Also, some stuff to make sure this doesn't regress:

  • Add tests for mutltiword options that both build and invoke ghc ( tswelsh@9832fd9 + more)
  • Add tests for multiword options that include RTS options.

@mgsloan mgsloan added this to the P1: Must milestone Jan 30, 2018
@sclausen
Copy link

sclausen commented Jan 30, 2018

@mgsloan thanks for the quick answer!

@snoyberg
Copy link
Contributor

See #4747

snoyberg added a commit that referenced this issue Apr 16, 2019
cwgoes pushed a commit to anoma/juvix that referenced this issue Feb 12, 2021
When I try to build the optimised compiler, I am greeted with an error from stack:

```
stack build --jobs 4 --ghc-options "-O3 -fllvm" --flag juvix:incomplete-error
Invalid option `-fllvm'

Usage: stack build [TARGET] [--dry-run] [--pedantic] [--fast]
....
```

-fllvm is treated as an option to stack, and not as part of the
--ghc-options flag. This is a known issue commercialhaskell/stack#3315,
that apparently was fixed. I am running a more recent version of stack
(2.5.1), but it still comes up as a problem.

A solution to this is by using multiple --ghc-options flags:

```
stack build --jobs 4 --ghc-options "-O3" --ghc-options "-fllvm" --flag juvix:incomplete-error
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants