[erlang-questions] Erlang in Debian on m68k architecture

Mikael Pettersson <>
Thu Jan 25 12:48:50 CET 2007

Sergei Golovan writes:
 > Hi!
 > As one can see, erlang Debian package (R11B-2 relese, 11.b.2 in Debian
 > versioning) fails to build on m68k now
 > (http://buildd.debian.org/fetch.cgi?&pkg=erlang&ver=1%3A11.b.2-4&arch=m68k&stamp=1167824208&file=log).
 > After some research, we've found that erlang relies on the alignment
 > of some global variable. The following patch fixes it:
 > ------------------------------------------------------------------
 > --- erlang-11.b.2.orig/erts/emulator/beam/binary.c
 > +++ erlang-11.b.2/erts/emulator/beam/binary.c
 > @@ -31,7 +31,7 @@
 >  #include "erl_bits.h"
 >  Uint erts_allocated_binaries;
 > -erts_mtx_t erts_bin_alloc_mtx;
 > +erts_mtx_t erts_bin_alloc_mtx __attribute__ ((aligned (4)));
 >  void
 >  erts_init_binary(void)
 > ------------------------------------------------------------------
 > So, the question is the following: Are global variables supposed to be
 > always aligned? Is this a bug in GCC that it doesn't align the
 > variable?

Definitely smells like a toolchain bug to me. In this case, since you've
enabled threads, erts_mtx_t is a properly declared struct type containing
among other things a pthread_mutex_t, an int, and a couple of pointers.
I don't remember how strict M68K is about alignment, but presumably it wants
non-arbitrary alignment for word-sized fields, especially perhaps if they're
used for atomic accesses.

The error could be in gcc, gas, ld, or even libc.

As GDB session on the core dump should tell us more about the location
of the crash, the failing instruction, and what data it tried to access.


More information about the erlang-questions mailing list