Add __GLASGOW_HASKELL_TH__=YES/NO to CPP definitions
authorJoachim Breitner <mail@joachim-breitner.de>
Thu, 30 Oct 2014 04:15:07 +0000 (23:15 -0500)
committerAustin Seipp <austin@well-typed.com>
Thu, 30 Oct 2014 04:15:08 +0000 (23:15 -0500)
Test Plan: None really.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D386

GHC Trac Issues: #9734

compiler/main/DriverPipeline.hs
docs/users_guide/phases.xml

index 6bc67e7..66c6e97 100644 (file)
@@ -2100,6 +2100,11 @@ doCpp dflags raw input_fn output_fn = do
 
     backend_defs <- getBackendDefs dflags
 
+#ifdef GHCI
+    let th_defs = [ "-D__GLASGOW_HASKELL_TH__=YES" ]
+#else
+    let th_defs = [ "-D__GLASGOW_HASKELL_TH__=NO" ]
+#endif
     -- Default CPP defines in Haskell source
     ghcVersionH <- getGhcVersionPathName dflags
     let hsSourceCppOpts =
@@ -2112,6 +2117,7 @@ doCpp dflags raw input_fn output_fn = do
                     ++ map SysTools.Option hsSourceCppOpts
                     ++ map SysTools.Option target_defs
                     ++ map SysTools.Option backend_defs
+                    ++ map SysTools.Option th_defs
                     ++ map SysTools.Option hscpp_opts
                     ++ map SysTools.Option sse_defs
                     ++ map SysTools.Option avx_defs
index 085ebbf..b05de99 100644 (file)
@@ -468,6 +468,21 @@ $ cat foo.hspp</screen>
 
       <varlistentry>
         <term>
+          <constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;TH&lowbar;&lowbar;</constant>
+          <indexterm><primary><constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;TH&lowbar;&lowbar;</constant></primary></indexterm>
+        </term>
+        <listitem>
+          <para>
+          This is set to <literal>YES</literal> when the compiler supports Template Haskell, and to
+          <literal>NO</literal> when not. The latter is the case for a stage-1 compiler during bootstrapping, or
+          on architectures where the interpreter is not available.
+          </para>
+        </listitem>
+      </varlistentry>
+
+
+      <varlistentry>
+        <term>
           <constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;LLVM&lowbar;&lowbar;</constant>
           <indexterm><primary><constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;LLVM&lowbar;&lowbar;</constant></primary></indexterm>
         </term>