问询cabal build未文档化标志:--package-db是否为--package-conf同义词及-fbuilding-cabal-package含义
Great questions! Let's unpack these two points clearly:
1. Is --package-db a synonym for --package-conf in ghc-pkg?
Yes, your guess is totally correct—these two flags are full synonyms for each other.
The story here is a naming transition in GHC's toolchain: older GHC versions used --package-conf to reference custom package databases, but this was renamed to --package-db in newer releases for better clarity. To avoid breaking existing scripts and workflows, ghc-pkg still accepts both flags, even if the official manual doesn't explicitly note this synonymity. You can verify this by running commands with either flag—they'll produce identical results every time.
2. What does GHC's -fbuilding-cabal-package flag do?
This is an internal, undocumented flag that Cabal automatically passes to GHC during package builds. Its main job is to signal to GHC that the compilation is part of a Cabal-managed process, so GHC can adjust its behavior to play nicely with Cabal's workflow. Some specific effects include:
- Tweaking warning logic: Disables or modifies warnings that aren't relevant when building via Cabal (like those about missing package metadata that Cabal already manages).
- Tailoring output for Cabal integration: Ensures compiled artifacts (such as interface files) include extra metadata that Cabal needs for dependency resolution, installation, and Haddock documentation generation.
- Enabling build-specific optimizations: Helps GHC handle incremental builds and dependency tracking in a way that aligns with how Cabal orchestrates package builds.
Since this is a private contract between Cabal and GHC, it's not listed in GHC's public documentation—end users never need to pass this flag manually; Cabal handles it entirely behind the scenes.
内容的提问来源于stack exchange,提问作者Tom Ellis

