[Template-haskell] Profiling with Template Haskell

Simon Marlow simonmar@microsoft.com
Wed, 3 Sep 2003 10:21:17 +0100

> | > Then, all you need do is
> | > 	compile C-code without -prof
> | > 	compile R-code with -prof
> |=20
> | But we only have one kind of "import", which imports a=20
> module both at
> compile-time and run-time.
> | You'd be forced to link in the C-code modules in the final program,
> and I'm pretty sure something will
> | go wrong even if the program doesn't end up referring to=20
> anything from
> those modules.
> Ah... you mean the module initialisation tree will still kick=20
> in.  Hmm.
> But if a module is pure C-code, the mod-init code will still work even
> if it's compiled without -prof, wont' it?  Admittedly, the c-module
> would then a (redundant) part of the runtime executable=20

I realised you'll get a link failure, because the init function contains
the build tag, so it's impossible to link non-prof code with prof code
(this is a safety feature :-).

So, you still need to compile any module which contains compile-time
code as both prof and non-prof.  The latter will be used at compile time
only.  There might be some confusion over interface files: GHC will read
the profiled interface, so it better be consistent with the non-prof
interface, which describes the code we're going to load and run at
compile time.

One way which is guaranteed to work is to put the compile-time code into
a package.