English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 08 January 2017, 16:16   #1
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
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.
Samurai_Crow is offline  
Old 08 January 2017, 17:52   #2
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
Nice! Finally a more recent version of GCC. I'll give it a go!
Marlon_ is offline  
Old 08 January 2017, 18:00   #3
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Excellent work

I tend to use vbcc thesedays but this is good.
plasmab is offline  
Old 08 January 2017, 18:40   #4
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
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.

Last edited by nogginthenog; 09 January 2017 at 17:20.
nogginthenog is offline  
Old 08 January 2017, 19:26   #5
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
Quote:
Originally Posted by nogginthenog View Post
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.
Marlon_ is offline  
Old 09 January 2017, 17:08   #6
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
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;
    }
  });
}

Last edited by nogginthenog; 09 January 2017 at 17:22.
nogginthenog is offline  
Old 09 January 2017, 17:56   #7
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
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.

Last edited by alkis; 09 January 2017 at 17:59. Reason: a0/a1
alkis is offline  
Old 09 January 2017, 19:34   #8
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
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 :-)
nogginthenog is offline  
Old 09 January 2017, 20:11   #9
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
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.
Marlon_ is offline  
Old 09 January 2017, 21:08   #10
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
I've emailed Steffan and invited him to this thread.
nogginthenog is offline  
Old 10 January 2017, 00:30   #11
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by nogginthenog View Post
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.

Last edited by bebbo; 10 January 2017 at 00:35.
bebbo is offline  
Old 10 January 2017, 00:33   #12
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
I also enabled the "github issues" ticket tracking.
bebbo is offline  
Old 10 January 2017, 00:33   #13
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
Quote:
Originally Posted by bebbo View Post
I also enabled the "github issues" ticket tracking.
Nice!
Marlon_ is offline  
Old 10 January 2017, 00:53   #14
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
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'?

Last edited by Marlon_; 10 January 2017 at 00:58.
Marlon_ is offline  
Old 10 January 2017, 09:34   #15
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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.
bebbo is offline  
Old 10 January 2017, 13:01   #16
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
Quote:
Originally Posted by bebbo View Post
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

Last edited by Marlon_; 10 January 2017 at 13:10.
Marlon_ is offline  
Old 10 January 2017, 20:55   #17
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
No one said it's a release version.

If I have time I'll continue working on building libnix without errors.
bebbo is offline  
Old 10 January 2017, 20:55   #18
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
Thanks Bebbo :-) I didn't realise you are on this board. I will have a play.
nogginthenog is offline  
Old 10 January 2017, 21:01   #19
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
Quote:
Originally Posted by bebbo View Post
No one said it's a release version.
I realise this, I'm just letting you know in case you didn't know.
Marlon_ is offline  
Old 10 January 2017, 22:57   #20
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
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 :-)
nogginthenog is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
New GCC based dev toolchain for AmigaOS 3.x cla Coders. Releases 8 24 December 2017 10:18
Issue with photon/xxxx WinUAE Toolchain arpz Coders. Asm / Hardware 2 26 September 2015 22:33
New 68k gcc toolchain arti Coders. C/C++ 17 31 July 2015 03:59
Hannibal's WinUAE Demo Toolchain 5 Bobic Amiga scene 1 23 July 2015 21:04
From gcc to vbcc. Cowcat Coders. General 9 06 June 2014 14:45

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:17.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14476 seconds with 14 queries