Statically linking a small piece of C into every GHC generated binary

Johan Tibell johan.tibell at gmail.com
Tue Jul 19 18:45:18 CEST 2011


On Tue, Jul 19, 2011 at 6:02 PM, Johan Tibell <johan.tibell at gmail.com> wrote:
> I've implemented the primop but run into some difficulty: to use the
> above fallback I need the code to be statically linked into every
> binary. I'm not quite sure how to achieve that.

If dynamic linking doesn't hurt performance (too much). Could I stick
this piece of C code in ghc-prim? Are we guaranteed to always link
against ghc-prim?

> GCC manages by having
> the above function definition in libc, which is always statically
> linked.

I just realized that this isn't true. I wonder if GCC's
__builtin_popcount suffers a performance degradation when libc is
dynamically linked.

> I think LLVM uses a small statically linked compiler run-time
> library for the same purpose.

However I believe this is the case still. I'll need to doublecheck.

Johan



More information about the Glasgow-haskell-users mailing list