GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

C and PASCAL (or any other high-level languages) in here please

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

mikro
Hardware Guru
Hardware Guru
Posts: 2178
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by mikro »

GCC 7.3.0 for the FreeMiNT target has been just released: https://github.com/freemint/m68k-atari- ... 7_3_0-mint

The main difference against GGN's GCC (currently in version 8.2) is that this toolchain provides the more traditional patchset, i.e. producing a.out binaries compatible with TOS executables, doesn't require any special flags or pre-/post-processing. And hey, works natively on the FireBee!

On the other hand it is, well, an a.out target so it doesn't produce so finely tuned link time optimisations.

vido
Atari Super Hero
Atari Super Hero
Posts: 719
Joined: Mon Jan 31, 2011 7:39 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by vido »

This is great!
Thanks Mikro! :)

PeterS
Captain Atari
Captain Atari
Posts: 323
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by PeterS »

Fantastic work.

mikro
Hardware Guru
Hardware Guru
Posts: 2178
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by mikro »

Hold on with celebrations, Thorsten has found a bug in m68020/m5475 versions. Investigating... :-/

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

And just for those who are not reading the mailing list: cross-compilers for gcc 7.3.1 and 8.2 are available since quite some time on http://tho-otto.de/crossmint.php, together with some commonly used packages, for linux, win32 and macOS.

Mikro's versions are native compilers, usable on mint.

vido
Atari Super Hero
Atari Super Hero
Posts: 719
Joined: Mon Jan 31, 2011 7:39 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by vido »

ThorstenOtto wrote:Mikro's versions are native compilers, usable on mint.
Native compilers are what I need/use :)

mikro
Hardware Guru
Hardware Guru
Posts: 2178
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by mikro »

All good, the archives now contain properly configured and built compilers for all three platforms. Same URL as in the first post.

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

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by jfl »

Thanks mikro and anyone else involved. I too use the native GCC, on my FireBee. So this is really welcomed news.

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

It should be noted that you may still run into some problems with newer gcc: the previous toolchain (gcc 4.6.4 in most cases) compiled in c99 mode by default. gcc 7.x uses c11, and gcc 8.x c17. While this might be even required to be able to compile some newer packages, the mintlib currently does not completely support this, so you may encounter some missing functions here and there.

BlankVector
Atari Super Hero
Atari Super Hero
Posts: 513
Joined: Wed Oct 24, 2007 7:52 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by BlankVector »

Great job :)
Subscribe to my Vretrocomputing channel on YouTube and Facebook. Latest video: Replace Atari STE ROMs with EEPROMs.

User avatar
LaurentS
Captain Atari
Captain Atari
Posts: 287
Joined: Mon Jan 05, 2009 5:41 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by LaurentS »

Hi,

I've given a try to the gcc8.2.1 under linux with Otto's pre compiled programs and it works well. That's a great job.

I've got a question : I've compiled a quick hello word program (source and compile command below), and the result is 103849 bytes.
Is there a way to get lighter exe ?
I would expect a less than 4 kb exe in this case.

Regards
Laurent

The source ;)

#include <stdio.h>

int main(int argc, char* argv[])
{
puts("Hello, world !");

return 0;
}


The compile command : m68k-atari-mint-gcc hello.c -o hello.tos -O2 -m68030 -s

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

LaurentS wrote:Hi,
I've given a try to the gcc8.2.1 under linux with Otto's pre compiled programs and it works well. That's a great job.
Thanks ;)
I've got a question : I've compiled a quick hello word program (source and compile command below), and the result is 103849 bytes.
Yes, thats the drawback of having a (mostly) posix compliant c-library. Other system don't care about that, because the library is mostly shared nowadays.
Is there a way to get lighter exe ?
That depends on the program. For simple ones, you can use Markus' libcmini, but of course that lacks a lot of functions available in mintlib. Also, file I/O using stdio streams is rather slow there, because it is always unbuffered.

User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2126
Joined: Sun Jul 31, 2011 1:11 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by Eero Tamminen »

One gets minimal HelloWorld binary also "with MiNTlib", by:
* using TOS calls instead of C file stream functions like puts()
* telling GCC not to link full startup code (as no argument parsing is needed)

(Full startup code may also depend on printf/file stream functions for error reporting i.e. everything they indirectly bring in.)

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

Eero Tamminen wrote:One gets minimal HelloWorld binary also "with MiNTlib", by:
* telling GCC not to link full startup code (as no argument parsing is needed)
That *might* work, but then you have to write your own startup code. And even simple programs (beside hello world) usually need argument parsing, at least for a supplied filename as argument. And of course you must make sure that you don't accidently access stdin/stdout/stderr somehow, since they are not properly initialized.

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 436
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by Orion_ »

ThorstenOtto wrote:And just for those who are not reading the mailing list: cross-compilers for gcc 7.3.1 and 8.2 are available since quite some time on http://tho-otto.de/crossmint.php, together with some commonly used packages, for linux, win32 and macOS.
For years I've been using VBCC due to its ability to compile "devpac syntax" assembler source, and to specify function parameters into specific register.
Example: void SetFullPalette(__reg("d0") int palette, __reg("a0") void *data);
Unfortunately, looking at the code produced by VBCC, it's quite inefficient, even for trivial stuff, for example:
unsigned short somevar;
unsigned short othervar;
somevar = othervar + 3;

I get something like:
moveq #0,d0
move.w othervar,d0
addq.l #3,d0
move.w d0,somevar

So I hope GCC 8.2 can do better, but I have lots of code written in assembly, and I just can't understand how I can bind it to GCC by specifying function parameters into specific register.
I tried to use "regparm" like this:
void __attribute__((regparm(2))) SetFullPalette(int palette, void *data);

But I get " warning: 'regparm' attribute directive ignored [-Wattributes]"
does anyone knows if this is possible with GCC or do I need to stick with VBCC ?
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 843
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by mfro »

LaurentS wrote:Hi,

I've given a try to the gcc8.2.1 under linux with Otto's pre compiled programs and it works well. That's a great job.

I've got a question : I've compiled a quick hello word program (source and compile command below), and the result is 103849 bytes.
Is there a way to get lighter exe ?
I would expect a less than 4 kb exe in this case.

Regards
Laurent

The source ;)

#include <stdio.h>

int main(int argc, char* argv[])
{
puts("Hello, world !");

return 0;
}


The compile command : m68k-atari-mint-gcc hello.c -o hello.tos -O2 -m68030 -s
https://github.com/mfro0/libcmini

But 4k is unrealistic with a full fledged printf(). About 4k is possible (with libcmini), but you need to replace the printf() call with Cconws().
You can even squeeze a little more out with a 'fastcall' compiler (but this requires a rebuild of all libs).

User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2126
Joined: Sun Jul 31, 2011 1:11 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by Eero Tamminen »

Orion_ wrote:So I hope GCC 8.2 can do better, but I have lots of code written in assembly, and I just can't understand how I can bind it to GCC by specifying function parameters into specific register.
I think you should still be able to use VASM as standalone assembler and link object files it produces with GCC programs.

DML's game / demo engine library should be "full" of both of these kind of things:
* http://www.atari-forum.com/viewtopic.php?f=16&t=31558
* https://bitbucket.org/d_m_l/agtools/src

(On quick check it had both independent VASM files, and inline GCC assembly inside C/C++ files.)

mikro
Hardware Guru
Hardware Guru
Posts: 2178
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by mikro »

Orion_ wrote:So I hope GCC 8.2 can do better, but I have lots of code written in assembly, and I just can't understand how I can bind it to GCC by specifying function parameters into specific register.
I tried to use "regparm" like this:
void __attribute__((regparm(2))) SetFullPalette(int palette, void *data);

But I get " warning: 'regparm' attribute directive ignored [-Wattributes]"
does anyone knows if this is possible with GCC or do I need to stick with VBCC ?
If you desperately want to use those regparms, take a look at Peylow's gcc fork: https://github.com/PeyloW/gcc-4.6.4 -- it supports both 'fastcall' and 'regparm' parameters.

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

mikro wrote: If you desperately want to use those regparms, take a look at Peylow's gcc fork: https://github.com/PeyloW/gcc-4.6.4 -- it supports both 'fastcall' and 'regparm' parameters.
It's also available in the gcc-4.6.4 version on my site. But only for this compiler, not for 7.3 or 8.2. And as already mentioned, you will need libraries that are also compiled with --fastcall. mintlib does not work, but libcmini should support it.

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 436
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by Orion_ »

ThorstenOtto wrote: It's also available in the gcc-4.6.4 version on my site. But only for this compiler, not for 7.3 or 8.2. And as already mentioned, you will need libraries that are also compiled with --fastcall. mintlib does not work, but libcmini should support it.
Seems like it's not working with 4.6.4:
m68k-atari-mint-gcc-4.6.4.exe -fomit-frame-pointer -c -S -O2 main.c
main.c:27:1: warning: 'fastcall' attribute directive ignored [-Wattributes]

I don't use any standard library, I made my own, and I'm compiling for the Sega Megadrive.
I would really like to use gcc 8 because, I compared the generated code of gcc 4 and gcc 8 for the same portion of C code, and gcc 8 is better.
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

Orion_ wrote: main.c:27:1: warning: 'fastcall' attribute directive ignored [-Wattributes]
You should better use it as a compile switch (-mfastcall). Although attributes should work too, that is highly experimental, since the original branch from Peylow did not support that. There might be still some problems with mixing fastcall/cdecl function in the same source.
I don't use any standard library, I made my own
Then you just have to compile it using that switch, and place it in the correct directory (/usr/lib/mfastcall for 32bit, /usr/lib/mshort/mfastcall for 16bit etc, prepending /usr/m68k-atari-mint/sys-root for the cross-compiler). Just make sure you also pass -mfastcall when link so the correct ones are linked. Of course, if there are assembler files in your library, you will have to adjust them according to new parameter passing.
and gcc 8 is better.
In most cases, yes. But things have changed a lot since gcc 4.6.4, so the needed changes for -mfastcall support can't be easily ported. If you feel like it, everything is available also as a git repository at https://github.com/th-otto/m68k-atari-mint-gcc

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 436
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by Orion_ »

ThorstenOtto wrote: You should better use it as a compile switch (-mfastcall).
m68k-atari-mint-gcc-4.6.4.exe -mcpu=68000 -mfastcall -fomit-frame-pointer -S -O2 -c main.c
cc1.exe: error: unrecognized command line option '-mfastcall'
ThorstenOtto wrote:In most cases, yes. But things have changed a lot since gcc 4.6.4, so the needed changes for -mfastcall support can't be easily ported. If you feel like it, everything is available also as a git repository at https://github.com/th-otto/m68k-atari-mint-gcc
Well, I never succeeded at compiling GCC under Windows, so I doubt I can make anything from these sources :/
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

Orion_ wrote:
ThorstenOtto wrote: cc1.exe: error: unrecognized command line option '-mfastcall'
Are you sure you use the correct version? ;) The one from Vincent does not have that support. Otherwise i have to check it, maybe i forgot to update the windows archive, but the linux version should work.
ThorstenOtto wrote:Well, I never succeeded at compiling GCC under Windows, so I doubt I can make anything from these sources :/
You could take a look at that script that i use. Its the same for linux, macos, and windows, with only a few differences, so it was not really that difficult. Its much more difficult though to build a native compiler, e.g. compile gcc by itself on windows, because of that damn mismatch between msys and windows path names.

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 436
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by Orion_ »

ThorstenOtto wrote:
Orion_ wrote: cc1.exe: error: unrecognized command line option '-mfastcall'
Are you sure you use the correct version? ;) The one from Vincent does not have that support. Otherwise i have to check it, maybe i forgot to update the windows archive, but the linux version should work.
I use the MinGW32 4.6.4 version from your website
I also tried the m68k-ataribrowner-elf-gcc-7.1.0, but I get the same error
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

ThorstenOtto
Atari God
Atari God
Posts: 1103
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Post by ThorstenOtto »

I use the MinGW32 4.6.4 version from your website
Ok, i'll take a look. But may take a few days.
I also tried the m68k-ataribrowner-elf-gcc-7.1.0, but I get the same error
That's a complete different port, and does not have Peylows patches applied. Its only advantage is that it supports link-time-optimization because it generates elf format, at the cost of having to convert the output in a separate step to a gemdos program. Also it does not have *any* libraries available. You can achieve the same effect by using my m68k-atari-mintelf toolchain, without the drawbacks.

Post Reply

Return to “C / PASCAL etc.”