From 34b8afa4b2e21be2e1f91ce2ecdc65ab971547ac Mon Sep 17 00:00:00 2001
From: "Edward Z. Yang" <ezyang@cs.stanford.edu>
Date: Thu, 6 Oct 2016 23:16:33 -0700
Subject: [PATCH] Version test for Backpack support.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
---
 Cabal/Distribution/Simple/Compiler.hs  | 5 +++++
 Cabal/Distribution/Simple/Configure.hs | 9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Cabal/Distribution/Simple/Compiler.hs b/Cabal/Distribution/Simple/Compiler.hs
index 505f9cb1bb..02d0c9f7d7 100644
--- a/Cabal/Distribution/Simple/Compiler.hs
+++ b/Cabal/Distribution/Simple/Compiler.hs
@@ -59,6 +59,7 @@ module Distribution.Simple.Compiler (
         unitIdSupported,
         coverageSupported,
         profilingSupported,
+        backpackSupported,
 
         -- * Support for profiling detail levels
         ProfDetailLevel(..),
@@ -316,6 +317,10 @@ packageKeySupported = ghcSupported "Uses package keys"
 unitIdSupported :: Compiler -> Bool
 unitIdSupported = ghcSupported "Uses unit IDs"
 
+-- | Does this compiler support Backpack?
+backpackSupported :: Compiler -> Bool
+backpackSupported = ghcSupported "Support Backpack"
+
 -- | Does this compiler support Haskell program coverage?
 coverageSupported :: Compiler -> Bool
 coverageSupported comp =
diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs
index 4c6ffb2a97..656ac110cf 100644
--- a/Cabal/Distribution/Simple/Configure.hs
+++ b/Cabal/Distribution/Simple/Configure.hs
@@ -954,13 +954,18 @@ checkCompilerProblems comp pkg_descr enabled = do
                 all (all (isDefaultIncludeRenaming . snd) . backpackIncludes)
                          (enabledBuildInfos pkg_descr enabled)) $
         die $ "Your compiler does not support thinning and renaming on "
-           ++ "package flags.  To use this feature you probably must use "
+           ++ "package flags.  To use this feature you must use "
            ++ "GHC 7.9 or later."
 
     when (any (not.null.PD.reexportedModules) (PD.allLibraries pkg_descr)
           && not (reexportedModulesSupported comp)) $ do
         die $ "Your compiler does not support module re-exports. To use "
-           ++ "this feature you probably must use GHC 7.9 or later."
+           ++ "this feature you must use GHC 7.9 or later."
+
+    when (any (not.null.PD.signatures) (PD.allLibraries pkg_descr)
+          && not (backpackSupported comp)) $ do
+        die $ "Your compiler does not support Backpack. To use "
+           ++ "this feature you must use GHC 8.1 or later."
 
 -- | Select dependencies for the package.
 configureDependencies
-- 
GitLab