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

Mikael Pettersson mikpe@REDACTED
Tue May 27 22:15:40 CEST 2008


Colm Dougan writes:
 > 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?

Yes.
It will fall back to the BEAM code if there's a load-time mismatch,
so things should still "work", but the load-time warnings and loss
of performance won't be nice.

 > 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.

That would require support for "fat" binaries. We don't yet have that.

/Mikael



More information about the erlang-questions mailing list