You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No recompilation when using addDependentFile or -fforce-recomp in a build dependent package (stanza) #9745
Importing a library that is in the package's build-depends doesn't recompile when it should.
The following are the cases when recompilation should happen in a dependent package but it doesn't happen:
when using addDependentFile and the file changes
when explicitly marking some file using {-# OPTIONS_GHC -fforce-recomp #-}
The only workaround I have is either to do cabal clean and then compile again from scratch....
Or modify one of the library source files.
{-# OPTIONS_GHC -fforce-recomp #-}
module Foo where
....
And the contents of the Spec.hs are the following:
module Spec where
import Foo
...
Now when I run cabal test my-tests for the first time everything necessary normally compiles along with the Foo.hs.
And now when I run cabal test my-tests the second time, I expect the Foo.hs to compile again, but it doesn't compile again even though it uses the -fforce-recomp option.
The similar example would be using the addDependentFile and the dependent file changes, it doesn't compile either.
Expected behavior
When there's {-# OPTIONS_GHC -fforce-recomp #-} used in any of the dependent library source files, it should compile again every single time.
Also, when there's addDependentFile used in the dependent library, it should also recompile when the dependent file changes.
System information
OS: x86-darwin
Cabal and GHC: cabal-install version 3.6.2.0 The Glorious Glasgow Haskell Compilation System, version 8.10.7
As discussed in the related issues, you can use extra-source-files, and this is the recommended way. Have you tried doing so, and are there any problems in doing so?
This also has the advantage that the file in extra-source-files is actually packaged up by sdist properly, which a file added by addDependentFile cannot be.
Further, I think this is the correct semantics for -fforce-recomp. The flag is intended to say "if you are recompiling the package, then you should recompile the so-flagged files" not "always recompile this package"
Further, I think this is the correct semantics for -fforce-recomp. The flag is intended to say "if you are recompiling the package, then you should recompile the so-flagged files" not "always recompile this package"
I see, I'm okay with that then.
As discussed in the related issues, you can use extra-source-files, and this is the recommended way. Have you tried doing so, and are there any problems in doing so?
I haven't yet, but in my use case the dependent file path is based on env variable, so I'm curious whether I can use env variable in the cabal file for the extra-source-files?
I haven't yet, but in my use case the dependent file path is based on env variable, so I'm curious whether I can use env variable in the cabal file for the extra-source-files?
I suppose the answer here is "no", but you could have a generation step for the .cabal file that expands the environment variable.
I am closing this issue now, but feel free to reopen with new information.
Activity
gbaz commentedon Feb 27, 2024
As discussed in the related issues, you can use extra-source-files, and this is the recommended way. Have you tried doing so, and are there any problems in doing so?
This also has the advantage that the file in extra-source-files is actually packaged up by sdist properly, which a file added by
addDependentFilecannot be.Further, I think this is the correct semantics for -fforce-recomp. The flag is intended to say "if you are recompiling the package, then you should recompile the so-flagged files" not "always recompile this package"
KristianBalaj commentedon Feb 27, 2024
I see, I'm okay with that then.
I haven't yet, but in my use case the dependent file path is based on env variable, so I'm curious whether I can use env variable in the cabal file for the
extra-source-files?EDIT: Also thanks for a quick response 🙌
andreasabel commentedon Feb 23, 2025
I suppose the answer here is "no", but you could have a generation step for the
.cabalfile that expands the environment variable.I am closing this issue now, but feel free to reopen with new information.