Skip to content

setup haddock ignores LANGUAGE CPP pragma #223

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

Closed
bos opened this issue May 24, 2012 · 12 comments
Closed

setup haddock ignores LANGUAGE CPP pragma #223

bos opened this issue May 24, 2012 · 12 comments

Comments

@bos
Copy link
Contributor

bos commented May 24, 2012

(Imported from Trac #230, reported by ross on 2008-02-04)

setup haddock preprocesses sources with cpp if CPP is included in the extensions field, but not if a source file starts with

{-# LANGUAGE CPP #-}
This is confusing, because that works with setup build.
@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by @dcoutts on 2008-02-04)

Of course that's because it is GHC that interprets the {-# LANGUAGE CPP #-} pragma and not Cabal.

Long term I think Cabal should notice LANGUAGE pragmas. It'd allow it to check that all extensions are declared in the .cabal file and it'd allow Cabal to do the cpping itself rather than using ghc's cpp.

I'm assigning it to milestone 2.0 because it should be easy enough if we're already reading .hs files to do module chasing.

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by ross on 2008-02-04)

Distribution.Simple.Hugs.getOptionsFromSource may be useful.

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by @dcoutts on 2008-02-05)

And of course we have the same problem with {-# OPTIONS -fglasgow-exts -cpp #-} which is generated by alex. So even if you didn't realise you use CPP, if you use alex then you do and then haddock fails because we don't run cpp on that file. So if we go looking for LANGUAGE pragmas then we'd also have to do the same for OPTIONS (and OPTIONS_*) pragmas.

Seems that getOptionsFromSource gets those too which is nice. Perhaps we should just do that for every file in builds and when haddocking.

@tibbe
Copy link
Member

tibbe commented Jan 28, 2013

This works for me now so I guess it got fixed at some point.

@tibbe tibbe closed this as completed Jan 28, 2013
@asr
Copy link
Contributor

asr commented Sep 4, 2013

Why is this issue closed? I could reproduce the issue with Cabal-1.18.0 and cabal-install-1.18.0.

@tibbe
Copy link
Member

tibbe commented Sep 4, 2013

Why is this issue closed? I could reproduce the issue with Cabal-1.18.0 and cabal-install-1.18.0.

I said 7 months ago:

This works for me now so I guess it got fixed at some point.

Perhaps it broken again. Do you have simple complete repro example?

@asr
Copy link
Contributor

asr commented Sep 6, 2013

Do you have simple complete repro example?

Yes. See https://github.com/asr/cabal-issue223

If I remove extensions: CPP from issue223.cabal I got (I only could reproduce the issue using the #include directive):

$ cabal haddock --executables
Running Haddock for issue223-0.1...
Preprocessing executable 'issue223' for issue223-0.1...

dist/build/tmp-14523/Main.hs:5:0:
     fatal error: Empty.h: No such file or directory
compilation terminated.

@asr
Copy link
Contributor

asr commented May 3, 2014

I could reproduce the issue with

$ cabal --v
cabal-install version 1.20.0.1
using version 1.20.0.0 of the Cabal library

Could someone reopen the issue please.

@23Skidoo 23Skidoo modified the milestones: cabal-install-1.22, Cabal-2.0 May 3, 2014
@23Skidoo 23Skidoo reopened this May 3, 2014
@jgm
Copy link

jgm commented May 15, 2014

I just ran into this too with jgm/zip-archive.
Interestingly, removing Default-Extensions: CPP from the cabal file fixed the problem.

jgm added a commit to jgm/zip-archive that referenced this issue May 15, 2014
@23Skidoo
Copy link
Member

/me wonders if this has been fixed by #1854.

@asr
Copy link
Contributor

asr commented May 16, 2014

I requested reopen the issue some days ago. The issue is fixed by #1854. Thanks!

@23Skidoo
Copy link
Member

@asr Great. Closing.

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