HaLVM
HaLVM copied to clipboard
HaLVM GHC does not list TemplateHaskell in the supported extensions
Problem
GHC 8 added the new TemplateHaskellQuotes
extension for the subset of TH that a stage 1 GHC supports: https://ghc.haskell.org/trac/ghc/ticket/11102. HaLVM uses a (modified) stage 1 GHC, except it hacks in TH support: https://github.com/GaloisInc/HaLVM/wiki/What-is-the-Difference-Between-GHC-and-the-HaLVM?#the-games-we-play-with-ghc. Those hacks aren't aware of the new treatment of the TemplateHaskell
extension in GHC 8, and so TemplateHaskell
is not listed by halvm-ghc --supported-languages
. Cabal uses <Haskell compiler> --supported-languages
to determine which extensions the Haskell compiler supports, so halvm-ghc
can no longer be used to build Cabal packages that list TemplateHaskell
in the extensions in the .cabal
file.
Easy workaround (that doesn't work :P)
Patch halvm-ghc
to treat --supported-languages
specially:
--- /usr/bin/halvm-ghc.orig 2017-03-22 15:07:42.945173502 -0700
+++ /usr/bin/halvm-ghc 2017-03-22 16:06:35.588340911 -0700
@@ -16,6 +16,18 @@
then echo "2.4.0"; exit;
fi
+# In GHC 8, for stage 1 compilers, the TemplateHaskellQuote extension
+# was added and the TemplateHaskell extension was removed from the
+# list of supported extensions. Cabal uses the list of supported
+# extensions returned by '--supported-extensions' to check that the
+# extensions listed in the .cabal file are supported.
+for arg in "$@"; do
+ if [[ "$arg" == "--supported-extensions" ||
+ "$arg" == "--supported-languages" ]]; then
+ echo TemplateHaskell
+ fi
+done
+
GHCBIN="${bindir}/x86_64-unknown-HaLVM-ghc"
LINKSCRIPTOPT="-pgml ${libdir}/ldkernel -optl -static -rtsopts"
LIBDIROPT="-L${libdir}"
I've tested this hacky fix. UPDATE: it allows halvm-cabal
to succeed, but then halvm-ghc
rejects any files with TemplateHaskell
in a LANGUAGE
pragma.
Proper (?) fix
Reverse the logic added to GHC 8 to not list TemplateHaskell
as supported for stage 1 GHCs: https://git.haskell.org/ghc.git/commitdiff/98a4fa5fb740ce43a1787eb5730e35b463a2de79.