Best "GCC" compiler for Atari ST?

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
patrick295767
Captain Atari
Captain Atari
Posts: 255
Joined: Sun Aug 13, 2006 2:15 pm
Contact:

Best "GCC" compiler for Atari ST?

Postby patrick295767 » Wed Feb 06, 2013 6:25 am

Hi,

I would like to ask what could be closest gcc compiler for compiling C language with the Atari ST.

Where the libs similar to what we can use with Unix nowadays?

Kind regards
Pat

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Best "GCC" compiler for Atari ST?

Postby dml » Wed Feb 06, 2013 11:46 am

This one...

http://vincent.riviere.free.fr/soft/m68k-atari-mint/

...is both a cross-compiler and native compiler for ST/TT/Falcon etc.

The generated executables will work happily on plain TOS providing you avoid MiNT-specific libraries. I built code for STE without any problems.

[edit]

The project below was built for both Atari & Linux (really Cygwin) using the above tools, so it's probably a fair example of use. (Although it's a C++ project and links to the C++ std lib and some other libs which are quite large - this is easily avoided if you're just working with C or plain C++ without STL etc..).

http://www.leonik.net/dml/files/pcs512_r2.zip

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best "GCC" compiler for Atari ST?

Postby Eero Tamminen » Mon Feb 11, 2013 2:27 pm

patrick295767 wrote:I would like to ask what could be closest gcc compiler for compiling C language with the Atari ST.


New GCC versions use a lot of memory, it's unlikely that there's enough memory on ST to run them. Another problem with GCC is that it needs unix like environment, file system hierarchy etc.

For ST I would recommend AHCC/Pure-C. If you have at least 4MB of RAM, you could use older 2.x version of GCC with MiNT. If you have 14MB of RAM, you could consider newer versions of GCC or VBCC.

VBCC works fine under TOS too:
http://koti.mbnet.fi/tammat/hatari/devel.shtml#vbcc

The problem with VBCC is that its C-library doesn't have ANY MiNT or Unix / POSIX support.

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Best "GCC" compiler for Atari ST?

Postby dml » Mon Feb 11, 2013 2:37 pm

Eero Tamminen wrote:New GCC versions use a lot of memory, it's unlikely that there's enough memory on ST to run them. Another problem with GCC is that it needs unix like environment, file system hierarchy etc.


Yes if you want to do the compilation *on* an ST, then your options are more limited (especially if you happened to want C++, or want to compile a wide range of non-Atari source - I think GCC 2.9.5 was the last native version I used on an Atari...).

However if you want to compile *for* an ST, from your PC or Mac or Linux or whatever, then I still recommend the newer GCC as an option, since it handles nearly anything you'll find in the wild.

User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 817
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby jfl » Mon Feb 11, 2013 2:40 pm

dml wrote:http://vincent.riviere.free.fr/soft/m68k-atari-mint/
...is both a cross-compiler and native compiler for ST/TT/Falcon etc.

Vincent only provides a cross-compiler.
Jean-François
GEMDict – GEMClip

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Best "GCC" compiler for Atari ST?

Postby dml » Mon Feb 11, 2013 2:46 pm

jfl wrote:
dml wrote:http://vincent.riviere.free.fr/soft/m68k-atari-mint/
...is both a cross-compiler and native compiler for ST/TT/Falcon etc.

Vincent only provides a cross-compiler.


Yes my mistake - the native version mentioned is actually a link to Mikro's site where it is supported separately.

http://mikro.naprvyraz.sk/download.htm

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Mon Feb 11, 2013 5:38 pm

For coding ST stuff on an ST, I can only recommend AHCC. It is free, Pure C compatible and more important actively developped. You contact the author Henk Robbers and he will happily help you out and improve his works.

AHCC is a great tool not to be missed on the real deal!

I'd forget about the GCC options mentioned above unless you want to crosscompile. Binaries compiled by the cross toolchain tend to be rather large for ST programs. That view changes for accelerated Falcons and the Firebee where RAM is not an issue but for ST(e) class machines it is!
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

rabindranath72
Captain Atari
Captain Atari
Posts: 244
Joined: Tue Feb 15, 2011 3:59 pm

Re: Best "GCC" compiler for Atari ST?

Postby rabindranath72 » Tue Feb 12, 2013 11:50 am

It may be current, but it's not available from the author's home page :? What is the latest version? Also, does it support floating point?

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Tue Feb 12, 2013 4:52 pm

AHCC supports floating point on machines with 68020 CPU and FPU. Most of teh time you won't need floating point.

The most current version is always available at Henk's website (http://members.chello.nl/h.robbers/) directly. It is 4.14 atm
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Best "GCC" compiler for Atari ST?

Postby dml » Tue Feb 12, 2013 5:35 pm

Has anyone actually compared the code generation of the various 68k compilers to see how they differ? In terms of both performance and size (most compilers let you optimize for one or the other, including AHCC and GCC - and probably VBCC also).

Hard data is always good.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best "GCC" compiler for Atari ST?

Postby Eero Tamminen » Tue Feb 12, 2013 9:52 pm

dml wrote:Has anyone actually compared the code generation of the various 68k compilers to see how they differ? In terms of both performance and size (most compilers let you optimize for one or the other, including AHCC and GCC - and probably VBCC also).


The standard library affect the code size much more than the C-compiler, unless you have huge amount of C-code and don't use much library functions. MiNTlib printf() alone pulls in something like 50kB.

I have some comments on AHCC, VBCC & GCC here:
http://koti.mbnet.fi/tammat/hatari/devel.shtml

Building C++ one can forget on ST, even with oldest GCC version and 4MB of RAM, one would need to split classes a lot into separate files to get them compiled, and probably also use pretty low optimization levels.

If one wants to port Unix stuff, MiNTlib (i.e. GCC) is the only realistic alternative. C-libraries in other compilers are lacking too many POSIX functions.

If 16-bit ints and no floating point without FPU is OK, I would recommend AHCC, it's a bit more mature than VBCC and produces smaller binaries. AHCC does only some peep-hole assembly optimizations, so one gets what one writes. :-)

If one needs floating point and 32-bit ints, but wants smaller binaries than with MiNTlib, I would suggest VBCC, otherwise old version of GCC. VBCC does optimizations, but for higher levels even 14MB of RAM isn't always enough. But I've found that even old GCC 2.x still produces faster code than VBCC...

(VBCC has also some corner case code-generation bugs for 68000 and 680x0 which I've found, that are being fixed by its author.)

joska
Hardware Guru
Hardware Guru
Posts: 3574
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby joska » Tue Feb 12, 2013 9:59 pm

Eero Tamminen wrote:If 16-bit ints and no floating point without FPU is OK, I would recommend AHCC


AHCC has 32 bit ints too. This is a compiler option.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Best "GCC" compiler for Atari ST?

Postby dml » Tue Feb 12, 2013 10:51 pm

Eero Tamminen wrote:The standard library affect the code size much more than the C-compiler, unless you have huge amount of C-code and don't use much library functions. MiNTlib printf() alone pulls in something like 50kB.


Yes I understand this very well. This also applies to C++. It is the code generation I was curious about since I don't know much about VBCC or AHCC. OTOH I know a great deal about GCC and it's variants.

Eero Tamminen wrote:I have some comments on AHCC, VBCC & GCC here:
http://koti.mbnet.fi/tammat/hatari/devel.shtml


I'll take a look.

Eero Tamminen wrote:Building C++ one can forget on ST, even with oldest GCC version and 4MB of RAM, one would need to split classes a lot into separate files to get them compiled, and probably also use pretty low optimization levels.


Yes, this is also true.

Eero Tamminen wrote:If 16-bit ints and no floating point without FPU is OK, I would recommend AHCC, it's a bit more mature than VBCC and produces smaller binaries. AHCC does only some peep-hole assembly optimizations, so one gets what one writes. :-)


I browsed through the AHCC source and I get the general idea. I couldn't find any reference at all to instruction timings even for plain 68k so it looks like a literal mapping to known instructions, and a bunch of hand-chosen peephole triggers on top of that. So yes - you get literally what you write.

Eero Tamminen wrote:VBCC does optimizations, but for higher levels even 14MB of RAM isn't always enough. But I've found that even old GCC 2.x still produces faster code than VBCC...


So if source compatibility, performance and productivity are important, use the cross-compiler. If you need to compile literally on an ST, AHCC is light enough to do the job.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best

Postby Eero Tamminen » Wed Feb 13, 2013 8:16 pm

joska wrote:
Eero Tamminen wrote:If 16-bit ints and no floating point without FPU is OK, I would recommend AHCC


AHCC has 32 bit ints too. This is a compiler option.


Last time I tried it, it wasn't mature enough for use and especially the situation with 16-bit vs. 32-bit headers is a complete mess (Henk doesn't want to touch them, but accepts updates). If you diff headers in include/ and sinclude/ dirs, you notice that they differ a lot, not just in int/short usage.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best "GCC" compiler for Atari ST?

Postby Eero Tamminen » Wed Feb 13, 2013 8:24 pm

dml wrote:
Eero Tamminen wrote:VBCC does optimizations, but for higher levels even 14MB of RAM isn't always enough. But I've found that even old GCC 2.x still produces faster code than VBCC...


So if source compatibility, performance and productivity are important, use the cross-compiler.


E.g. native GCC 2.x RPM packages from Sparemint works pretty well under Aranym when extracted on top of AFROS file system content. In Aranym one can specify enough memory for anything and the setup is close enough to what it would be on Firebee, if one is interest to move there later on.


dml wrote:If you need to compile literally on an ST, AHCC is light enough to do the job.


Unless one needs floating point. Then if one has 4MB of RAM, I would recommend GCC 2.x if one uses MiNT, and VBCC if one uses TOS. And to have a lot of patience. :-)

Or one could get hold of the old proprietary Pure-C from somewhere.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Thu Feb 14, 2013 5:14 pm

The int is 16 or 32bit shouldn't matter. Good C programmers use stdint.h or an equivalent where they pick types with a welldefined size.
For ST code I'd stick with int16_t or uint16_t for most things.

Esp because int is never the same size on various platforms, it is quite a problem for portability. SDL overs welldefined datatypes because of this.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best "GCC" compiler for Atari ST?

Postby Eero Tamminen » Thu Feb 14, 2013 11:21 pm

simonsunnyboy wrote:The int is 16 or 32bit shouldn't matter. Good C programmers use stdint.h or an equivalent where they pick types with a welldefined size.


There's a *lot* of existing code that doesn't care that much about int size, but still assumes them to be at least 32-bits. While I've written even this year code using 16-bit ints, I think for most people they're a relic from the 80's...

simonsunnyboy wrote:Esp because int is never the same size on various platforms, it is quite a problem for portability. SDL overs welldefined datatypes because of this.


I've used SDL a lot, but I doubt you would get a working SDL if you build it with 16-bit ints. :-)

rabindranath72
Captain Atari
Captain Atari
Posts: 244
Joined: Tue Feb 15, 2011 3:59 pm

Re: Best "GCC" compiler for Atari ST?

Postby rabindranath72 » Fri Feb 15, 2013 8:53 am

Yeah I am one of those few who actually needs floating point :) And I mostly work on an STE, so AHCC is not for me, sadly.
Thanks for the link, apparently my browser redirects to an hold page which hosts version 4.6 of AHCC.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best "GCC" compiler for Atari ST?

Postby Eero Tamminen » Fri Feb 15, 2013 3:22 pm

rabindranath72 wrote:Thanks for the link, apparently my browser redirects to an hold page which hosts version 4.6 of AHCC.


I've mailed Henk about that, he apparently restored wrong version of the pages after switching computer.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Fri Feb 15, 2013 4:30 pm

Regarding int, any software having references to int is IMHO bad. Either it should be (un)signed short or long as those are well defined by the C standard.
Anyway AHCC is still terrific to have on the ST :) And maybe someday someone helps Henk with doing the floating point package?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

Ato
Captain Atari
Captain Atari
Posts: 300
Joined: Tue Aug 10, 2010 3:27 am
Location: Duisburg, Germany

Re: Best "GCC" compiler for Atari ST?

Postby Ato » Sun Feb 17, 2013 3:38 pm

simonsunnyboy wrote:Regarding int, any software having references to int is IMHO bad. Either it should be (un)signed short or long as those are well defined by the C standard.


???

My copy of the C99 standard (WG14/N1256, Committee Draft, Septermber 7, 2007, ISO/IEC 9899:TC3) still lists int as valid type:

6.2.5 Types
[...]
There are five standard signed integer types, designated as signed char, short
int, int, long int, and long long int. (These and other types may be
designated in several additional ways, as described in 6.7.2.) There may also be
implementation-defined extended signed integer types.28) The standard and extended
signed integer types are collectively called signed integer types.29)


I cannot see why using a standard integer type is "bad"!?

<rant>
While we are at it:

What really is "bad", as in bad practice, is to use standard types (integer, floating point, any) and to make assumptions on their size based on previous experience "this code has worked for 15 years", a magic eight ball or some other random event. That's why there are the header files limits.h and stdint.h which seem to be rarely used. Obviously, when a developer is making size assumptions on types, the developer should rather use types with a defined size from stdint.h instead of any of the standard types (which you have already mentioned, SSB).

I have reviewed too much faulty code too many times because the developer made implicit assumptions on type sizes.
</rant>

Cheers,
T.

User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 817
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby jfl » Sun Feb 17, 2013 4:22 pm

simonsunnyboy wrote:Regarding int, any software having references to int is IMHO bad. Either it should be (un)signed short or long as those are well defined by the C standard.

I mustn’t be writing good software, then. Ah, well. I didn't think I was anyway.
Jean-François
GEMDict – GEMClip

Hippy Dave
Atari Super Hero
Atari Super Hero
Posts: 515
Joined: Sat Jan 10, 2009 5:40 am

Re: Best "GCC" compiler for Atari ST?

Postby Hippy Dave » Sun Feb 17, 2013 10:11 pm

simonsunnyboy wrote:Regarding int, any software having references to int is IMHO bad. Either it should be (un)signed short or long as those are well defined by the C standard.

I never gave much thought to this until now. (int) is bad! I'm taking your advice. :coffe:
I learned to program in C (way back in '84) without a computer or compiler
by reading "The C Programming Language" six months before I got the 520ST,
and Alcyon C compiler from Atari.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Mon Feb 18, 2013 5:30 pm

Back then, there wasn't much alternatives. But ANSI C has evolved and the C99 standard helps to fill a lot of old holes, and make C a bit more C++ compatible. // comments for example as well as allowing variable declaration within {} blocks below function level.

Sadly AHCC does not implement all of them :(
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

rabindranath72
Captain Atari
Captain Atari
Posts: 244
Joined: Tue Feb 15, 2011 3:59 pm

Re: Best "GCC" compiler for Atari ST?

Postby rabindranath72 » Mon Feb 18, 2013 6:27 pm

The ANSI C standard is quite flexible (and explicit.) Save particular directives, ints are supposed to be signed.
The only restrictions are:
- short and int must be at least 16 bits;
- long must be at least 32 bits;
- short cannot be larger than int; (but they can be equal)
- int cannot be larger than long; (but they can be equal)

So you might effectively have short=int=long.
It's obviously good practice to be explicit about what one means when declaring a variable "int."


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 4 guests