English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. C/C++ (http://eab.abime.net/forumdisplay.php?f=118)
-   -   GCC 6.2 toolchain for AmigaOS 3 (http://eab.abime.net/showthread.php?t=85474)

Samurai_Crow 08 January 2017 17:16

GCC 6.2 toolchain for AmigaOS 3
 
https://github.com/bebbo has ported cross-compiler toolchains for Windows, Linux and Mac OS. I have not tried them yet but it's a very recent version of GCC.

Marlon_ 08 January 2017 18:52

Nice! Finally a more recent version of GCC. I'll give it a go! :)

plasmab 08 January 2017 19:00

Excellent work :)

I tend to use vbcc thesedays but this is good.

nogginthenog 08 January 2017 19:40

I tried to build this last week. Run into a couple of problems I couldn't solve.
I made some notes, which I was intending to post after I got everything working:

1. The page has:
# git clone git://github.com/cahirwpz/amigaos-cross-toolchain.git
But this should be:
# git clone git://github.com/bebbo/amigaos-cross-toolchain.git
otherwise you will build gcc 2.95 like me :-)

2. You are going to need 32bit gcc and libs (anyone know why?). Didn't keep all my notes but I needed at least these:
sudo apt-get install libgmp-dev:i386 libmpfr-dev:i386 libmpc-dev:i386 gcc-multilib g++-multilib

3. Don't forget the "--gcc 6" parameter! It says it right at the top of the page but wasn't obvious to me.

4. You need a github account with a ssh key! I think this is because the scripts use ssh:// instead of https:// (which shouldn't be necessary for a RO checkout). You can add a key here: https://github.com/settings/ssh

After all this I get 2 errors.

Code:

/usr/bin/install: cannot create regular file '/home/paul/source/gcc6.2/amigaos-cross-toolchain/.build-m68k/host/man/man1/flex.1': No such file or directory
Makefile:180: recipe for target 'install.man' failed

It's not a rights issue. If I build a second time it continues...

GCC actually builds OK but libnix fails.
submodules/libnix/sources/stubs/../nix/misc/__request.c

Code:

toolchain/submodules/libnix/sources/stubs/../headers -O3 -fomit-frame-pointer -c /home/paul/source/gcc6.2/amigaos-cross-toolchain/submodules/libnix/sources/stubs/../nix/misc/__request.c -o ../nix/misc/__request.o
In file included from /opt/m68k-amigaos/os-include/inline/intuition.h:16:0,
                from /opt/m68k-amigaos/os-include/proto/intuition.h:13,
                from /home/paul/source/gcc6.2/amigaos-cross-toolchain/submodules/libnix/sources/stubs/../nix/misc/__request.c:2:
/home/paul/source/gcc6.2/amigaos-cross-toolchain/submodules/libnix/sources/stubs/../nix/misc/__request.c: In function ‘__request’:
/home/paul/source/gcc6.2/amigaos-cross-toolchain/submodules/libnix/sources/stubs/../nix/misc/__request.c:13:26: error: invalid use of void expression
  if (((struct Process *)FindTask(NULL))->pr_WindowPtr != (APTR)-1L) {
                          ^
/home/paul/source/gcc6.2/amigaos-cross-toolchain/submodules/libnix/sources/stubs/../nix/misc/__request.c:14:23: error: void value not ignored as it ought to be
    if ((IntuitionBase=OpenLibrary(__intuitionname,0))) {
                      ^

Looks like OS calls are defined as returning void? If I hack around this the next file fails.

Building under Debian Linux VM. Cahirwpz's GCC 2.95 builds correctly.
Would love to know if anyone else has similar issues.

Marlon_ 08 January 2017 20:26

Quote:

Originally Posted by nogginthenog (Post 1133340)
GCC actually builds KO but libnix fails.
submodules/libnix/sources/stubs/../nix/misc/__request.c

I have the same issue. :/

EDIT:
On Debian too.

EDIT2:
Going to try on macOS Sierra next.

nogginthenog 09 January 2017 18:08

Seems to be a problem with the inlines or protos:

Code:

#include <proto/dos.h>
void test()
{
  Open("",MODE_OLDFILE);
}

/opt/m68k-amigaos/bin/m68k-amigaos-gcc test.c

Code:

In file included from /opt/m68k-amigaos/os-include/inline/dos.h:16:0,
                from /opt/m68k-amigaos/os-include/proto/dos.h:13,
                from test.c:1:
test.c: In function âtestâ:
test.c:5:4: error: asm-specifier for variable â_Open_reâ conflicts with asm clobber list
    Open("",MODE_OLDFILE);
    ^
test.c:5:4: error: asm-specifier for variable â_n1â conflicts with asm clobber list

The preprocessor expands the above to this. I don't have 2.95 to hand but I'll see what it produces later.

Code:

void test()
{
  ({
    CONST_STRPTR _Open_v1 = (
      ""
    );LONG _Open_v2 = (1005); {
      register BPTR _Open_re __asm("d0");
      register struct Library *
        const _Open_bn __asm("a6") = (struct Library * )(DOSBase);
      register CONST_STRPTR _n1 __asm(
        "d1"
      ) = _Open_v1;
      register LONG _n2 __asm(
        "d2"
      ) = _Open_v2;
      __asm volatile("jsr a6@(-"
        "0x1e"
        ":W)": "=r" (_Open_re): "r" (_Open_bn), "rf" (_n1), "rf" (_n2): "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory");
      _Open_re;
    }
  });
}


alkis 09 January 2017 18:56

This is from gcc3.4.0
Code:

void test()
{
  ({ CONST_STRPTR _Open_v1 = (""); LONG _Open_v2 = (1005); BPTR _Open_re2 = ({ register int _d1 __asm("d1"); register int _a0 __asm("a0"); register int _a1 __asm("a1"); register BPTR _Open_re __asm("d0"); register void *const _Open_bn __asm("a6") = (DOSBase); register CONST_STRPTR _n1 __asm("d1") = _Open_v1; register LONG _n2 __asm("d2") = _Open_v2; __asm volatile ("jsr a6@(-""0x1e"":W)" : "=r" (_Open_re), "=r" (_d1), "=r" (_a0), "=r" (_a1) : "r" (_Open_bn), "rf"(_n1), "rf"(_n2) : "fp0", "fp1", "cc", "memory"); _Open_re; }); _Open_re2; });
}

Looks like the 6.x series states that the parameters (d1,d2) are clobbered (unspecified) after the block, while 3.x doesn't state that.

Interestingly enough, the 6.x says that a0,a1 are clobbered and 3.x does not.

nogginthenog 09 January 2017 20:34

Tested 2.95 vs 6.20 and they both produce identical code for the Open() wrapper.
I wonder if fd2sfd needs work?

I don't think Debian is an issue but I will spin up a 32bit Ubuntu VM just in case.

The compiler is working but OS support would be useful :-)

Marlon_ 09 January 2017 21:11

Mac has the same issue, so I doubt it's the OS. Would be nice if we could get the author to this thread so he's aware.

nogginthenog 09 January 2017 22:08

I've emailed Steffan and invited him to this thread.

bebbo 10 January 2017 01:30

Quote:

Originally Posted by nogginthenog (Post 1133340)
I tried to build this last week. Run into a couple of problems I couldn't solve.
I made some notes, which I was intending to post after I got everything working:

1. The page has:
# git clone git://github.com/cahirwpz/amigaos-cross-toolchain.git
But this should be:
# git clone git://github.com/bebbo/amigaos-cross-toolchain.git
otherwise you will build gcc 2.95 like me :-)

Thanks updated.

Quote:

2. You are going to need 32bit gcc and libs (anyone know why?). Didn't keep all my notes but I needed at least these:
sudo apt-get install libgmp-dev:i386 libmpfr-dev:i386 libmpc-dev:i386 gcc-multilib g++-multilib
32 bit is required since the amigaos linker stuff seems not to work with 64 bit. There are fixes missing to replaces integers with 32 bit values -not 64 bit.

Quote:

3. Don't forget the "--gcc 6" parameter! It says it right at the top of the page but wasn't obvious to me.
added in readme

Quote:

4. You need a github account with a ssh key! I think this is because the scripts use ssh:// instead of https:// (which shouldn't be necessary for a RO checkout). You can add a key here: https://github.com/settings/ssh

After all this I get 2 errors.

Code:

/usr/bin/install: cannot create regular file '/home/paul/source/gcc6.2/amigaos-cross-toolchain/.build-m68k/host/man/man1/flex.1': No such file or directory
Makefile:180: recipe for target 'install.man' failed

It's not a rights issue. If I build a second time it continues...

GCC actually builds OK but libnix fails.
submodules/libnix/sources/stubs/../nix/misc/__request.c

...
The macros.h file does not work with gcc 6. I am using a different one, which I did not test yet with gcc 2.93. So I did not commit it yet...

... committed it without testing 2.93.

Then the libnix will build partially. Relative code is not yet working.

bebbo 10 January 2017 01:33

I also enabled the "github issues" ticket tracking.

Marlon_ 10 January 2017 01:33

Quote:

Originally Posted by bebbo (Post 1133633)
I also enabled the "github issues" ticket tracking.

Nice! :)

Marlon_ 10 January 2017 01:53

The latest commits made it go much further for me on Debian!

EDIT:
I do get a lot of these:
Code:

m68k-amigaos-gcc: error: ../nix/stdio/vsscanf.S: No such file or directory
m68k-amigaos-gcc: fatal error: no input files

Code:

m68k-amigaos-gcc: error: extra/dirent.S: No such file or directory
m68k-amigaos-gcc: fatal error: no input files

Code:

m68k-amigaos-gcc: error: socket/__initsock.S: No such file or directory
m68k-amigaos-gcc: fatal error: no input files

And a lot of these:
Code:

m68k-amigaos-gcc: error: unrecognized command line option '-fbaserel'; did you mean '-fassert'?

bebbo 10 January 2017 10:34

Quote:

Relative code is not yet working.
That's the -fbaserel option.

As long you are not using the -fbaserel option you should be able to compile and link Amiga executables now.

Marlon_ 10 January 2017 14:01

Quote:

Originally Posted by bebbo (Post 1133669)
That's the -fbaserel option.

As long you are not using the -fbaserel option you should be able to compile and link Amiga executables now.

Ah, I see! :)

I don't feel like the whole toolchain has successfully been compiled though,
and I get funky stuff like this when trying to compile the example files that did compile with gcc-2
Code:

amigaos-cross-toolchain/examples$ make
m68k-amigaos-gcc -g -Os -Wall -fomit-frame-pointer    hello-ks13.c  -o hello-ks13
hello-ks13.c: In function ‘main’:
hello-ks13.c:12:40: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
  if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 34))) {
                                        ^~~~~~~~~~~
hello-ks13.c:17:1: internal compiler error: in default_no_named_section, at varasm.c:6230
 }
 ^
0x8781926 default_no_named_section(char const*, unsigned int, tree_node*)
        /home/marlon/amigaos-cross-toolchain/submodules/gcc-6/gcc/varasm.c:6230
0x878322f switch_to_section(section*)
        /home/marlon/amigaos-cross-toolchain/submodules/gcc-6/gcc/varasm.c:7148
0x8787f13 assemble_start_function(tree_node*, char const*)
        /home/marlon/amigaos-cross-toolchain/submodules/gcc-6/gcc/varasm.c:1761
0x8320d41 rest_of_handle_final
        /home/marlon/amigaos-cross-toolchain/submodules/gcc-6/gcc/final.c:4439
0x8320d41 execute
        /home/marlon/amigaos-cross-toolchain/submodules/gcc-6/gcc/final.c:4516
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
<builtin>: recipe for target 'hello-ks13' failed
make: *** [hello-ks13] Error 1


bebbo 10 January 2017 21:55

No one said it's a release version.

If I have time I'll continue working on building libnix without errors.

nogginthenog 10 January 2017 21:55

Thanks Bebbo :-) I didn't realise you are on this board. I will have a play.

Marlon_ 10 January 2017 22:01

Quote:

Originally Posted by bebbo (Post 1133825)
No one said it's a release version.

I realise this, I'm just letting you know in case you didn't know.

nogginthenog 10 January 2017 23:57

Late home today due to a train drivers strike in Southern England. 2 hours to get home from work :-(

This seems to be the cause of the problems.
Error: Unknown pseudo-op: `.section'

Confirmed that m68k-amigaos-as does not support .section

Example:
Code:

paul@debian:cd ~/source/gcc6.2/amigaos-cross-toolchain/submodules/libnix/sources/stubs/stubs

/opt/m68k-amigaos/bin/m68k-amigaos-gcc __dtor_list__.c
/tmp/cctMPpYM.s: Assembler messages:
/tmp/cctMPpYM.s:3: Error: Unknown pseudo-op:  `.section'

/opt/m68k-amigaos/bin/m68k-amigaos-gcc -S __dtor_list__.c
cat __dtor_list__.s
#NO_APP
        .globl  ___DTOR_LIST__
        .section        .bss
        .align  2
___DTOR_LIST__:
        .skip 8

I will try to investigate some more tomorrow.
Thanks for the great work Bebbo, we appreciate it :-)


All times are GMT +2. The time now is 12:32.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.

Page generated in 0.07867 seconds with 11 queries