Skip to content

Commit

Permalink
Workaround GHC #11214 by filtering JavaScriptFFI
Browse files Browse the repository at this point in the history
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. 9f68eb4)
  • Loading branch information
hvr committed Oct 17, 2016
1 parent 4fbfda3 commit 608517b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,21 @@ configure verbosity hcPath hcPkgPath conf0 = do

ghcInfo <- Internal.getGhcInfo verbosity implInfo ghcProg
let ghcInfoMap = Map.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 < mkVersion [8]
, Just "NO" <- Map.lookup "Have interpreter" ghcInfoMap
= filter ((/= EnableExtension TemplateHaskell) . fst)
extensions0
| otherwise = extensions0
filterExtTH | ghcVersion < mkVersion [8]
, Just "NO" <- Map.lookup "Have interpreter" ghcInfoMap
= filterExt TemplateHaskell
| otherwise = id

filterExt ext = filter ((/= EnableExtension ext) . fst)

let comp = Compiler {
compilerId = CompilerId GHC ghcVersion,
Expand Down

0 comments on commit 608517b

Please sign in to comment.