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

[MiNT] GCC 4.2.2 and binary compatibility



Hello.

Some time ago I posted here an announce about a new port of GCC 4.2 for
the MiNT target, which is available here:
http://vincent.riviere.free.fr/soft/m68k-atari-mint/

Recently some binary compatibility issues were reported on the EmuTOS
mailing list.
http://sourceforge.net/mailarchive/forum.php?thread_name=472EF4F0.5070101%40carroll.de&forum_name=emutos-devel

Because it became out of topic, I continue the discussion here.

The first problem was about functions returning pointers. Traditional
compilers used to return them into d0. GCC for Linux/m68k returns them
into a0. My current binaries behaves like Linux, but it breaks the
compatibility with older Atari functions written in assembly language.
Thus in my next build, I'll disable that a0/d0 stuff and use d0 in all cases, just like older compilers.

The second question is about alignment.

Vincent Rivière wrote:
I would like to speak about another "feature" : alignment.

By default, GCC aligns structure members on 4-byte boundaries, producing useless 2-byte holes in a structure where longs and shorts are mixed. I patched it long ago to use a 2-byte default alignment, so no space is wasted. Some people said that the 68020+ CPU have faster memory access to longs aligned on 32-bit boundaries. Is it true on Atari computers ?

I recently discovered another "feature" of GCC. When function arguments are pushed on the stack, they are aligned on an "int" boundary. When compiling with -mshort, there is no additional filler.
But when -mshort is not used, pushing a short then a long causes the
long to be aligned 2 bytes further. A short filler is inserted between the 2 values. Just like structure alignment, it seems to me that such alignment is useless on the Atari platform. I plan to remove this alignment in my next build.

So what do you think about removing the alignments, for structure members and stack parameters ? Does it break some compatibility ?

Petr Stehlik answered:
yes, it does.

If you want to help the Atari community with your GCC port then
please don't mess with these settings (including the a0/d0 trials)
and make sure that you use the very same settings the gcc 2.95 for
MiNT had.

Feel free to post any further comment.

Regards,

--
Vincent Rivière
vincent.riviere@freesbee.fr