[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [erlang-questions] Erlang in Debian on m68k architecture



On Thu, 25 Jan 2007, Mikael Pettersson wrote:
> Sergei Golovan writes:
>  > 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.

The m68k ABI specifies that 32-bit objects must be aligned to a 16-bit address.
I.e. ints and pointers are not guaranteed to be 32-bit aligned.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



Reply to: