[erlang-questions] Compiling erlang core modules with +native and -smp

Colm Dougan colm.dougan@REDACTED
Tue May 27 18:17:22 CEST 2008


On Tue, May 27, 2008 at 4:24 PM, Mikael Pettersson <mikpe@REDACTED> wrote:
> Colm Dougan writes:
>  > Hi list,
>  >
>  > I had to compile the Debian version of erlang from source (to apply
>  > the zlib patch) and I noticed that there was an optional native.diff
>  > patch which builds the core erlang modules (stdlib, io_lib etc) using
>  > the +native option.  I decided to try this patch as I need all the
>  > performance I can get :)
>  >
>  > Anyway, later when I ran some code with this erlang using the -smp
>  > option to 'erl' I got lots of warnings like this :
>  >
>  > =INFO REPORT==== 27-May-2008::15:31:24 ===
>  > <HiPE (v 3.6.3)> Warning: not loading native code for module io_lib:
>  > it was compiled for an incompatible runtime system; please regenerate
>  > native code for this runtime system
>  >
>  > I guess this is because the +native code is not compatible with -smp
>  > and modules need to be compiled with both +native *and* -smp in order
>  > for the native code to be used.
>
> No, native and SMP are fully compatible. However, native code compiled
> for an SMP runtime is incompatible with a non-SMP runtime, and native
> code compiled for a non-SMP runtime is incompatible with an SMP runtime.
> (And there is little we can do about that incompatibility without
> sacrificing runtime performance on non-SMP, alas.)
>
> You need to take care to use the same SMP-or-not runtime system at
> compile-time as you intend to use at runtime.

I see.  Thanks.  This means that if I want to compile the erlang
standard library with +native then I have to know in advance whether I
will be using -smp on my runtime system.  Right?

I'm wondering if it would make sense to have a compile option that
compiles native code for both SMP and non SMP runtimes into the same
beam such that the relevant native native code can be selected at
runtime?   I don't know if that makes any sense - just wondering.

Thanks,
Colm



More information about the erlang-questions mailing list