Handle CPP properly in Backpack
authorEdward Z. Yang <ezyang@fb.com>
Sat, 25 Nov 2017 02:12:05 +0000 (10:12 +0800)
committerEdward Z. Yang <ezyang@fb.com>
Fri, 1 Dec 2017 00:25:29 +0000 (19:25 -0500)
Summary:
Previously, we attempted to lookup 'hole' packages for
include directories; this obviously is not going to work.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: validate

Reviewers: ekmett, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14525

Differential Revision: https://phabricator.haskell.org/D4234

compiler/main/Packages.hs
testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in1

index c49581b..14407be 100644 (file)
@@ -1892,8 +1892,14 @@ listVisibleModuleNames dflags =
 getPreloadPackagesAnd :: DynFlags -> [PreloadUnitId] -> IO [PackageConfig]
 getPreloadPackagesAnd dflags pkgids0 =
   let
-      pkgids  = pkgids0 ++ map (toInstalledUnitId . moduleUnitId . snd)
-                               (thisUnitIdInsts dflags)
+      pkgids  = pkgids0 ++
+                  -- An indefinite package will have insts to HOLE,
+                  -- which is not a real package. Don't look it up.
+                  -- Fixes #14525
+                  if isIndefinite dflags
+                    then []
+                    else map (toInstalledUnitId . moduleUnitId . snd)
+                             (thisUnitIdInsts dflags)
       state   = pkgState dflags
       pkg_map = pkgIdMap state
       preload = preloadPackages state