From cd4fb259c9c8c3714b0867e8968a54d7e6644c88 Mon Sep 17 00:00:00 2001 From: Bartosz Nitka Date: Tue, 11 Oct 2016 16:45:37 -0700 Subject: [PATCH] Dedupe include dirs inherited from dependencies 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. --- Cabal/Distribution/Simple/Configure.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index 656ac110cf2..6ccdce74807 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -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 ]