Use a stable ordering for the export list in the interface
authorSimon Marlow <marlowsd@gmail.com>
Thu, 16 Jul 2009 12:26:01 +0000 (12:26 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 16 Jul 2009 12:26:01 +0000 (12:26 +0000)
The export list was ordered according to the whim of FastStrings,
which meant that interface fingerprints could change for no good
reason, causing spurious recompilation.

compiler/iface/MkIface.lhs

index c929d96..17a379b 100644 (file)
@@ -923,11 +923,14 @@ mkIfaceAnnotation (Annotation { ann_target = target, ann_value = serialized }) =
 \begin{code}
 mkIfaceExports :: [AvailInfo]
                -> [(Module, [GenAvailInfo OccName])]
-  -- Group by module and sort by occurrence
-  -- This keeps the list in canonical order
+                  -- Group by module and sort by occurrence
 mkIfaceExports exports
   = [ (mod, eltsFM avails)
-    | (mod, avails) <- fmToList groupFM
+    | (mod, avails) <- sortBy (stableModuleCmp `on` fst) (fmToList groupFM)
+                       -- NB. the fmToList is in a random order,
+                       -- because Ord Module is not a predictable
+                       -- ordering.  Hence we perform a final sort
+                       -- using the stable Module ordering.
     ]
   where
        -- Group by the module where the exported entities are defined