Using gcc, basic questions

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

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

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Using gcc, basic questions

Postby JeanMars » Mon Jan 28, 2019 10:10 am

Hi,

just starting using gcc, I have a couple of basics questions:
- I installed gcc 7.3.0 for native atari under Aranym, latest gcc is 8.2.3 for cross compiler, any chance 8.2.3 is available for native?
- I installed gcc-7.3.0-m68020-60mint.tar.bz2 as running in Aranym on a 68060, looks like generated code is 680x0 (not pure 68000). Is there something to do to generate pure e68000 code or do I have to install gcc-7.3.0-m68000mint.tar.bz2 ?

Thanks,
Jean
Last edited by JeanMars on Mon Jan 28, 2019 3:59 pm, edited 1 time in total.

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Re: Using gcc, basic questions

Postby JeanMars » Mon Jan 28, 2019 11:39 am

Looks like I found response for #2:
http://tho-otto.de/crossmint.php
m68k-atari-mint-gcc is the C compiler.
m68k-atari-mint-g++ is the C++ compiler.
They just work. I only tested the C and C++ languages, but other languages may work, too.
If you want to generate DRI symbols in the final executable, append the option -Wl,--traditional-format to inform the linker.
I configured this version to generate 68000 code by default, and I enabled multilib. By default, sizeof(int) == 4, but if you compile with -mshort then sizeof(int) == 2 (unsupported by the current MiNTLib). Every object file and every library must be compiled with the same option! You can also generate code for the 68020 and higher and for the FPU by using the -m68020-60 option. And you can generate code for ColdFire V4e processors by using the -mcpu=5475 option.
Last edited by JeanMars on Mon Jan 28, 2019 4:00 pm, edited 1 time in total.

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 826
Joined: Sun Aug 03, 2014 5:54 pm

Re: Using gcc, basic questions

Postby ThorstenOtto » Mon Jan 28, 2019 1:18 pm

Yes, there is a difference between the native compilers, and the cross-compilers. The native compilers generate code by default for the machine they are running on, that is the *-m68020-60mint.tar.bz2 will have a compiler that generates 68020 code by default. You can override this by explicitly specifying -m68000. The cross-compilers all generate plain 68000 code by default, since they don't know which target might be the default.

Edit: when using the 68020 compiler on aranym, be sure to install the libraries in the correct place. Since it is generating 68020 code, the default libraries in /usr/lib should also be 68020 libraries, and the 68000 are looked up in /usr/lib/m68000.

PS.: im not quite happy with this different layout, but Miro decided to do it that way ;)

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Re: Using gcc, basic questions

Postby JeanMars » Mon Jan 28, 2019 4:02 pm

Thanks for the valuable info; any 8.2.3 for native? Probably a question to Miro.

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Re: Using gcc, basic questions

Postby JeanMars » Mon Jan 28, 2019 9:28 pm

Hum...
something is wrong on my side; I still have the same error under Hatari when generating 68000 (see image).
However, generated binaries are slightly different:
sha256g.ttp: 162820 bytes
sha256g030.ttp: 163077 bytes
makefiles are attached.
What I did:
make clean
make --> generates sha256g.ttp
make clean
make -d makefile.030 -->generates sha256g030.ttp

Any idea?
You do not have the required permissions to view the files attached to this post.

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

Re: Using gcc, basic questions

Postby mikro » Tue Jan 29, 2019 7:40 am

JeanMars wrote:- I installed gcc-7.3.0-m68020-60mint.tar.bz2 as running in Aranym on a 68060, looks like generated code is 680x0 (not pure 68000)

Yes, this is expected, even the man pages hint about that:
-m68020
-mc68020
Generate output for a 68020. This is the default when the compiler is configured for 68020-based systems. It is equivalent to -march=68020.

As Thorsten pointed about, -m68000 (for both compilation and linking!) should do the trick for plain 68000 output however be aware that you must place your libraries (mintlib specifically) into /usr/lib/m68000 else you risk messing 68000 and 68020 libraries together (in theory, /usr/lib is always default so if you setup your tree in that way that /usr/lib contains 68000 libraries only, it will work but I don't recommend it).

In theory it should be quite easy to take Thorsten's sources and make a native build out of it but this always requires some testing (I bit myself hard last time) for which I don't have time now. :-(

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

Re: Using gcc, basic questions

Postby mikro » Tue Jan 29, 2019 8:05 am

JeanMars wrote:something is wrong on my side; I still have the same error under Hatari when generating 68000 (see image).

You are missing $(CFLAGS) in

Code: Select all

$(CC) -o $@ $^

(as this is not an automatic make rule).

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Re: Using gcc, basic questions

Postby JeanMars » Tue Jan 29, 2019 12:56 pm

Yes,
I saw that after posting, will retest this evening.
Thanks for catching it :-)

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Re: Using gcc, basic questions

Postby JeanMars » Wed Jan 30, 2019 12:54 pm

OK, much better now.
Miro, is gcc 8.2.3 planned for native release?

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 826
Joined: Sun Aug 03, 2014 5:54 pm

Re: Using gcc, basic questions

Postby ThorstenOtto » Wed Jan 30, 2019 2:07 pm

BTW, where do you get that version 8.2.3 from? The latest release from the 8.x branch ist 8.2.1, see https://github.com/gcc-mirror/gcc/blob/ ... c/BASE-VER

JeanMars
Captain Atari
Captain Atari
Posts: 177
Joined: Fri Apr 09, 2010 5:15 pm
Location: France
Contact:

Re: Using gcc, basic questions

Postby JeanMars » Wed Jan 30, 2019 2:38 pm

Sorry it's 8.2.1... Apologies...

b0br
Retro freak
Retro freak
Posts: 11
Joined: Sat Aug 27, 2016 6:05 pm

Re: Using gcc, basic questions

Postby b0br » Wed Feb 06, 2019 10:00 pm

this is awesome (^_^)

OL
Atari Super Hero
Atari Super Hero
Posts: 519
Joined: Fri Apr 01, 2005 6:59 am
Contact:

Re: Using gcc, basic questions

Postby OL » Sun Apr 07, 2019 10:59 am

Thanks Mikro for your work and explanation,

looks work nice under Aranym, first time I was able to compil a source file without removing optimisation option to not failed! (just a high list of opengl call so probably nothing to optimize but was a mess to compil the full project!). Ok not fast but it work as I not want install cygwin on this computer it's good to have it.

Olivier

mikro wrote:
JeanMars wrote:- I installed gcc-7.3.0-m68020-60mint.tar.bz2 as running in Aranym on a 68060, looks like generated code is 680x0 (not pure 68000)

Yes, this is expected, even the man pages hint about that:
-m68020
-mc68020
Generate output for a 68020. This is the default when the compiler is configured for 68020-based systems. It is equivalent to -march=68020.

As Thorsten pointed about, -m68000 (for both compilation and linking!) should do the trick for plain 68000 output however be aware that you must place your libraries (mintlib specifically) into /usr/lib/m68000 else you risk messing 68000 and 68020 libraries together (in theory, /usr/lib is always default so if you setup your tree in that way that /usr/lib contains 68000 libraries only, it will work but I don't recommend it).

In theory it should be quite easy to take Thorsten's sources and make a native build out of it but this always requires some testing (I bit myself hard last time) for which I don't have time now. :-(
OL

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 826
Joined: Sun Aug 03, 2014 5:54 pm

Re: Using gcc, basic questions

Postby ThorstenOtto » Sun Apr 07, 2019 4:57 pm

mikro wrote:In theory it should be quite easy to take Thorsten's sources and make a native build out of it but this always requires some testing (I bit myself hard last time) for which I don't have time now. :-(


Well it is possible (and i have done it already) but it is very time consuming. Basically, is has to be done in several steps (for bootstrapping at least, the first step may be skipped if you have already a native compiler that is able to compile the current sources).
  • configure a cross-compiler similar to the current one, but this time in such a way that host=target, ie. the resulting compiler should run on the target(Atari), not on the host.
  • install that compiler and any needed libraries on your target machine. This must include a working c-library, and any libraries the compiler needs (usually mpc, mpfr and isl at least; i used the cross-compiled libraries for that purpose)
  • configure the compiler for a native build
  • Compile it and hope for the best, and be sure you don't need your target machine for a *very* long time... that last step took about 22h... on Aranym+JIT, so you can imagine how long it would take on real hardware.

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

Re: Using gcc, basic questions

Postby mikro » Tue Apr 09, 2019 8:22 am

ThorstenOtto wrote:Well it is possible (and i have done it already) but it is very time consuming. Basically, is has to be done in several steps (for bootstrapping at least, the first step may be skipped if you have already a native compiler that is able to compile the current sources).
  • configure a cross-compiler similar to the current one, but this time in such a way that host=target, ie. the resulting compiler should run on the target(Atari), not on the host.

Just for the record, it is possible to stop at this step. :-) This is how I do my native packages, using the Canadian Cross. Of course, making a bootstrapped build is much more rewarding, as you can be sure all target's system properties are guessed properly.


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 6 guests