In the normal cabal-install (and the stack workflow built on top of it), the flags specified in your Cabal file are local to your package and should not cause rebuilds. Similarly, the options specified in --ghc-options on the command line are local to your package.
For your specific questions about -threaded this flag does not affect the library code (as cabal-install will indicate), only the executable files.
Below is a short list of GHC flags here . In particular, note that -threaded is specified in Binding , with an additional link to Options that affect the binding . From this information, we conclude that -threaded only makes sense for executable files, since it signals to the GHC that we want to use a streaming runtime. If your package does not provide an executable file, it does not need any runtime, streaming or other.
To explain the high level of compilation and linking: these are two steps between the source code and the executable. Compilation is the process of creating an object file from source code. Linking is the process of attaching the numerous object files that make up your executable file. When you compile an executable file, it does not know that a function, such as map exists if you did not define it, so it simply compiles under the assumption that it does. The binding step is where we make all of these names accessible and meaningful. In the case of -threaded we make the process of binding information about the streaming runtime environment, which all the code that calls at run time, will use.
Since I do not know if you are using the standard cabal , stack cabal , or the new cabal.project , here is a digression to discuss this behavior in the case of cabal.project .
This is actually an open error.
The error is tracked as issue 3883 in Cabal GitHub (and somewhat in issue 4247 related to it).
According to your question, according to the current behavior, specifying the flags in the ghc-options stanza in the cabal.project file forces these dependencies to compile (or recompile, depending on the case) with these flags.
Jack henahan
source share