Commit d4f8ccee authored by Simon Marlow's avatar Simon Marlow

documentation for TH w/ profiling

parent 6f5d7744
......@@ -4236,7 +4236,46 @@ Hello
<title>Using Template Haskell with Profiling</title>
<indexterm><primary>profiling</primary><secondary>with Template Haskell</secondary></indexterm>
<para>Template Haskell relies on GHC's built-in bytecode compiler and
interpreter to run the splice expressions. The bytecode interpreter
runs the compiled expression on top of the same runtime on which GHC
itself is running; this means that the compiled code referred to by
the interpreted expression must be compatible with this runtime, and
in particular this means that object code that is compiled for
profiling <emphasis>cannot</emphasis> be loaded and used by a splice
expression, because profiled object code is only compatible with the
profiling version of the runtime.</para>
<para>This causes difficulties if you have a multi-module program
containing Template Haskell code and you need to compile it for
profiling, because GHC cannot load the profiled object code and use it
when executing the splices. Fortunately GHC provides a workaround.
The basic idea is to compile the program twice:</para>
<para>Compile the program or library first the normal way, without
<para>Then compile it again with <option>-prof</option>, and
additionally use <option>-osuf
to name the object files differentliy (you can choose any suffix
that isn't the normal object suffix here). GHC will automatically
load the object files built in the first step when executing splice
expressions. If you omit the <option>-osuf</option> flag when
building with <option>-prof</option> and Template Haskell is used,
GHC will emit an error message. </para>
<!-- ===================== Arrow notation =================== -->
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment