From 2b6c376dd8d60f74a432d07c5b2c50f9a0e8a414 Mon Sep 17 00:00:00 2001
From: Gershom Bazerman <gershom@arista.com>
Date: Wed, 28 Sep 2022 22:02:29 -0400
Subject: [PATCH] Revert "ordNub for extra stanzas"

This reverts commit a94b3f54d11dd11a755b880e1b87fae942c16c8c.
---
 Cabal/src/Distribution/Simple/Build.hs | 29 ++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/Cabal/src/Distribution/Simple/Build.hs b/Cabal/src/Distribution/Simple/Build.hs
index ad1161155d..4fe8a48c13 100644
--- a/Cabal/src/Distribution/Simple/Build.hs
+++ b/Cabal/src/Distribution/Simple/Build.hs
@@ -89,6 +89,7 @@ import Distribution.Version (thisVersion)
 import Distribution.Compat.Graph (IsNode(..))
 
 import Control.Monad
+import qualified Data.Set as Set
 import qualified Data.ByteString.Lazy as LBS
 import System.FilePath ( (</>), (<.>), takeDirectory )
 import System.Directory ( getCurrentDirectory, removeFile, doesFileExist )
@@ -433,36 +434,52 @@ generateCode codeGens nm pdesc bi lbi clbi verbosity = do
 -- information.
 addExtraCSources :: BuildInfo -> [FilePath] -> BuildInfo
 addExtraCSources bi extras = bi { cSources = new }
-  where new = ordNub (extras ++ cSources bi)
+  where new = Set.toList $ old `Set.union` exs
+        old = Set.fromList $ cSources bi
+        exs = Set.fromList extras
+
 
 -- | Add extra C++ sources generated by preprocessing to build
 -- information.
 addExtraCxxSources :: BuildInfo -> [FilePath] -> BuildInfo
 addExtraCxxSources bi extras = bi { cxxSources = new }
-  where new = ordNub (extras ++ cxxSources bi)
+  where new = Set.toList $ old `Set.union` exs
+        old = Set.fromList $ cxxSources bi
+        exs = Set.fromList extras
+
 
 -- | Add extra C-- sources generated by preprocessing to build
 -- information.
 addExtraCmmSources :: BuildInfo -> [FilePath] -> BuildInfo
 addExtraCmmSources bi extras = bi { cmmSources = new }
-  where new = ordNub (extras ++ cmmSources bi)
+  where new = Set.toList $ old `Set.union` exs
+        old = Set.fromList $ cmmSources bi
+        exs = Set.fromList extras
+
 
 -- | Add extra ASM sources generated by preprocessing to build
 -- information.
 addExtraAsmSources :: BuildInfo -> [FilePath] -> BuildInfo
 addExtraAsmSources bi extras = bi { asmSources = new }
-  where new = ordNub (extras ++ asmSources bi)
+  where new = Set.toList $ old `Set.union` exs
+        old = Set.fromList $ asmSources bi
+        exs = Set.fromList extras
 
 -- | Add extra HS modules generated by preprocessing to build
 -- information.
 addExtraOtherModules :: BuildInfo -> [ModuleName.ModuleName] -> BuildInfo
 addExtraOtherModules bi extras = bi { otherModules = new }
-  where new = ordNub (extras ++ otherModules bi)
+  where new = Set.toList $ old `Set.union` exs
+        old = Set.fromList $ otherModules bi
+        exs = Set.fromList extras
 
 -- | Add extra source dir for generated modules.
 addSrcDir :: BuildInfo -> FilePath -> BuildInfo
 addSrcDir bi extra = bi { hsSourceDirs = new }
-  where new = ordNub (unsafeMakeSymbolicPath extra : hsSourceDirs bi)
+  where new = Set.toList $ old `Set.union` ex
+        old = Set.fromList $ hsSourceDirs bi
+        ex  = Set.fromList [unsafeMakeSymbolicPath extra] -- TODO
+
 
 replComponent :: ReplOptions
               -> Verbosity
-- 
GitLab