cannot build 'vector' with profiling

Reid Barton rwbarton at gmail.com
Thu Jun 11 15:42:35 UTC 2015


On Wed, Jun 10, 2015 at 12:18 AM, Ranjit Jhala <jhala at cs.ucsd.edu> wrote:

> Hi all,
>
> I cannot build 'vector' (or 'cmdargs') with profiling on.
>

The short answer is: Never use --ghc-options="-prof". Cabal knows to use
-prof to build profiling libraries and profiled executables, and will
handle everything correctly automatically. If you remove the "-prof" part
from the --ghc-options in your original command, vector will build with
profiling correctly.

The longer explanation is:

vector uses Template Haskell which can only load the dynamic, unprofiled
version of a library. In order to build vector in any configuration, its
dependencies therefore need to have been built in at least the dynamic &
unprofiled configuration. vector itself must also be built in the dynamic &
unprofiled configuration, in case one module in vector runs a Template
Haskell containing identifiers defined in another module in vector.

Cabal is capable of building both the dynamic & unprofiled and static &
profiled configurations of vector and its dependencies simultaneously by
default. However, if you explicitly add --ghc-options=-prof, then you
defeat Cabal's attempt to build the dynamic & unprofiled configuration.


> specifically when I run:
>
>     $ cabal install --enable-executable-profiling
> --enable-library-profiling --ghc-options="-O2 -rtsopts -prof -auto-all
> -caf-all" vector
>
>
> I get the message:
>
>     Perhaps you haven't installed the "p_dyn" libraries for package
> ‛integer-gmp’
>

Right, by default ghc does not ship with dynamic & profiled libraries, so
this will fail very quickly when Cabal tries to build a dynamic &
unprofiled library, but you told it to also pass -prof to ghc.


> Per some advice I tried to add the '--disable-shared'
>
>
>     $ cabal install --disable-shared --enable-executable-profiling
> --enable-library-profiling --ghc-options="-O2 -rtsopts -prof -auto-all
> -caf-all" vector
>
> but then I get this:
>
>     Loading package primitive-0.6 ... <command line>: can't load .so/.DLL
> for: libHSprimitive-0.6.dylib (dlopen(libHSprimitive-0.6.dylib, 9): image
> not found)
>

This can't work because you need dynamic versions of vector's dependencies
for Template Haskell, but you disabled building them with --disable-shared.

Regards,
Reid Barton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20150611/c345c4b7/attachment.html>


More information about the Glasgow-haskell-users mailing list