Skip to content

Commit

Permalink
Dedupe include dirs inherited from dependencies
Browse files Browse the repository at this point in the history
If you build a big number of packages, all with
the same extra -I flags, the flags get inherited
by the dependent packages and duplicated.
For big dependency trees it can exceed the
maximum command line length on some systems,
this happened to me with Linux and hoogle 5.

This patch decreases the redundancy by
dropping all but the first occurrence of
an include dir, preserving the semantics,
as they are processed left to right.
  • Loading branch information
Bartosz Nitka committed Oct 12, 2016
1 parent 34eecf4 commit cd4fb25
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1602,9 +1602,14 @@ checkForeignDeps pkg lbi verbosity = do
++ ["-I."]
++ collectField PD.cppOptions
++ collectField PD.ccOptions
++ installedIncludeDirs
++ [ "-I" ++ dir
| dep <- deps
, dir <- Installed.includeDirs dep ]
, dir <- ordNub [ dir
| dep <- deps
, dir <- Installed.includeDirs dep ]
-- dedupe include dirs of dependencies
-- to prevent quadratic blow-up
]
++ [ opt
| dep <- deps
, opt <- Installed.ccOptions dep ]
Expand Down

0 comments on commit cd4fb25

Please sign in to comment.