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

Unnecessary recompilation when using the CPP language extension #3562

Closed
asr opened this issue Jul 15, 2016 · 5 comments
Closed

Unnecessary recompilation when using the CPP language extension #3562

asr opened this issue Jul 15, 2016 · 5 comments

Comments

@asr
Copy link
Contributor

asr commented Jul 15, 2016

Using the files below I got the following behaviour:

$ cabal install --enable-tests
...

$ cabal install
...
Preprocessing library Foo-0.1.0.0...
[1 of 1] Compiling Foo              ( Foo.hs, dist/build/Foo.o ) [dist/build/autogen/cabal_macros.h changed]

Cabal correctly changes cabal.macros.h because the dependencies of the library and the test-suite are different.

Why the module Foo.hs is recompiled?

If I comment-out {-# LANGUAGE CPP #-} in Foo.hs, this module isn't recompiled.

Files: Foo.cabal.txt, Foo.hs.txt and Test.hs.txt.

Cabal and GHC versions:

$ caball --version
cabal-install version 1.24.0.0
compiled using version 1.24.0.0 of the Cabal library

$ ghc --numeric-version
8.0.1
@phadej
Copy link
Collaborator

phadej commented Jul 15, 2016

The is no way to check whether symbols from cabal_macros.h aren't used in Foo.hs, most likely if you have {-# LANGUAGE CPP #-}, then you use it.

solution to #3545 will probably fix this as well, as libraries and test-suite cabal_macros.h will be actually different.

@asr
Copy link
Contributor Author

asr commented Jul 15, 2016

Thanks for the reference to #3545.

@ezyang
Copy link
Contributor

ezyang commented Jul 16, 2016

Yes, this is fixed in master.

BTW, there is always an implicit include of cabal_macros.h. Without CPP this can never affect the module, but with it we have to recompile. Arguably GHC should be smarter about not recompiling when preprocessor output is the same, but that is a GHC bug.

@ezyang ezyang closed this as completed Jul 16, 2016
@ezyang
Copy link
Contributor

ezyang commented Jul 16, 2016

PS the real ticket is #1893 and the fixing commit is 90e908b

@asr
Copy link
Contributor Author

asr commented Jul 16, 2016

I couldn't reproduce the problem using the current master (commit 0260415). Thanks!

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

3 participants