Description
Summary. Cabal incorrectly deduplicates ghc-options
which it passes to GHC.
Steps to reproduce. Create a Cabal package, and put ghc-options: -trust base -trust containers
in it. Attempt to build it and GHC will fail with something like:
target `base' is not a module name or a source file
How to fix. The fix is pretty simple: you will need to disable deduplication of command line arguments in ghc-options. This behavior was introduced in ba4a6d5 so you will need partially undo this patch.
The crux of the matter is the changes to the field types in Cabal/Distribution/Simple/Program/GHC.hs
; by changing a field from [String]
to NubListR String
, we change the behavior of mappend
(which is how we combine flags together) from non-deduplicating to deduplicating.
Which fields should we revert? At a minimum, ghcOptExtra
and ghcOptExtraDefault
, but there may be others. You will need to determine what these fields mean, and see if deduplicating is a good idea or not.
You will need to add a test. Read the README in https://github.com/haskell/cabal/tree/master/cabal-testsuite for guidance. The test for this ticket should be pretty standard; you'll be able to find plenty of similar examples.
What you will learn. You'll learn about how Cabal computes the options it eventually passes to GHC during a build. You'll get familiar with the build environment and writing tests for Cabal.
Old summary. I just ran into a problem where where cabal new-build
messes up
ghc-options: -trust base -trust dependent-sum
By not passing both -trust
tokens to GHC (to be more specific, only the last occurrence of -trust
reaches GHC's CLI, i.e. base -trust dependent-sum
is passed to GHC), which then causes GHC to fail with the following cryptic message:
target `base' is not a module name or a source file