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

'stack ghc' doesn't run C preprocessor? #1869

Closed
mitchellwrosen opened this issue Mar 2, 2016 · 2 comments
Closed

'stack ghc' doesn't run C preprocessor? #1869

mitchellwrosen opened this issue Mar 2, 2016 · 2 comments
Milestone

Comments

@mitchellwrosen
Copy link
Contributor

Sorry, hit submit on accident... filling out details now

@mitchellwrosen
Copy link
Contributor Author

I was trying to verify a bug in the latest mwc-random:

> stack unpack mwc-random-0.13.4.0
> cd mwc-random-0.13.4.0

Give it a stack.yaml...

> cat <<EOF >stack.yaml
resolver: lts-5.5
EOF

Make a file to compile...

> cat <<EOF >foo.hs
import System.Random.MWC
main = pure ()
EOF

Compile it

> stack ghc foo.hs

System/Random/MWC.hs:103:0:
     error: missing binary operator before token "("
     #if MIN_VERSION_primitive(0,6,0)
     ^

System/Random/MWC.hs:115:0:
     error: missing binary operator before token "("
     #if !MIN_VERSION_base(4,8,0)
     ^

System/Random/MWC.hs:482:0:
     error: missing binary operator before token "("
     #if MIN_VERSION_primitive(0,6,0)

It seems to work fine with mwc-random-0.13.4.0 in the snapshot database, rather than the local database.

This is stack ver 1.0.4

@mgsloan mgsloan added this to the Support milestone Mar 3, 2016
@mgsloan
Copy link
Contributor

mgsloan commented Mar 3, 2016

stack ghc is pretty much just an alias for stack exec ghc, with a bit of extra smarts to handle the --package flag. In other words, it does not use any cabal information at all, but will use the right GHC and package databases.

There's a PR in limbo state that tries adding something like this, see the discussion here - #1737 .

Anyway, the main problem is probably that your "foo.hs" is at the root dir of mwc-random and uses modules from it, and it lacks a src dir. This means that ghc will find these modules and try to compile them. Instead, put foo.hs in a subfolder. Then, you can do stack ghc foo.hs --package mwc-random (the --package part is only necessary if you don't want to first do a stack build)

@mgsloan mgsloan closed this as completed Mar 3, 2016
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