-
Notifications
You must be signed in to change notification settings - Fork 691
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
ghc-options appears to remove duplicates #4449
Comments
Looks like |
@DanielG thanks for investigating! This looks quite nasty... I'm surprised it didn't cause more problems already... |
Can this be worked around with |
@23Skidoo I think that works... but unfortunately it doesn't help with already released Do we actually agree that this a bug that needs fixing? :-) |
Well, |
@23Skidoo well, while I appreciate the reasoning behind why it was added (i.e. #2110), I don't think it's the right/principled thing to blindly de-duplicate flags w/o understanding their semantic/grammar/syntax (in the future, some flags may actually become ordering-sensitive (or just think of So I think we should at best de-duplicate flags whose structure we are very confident to understand (e.g. I think we could safely whitelist |
@hvr Maybe instead of reverting that patch we can just treat flags followed by positional arguments (e.g.
+1. |
That sounds like a good heuristic that would definitely help with the specific issue that gave rise to #4449 (so it would definitely be an improvement over the current situation). However, it doesn't help with CLI flags that have cumulative effect, or that don't follow |
I read the old ticket. The nub listification was done for a specific reason, but that reason ONLY applies to ghcOptExtensionMap, and NOT the other fields (which were also nubified.) There is no reason to nub ghcOptions, and we should look over the other fields and make sure they haven't been inappropriately nubbed. |
We still enable deduplication for some options, e.g. list of modules or list of paths to search for includes/libraries. Fixes haskell#4449.
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: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]
toNubListR String
, we change the behavior ofmappend
(which is how we combine flags together) from non-deduplicating to deduplicating.Which fields should we revert? At a minimum,
ghcOptExtra
andghcOptExtraDefault
, 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 upBy 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:The text was updated successfully, but these errors were encountered: