Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

HaLVM GHC does not list TemplateHaskell in the supported extensions #107

Open
ntc2 opened this issue Mar 22, 2017 · 0 comments
Open

HaLVM GHC does not list TemplateHaskell in the supported extensions #107

ntc2 opened this issue Mar 22, 2017 · 0 comments
Labels
Milestone

Comments

@ntc2
Copy link
Contributor

ntc2 commented Mar 22, 2017

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.

@acw acw added this to the HaLVM 2.5 milestone Mar 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants