setup haddock ignores LANGUAGE CPP pragma #223

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

Comments

Projects
None yet
5 participants
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.
Contributor

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.

Contributor

bos commented May 24, 2012

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

Distribution.Simple.Hugs.getOptionsFromSource may be useful.

Contributor

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.

Owner

tibbe commented Jan 28, 2013

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

@tibbe tibbe closed this Jan 28, 2013

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.

Owner

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?

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.
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 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

Member

23Skidoo commented May 16, 2014

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

Contributor

asr commented May 16, 2014

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

Member

23Skidoo commented May 17, 2014

@asr Great. Closing.

@23Skidoo 23Skidoo closed this May 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment