From 0bae3176a68730487edeb59d935ec1ed06822ac1 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Tue, 18 Oct 2016 00:31:48 +0200 Subject: [PATCH] Workaround GHC #11214 by filtering JavaScriptFFI Unfortunately, "native" GHC advertises support for `JavaScriptFFI` even though it doesn't support it. See also https://ghc.haskell.org/ticket/11214 for respective bug. However, in order to properly declare that packages require `JavaScriptFFI` support via `other-extensions` we need to fixup the list of extensions fed to the cabal solver. This patch does something similiar to the workaround we added some time ago to filter out TemplateHaskell for older GHCs which didn't properly advertise `TemplateHaskell` availability (c.f. 9f68eb4455808ea9dd9adc5a59b5ebee52a02de8) (cherry picked from commit 608517be9ce3c232e096530491ecc02a7853cacb) --- Cabal/Distribution/Simple/GHC.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 5e2a1310f62..56a33101d4e 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -144,16 +144,21 @@ configure verbosity hcPath hcPkgPath conf0 = do ghcInfo <- Internal.getGhcInfo verbosity implInfo ghcProg let ghcInfoMap = M.fromList ghcInfo + extensions = -- workaround https://ghc.haskell.org/ticket/11214 + filterExt JavaScriptFFI $ + -- see 'filterExtTH' comment below + filterExtTH $ extensions0 -- starting with GHC 8.0, `TemplateHaskell` will be omitted from -- `--supported-extensions` when it's not available. -- for older GHCs we can use the "Have interpreter" property to -- filter out `TemplateHaskell` - extensions | ghcVersion < Version [8] [] - , Just "NO" <- M.lookup "Have interpreter" ghcInfoMap - = filter ((/= EnableExtension TemplateHaskell) . fst) - extensions0 - | otherwise = extensions0 + filterExtTH | ghcVersion < Version [8] [] + , Just "NO" <- M.lookup "Have interpreter" ghcInfoMap + = filterExt TemplateHaskell + | otherwise = id + + filterExt ext = filter ((/= EnableExtension ext) . fst) let comp = Compiler { compilerId = CompilerId GHC ghcVersion,