Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
38 user(s) are online (31 user(s) are browsing Forums)

Members: 0
Guests: 38

more...
Support us!
Recent OS4 Files
OS4Depot.net





How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4577
...Intro...

Resized Image


The advantage of having up2date crosscompiler for amigaos4 probably have no needs to explain, as everything move forward, and even on amigaos4 we had to move even by small steps. While for having cross-compiler at all there is very good reassons: speed and ability to use all range of helpfull tools such as cmakes,autoconf and scripting languages, but for having updated cross-compiler there is even more reasson: ability to use c++XX till c++17, thread support in c++XX, bugfixes (and new bugs, of course:) ) and all the fancy stuff which come with new gcc. Some opensource projects even can't be compiled anymore on the dated and old compilers (like 4.x series).

While some projects can be fixed for backward compatibility, some of them heavy use new features which impossible to rewrite in accepted timeline. So having up2date version is always better. For those who curious what new in gcc8.2, there is brief list of changes: https://gcc.gnu.org/gcc-8/changes.html

The man who make it possible to have gcc on amigaos4 are Sebastian Bauer (sba1), who maintain adtools project at https://github.com/sba1/adtools/, which aims is to provide a number of tools that can be used to develop applications for AmigaOS and Amigaoid systems. But at the moment only the version for the amigaos4 are mostly maintained and in a relatively good shape, which is kind of expected as maintain alone everything for every possible platform are nightmare, so there is mostly all for aos4. So.. hats of to Sebastian !

Resized Image

Before, i use crosscompilers on Cygwin/Windows and on Linux, but this time i have some HP notebook / icore 3ghz with windows10 onboard (which i take for fast emulation of WinUAE/OS4_FE classic, to be able to do tests not only on x5000 and my old trusty pegasos2 , but also on some classic setup, even if it emulated). And lately i was in needs to have there something fresh for crosscompiling work, and there was 2 ways: or Cygwin again, or something else :) Cygwin was tested very well by me, and while it doing all the stuff well once you setup everything you need, i still didn't like the way how it maintain deps and i just want something more lightweight, different and new. And i choice MSYS2 : https://www.msys2.org/

Resized Image

As said on their site:
Quote:

At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains. It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.


So if you like it, you can follow instructions from their site to download and install it.

...Prepare for compiling...

For compiling cross-compiler, you will need native compiler first :) So you install everything you might think of: gcc, make, autotools, cmake, git, subversion, flex, bison, python, perl, etc, etc. Its all can be done via Pacman utility via running it over the msys2 console, so it mostly like apt-get, yum or anything of that sort.

Firstly, when you first time run the msys32.exe or msys64.exe (depend on what you want to use, 32 or x64 verions), you run "pacman" for update all the stuff you already have after initiall installation of MSYS2:

Quote:

# pacman -Syuu


And you repeat those steps until everything will be updated.

Then, we need to install all that developing stuff about which i told before, and that can be done easyly by that line for example:

Quote:

# pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain python git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake


All the necessary dependencies (like bisons,flex, etc) will be installed automatically. But if something will be missed later, you can always install it separately via the same pacman tool.

...Get ready for crosscompiler...

Now to the most interesting part: actuall compilation of our amigaos4 crosscompiler. But for first be sure, that you setup few additional settings for GIT, which are necessary, as without them some of the next comming commands (gild ones) will refuse to work. There they are:

Quote:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"


So, all you need is follow steps on Sebastian's adtools page,i.e:

cd /
mkdir /amiga
cd /amiga
git clone https://github.com/sba1/adtools
cd adtools

git submodule init
git submodule update

gild/bin/gild clone
gild/bin/gild checkout binutils 2.23.2
gild/bin/gild checkout gcc 8


At this step we have downloaded everything we need from adtools repo, and what we need next, is to actually build it.

I for myself build it also with support of objc and obj-c++. Not that its _that_ necessary to have for us, but sometime some stuff want it, so why not. Sebastian of course alone can't mantain everything, and so support of objc and obj-c++ will be "as it", but i see in issues on adtools repo, that Midar was able to build it, and test it by https://github.com/ObjFW/ObjFW where all compiles well and all tests passed, so at least it works in some form already.

For enabling it, i had to change a bit /amiga/adtools/gcc build/features.mk file, by changing that:

Quote:

--enable-languages=c,c++


on that

Quote:

--enable-languages=c,c++,objc,obj-c++


And nothing else need it.

Also you can see in the same features.mk file, that there is now --enable-threads=amigaos. This is new feature Sebastian add few months ago, for making c++XX threading works (yeah, this is _THAT_ "threading" about which we ask for 10 or how many years :) ) There is new option "-athread=", where you can choice from 3 options: native (so amigaos4 native implementation,without relying on pthreads at all), single (as it was before for us) and pthread (that one currently didn't work, probably will at some point, but not for now).

...Let's do it...

Now, before we will call "make" and to avoid issues in the process, we firstly will fix some cosmetic issues because of MSYS2.

1. You will have no "lha" installed for sure, which needs to unpack data from SDK archive (which will be auto downloaded from hyperion's site), so do it:

cd /amiga
git 
clone https://github.com/fragglet/lhasa
cd lhasa
./autogen.sh
make
make install


2. MSYS2, do not have needs for "-ldl", and so dind't have it, but building process want it, so we build wrapper which written specially for (for more information about go to the github page):

cd /amiga
git 
clone https://github.com/dlfcn-win32/dlfcn-win32.git
cd dlfcn-win32/
./
configure
make
make install
ln 
-/mingw/lib/libdl./mingw32/lib/libdl.a
ln 
-/mingw/lib/libdl./mingw64/lib/libdl.a



3. MSYS2 (and in whole mingw) , have some issues with absolute patches. I.e. /usr in reality are d:/msys64/usr (or where you installed msys2, point is that it mix of win32 and unix path), so sometime, some includes, or apps, which use some functions which others don't, want it as "real" path (with win32 part at begining). So, to fix issues which may come because of it (and they will, if you didn't fix), we in /amiga/adtools/gcc-build/Makefile, change that:

Quote:

REAL_SRC_DIR=$(realpath $(SRC_DIR))


on that:

Quote:

REAL_SRC_DIR=d:/msys64$(realpath $(SRC_DIR))


Taking in mind that its "d:/msys64" where we install MSYS2, so path can be different for you, of course.

Also there will be issues with the @include directive in the *.texi files, so, we just doing that:

Quote:

cp /amiga/adtools/gcc/repo/gcc/doc/include/* /amiga/adtools/gcc/repo/gcc/doc/
cp /amiga/adtools/native-build/gcc-cross-build-8.2.0/gcc/gcc-vers.texi /amiga/adtools/gcc/repo/gcc/doc/


And that should be enough (at least for me is). If, through, you will see any error from any .texi file, saying that from @include some file can't be found, just replace it with full path, or copy necessary file to that directory.

Then, at last, run the magic line to build and install our os4 crosscompiler.

Quote:

# make -C native-build gcc-cross CROSS_PREFIX=/usr/local/amiga


It will take a while, so you better add -j2 or -j3 to do parallel building and to speed things up. But once it done, we just issue our magic "export PATH=/usr/local/amiga/bin:$PATH" for make system know where to find amigaos4 compiler binaries (and that line better to add to the /home/user/.bashrc file, so you will have no needs to worry anymore about)

Done !

Resized Image
(press open image in new tab for full size)

Some test code now:

#include <stdio.h>
void main()
{
     
printf("gcc 8.2.0\n");
}

ppc-amigaos-gcc test.-o test


Resized Image
(press open image in new tab for full size)

Going a bit heavy (c++11 and threading via Sebastian's native implementation):

#include <iostream>
#include <thread>

//This function will be called from a thread

void call_from_thread() {
    
std::cout << "only 1200, only hardcore" << std::endl;
}

int main() {
    
//Launch a thread
    
std::thread t1(call_from_thread);

    
//Join the thread with the main thread
    
t1.join();

    return 
0;
}

ppc-amigaos-g++ -athread=native test2.-o test2


Resized Image
(press open image in new tab for full size)

...Outro...

That all, hope it will help someone. Even if one of our (or even new?) developers will find if helpfull, that will mean i write that for reasson :)


Edited by kas1e on 2018/11/9 18:30:03
Edited by kas1e on 2018/11/9 18:59:48
Edited by kas1e on 2018/11/13 18:25:33
Edited by kas1e on 2018/11/13 18:26:17
_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Quite a regular
Joined:
2013/10/17 15:21
From Hungary
Posts: 563
Nice I'm going to check this out later. Cygwin offers good compatibility, but it's really slow compared to MSYS or even to Linux in a VM.

_________________
I see the jimmies have been rustled.
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Joined:
2006/12/2 23:57
From Athens
Posts: 433
Great guide Kas1e, as always. Do you mind to add that at os4coding.net as a blog post as well?

   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Joined:
2006/12/2 23:57
From Athens
Posts: 433
I have a few questions:
1. Is it possible to compile for 68K as well with that installation? If this is possible, do we need the OS3 NDK installed somewhere?
2. The OS4 SDK is not needed at all, or should we add that later?

   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4577
@walkero
Quote:

Do you mind to add that at os4coding.net as a blog post as well

Yeah, why not

Quote:

1. Is it possible to compile for 68K as well with that installation? If this is possible, do we need the OS3 NDK installed somewhere?


Nope, you need to build 68k crosscompiler for that, but adtool's current one is os4 only based, and all the installation scripts,etc, all for produce os4 crosscompiler. For 68k one when i have needs i use zerohero's guide for: http://kas1e.mikendezign.com/zerohero ... p/cross-compiler_os3.html

But its "a bit" old, and i know there is more recent versions somewhere.

Quote:

2. The OS4 SDK is not needed at all, or should we add that later?


SDK will be downloaded, unpacked and installed automatically from Hyperion's site (for that purpose we install lha, to be able to unpack it). That process done inside of adtools installation scripts, so you need no worry about.


_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Joined:
2006/12/2 23:57
From Athens
Posts: 433
Thank you for your fast reply.
Keep up the good work.

   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Joined:
2016/9/1 8:40
From Leiden ZH
Posts: 19
Great guide!

Two things:

1) It was unclear to me from which directory to do the make -C native-build (adtools)
2) I don't have a file called /amiga/adtools/native-build/gcc-cross-build-8.2.0/gcc/gcc-vers.texi.

There is no /amiga/adtools/native-build/gcc-cross-build-8.2.0/ dir. Not sure what I did wrong?


Oh and now it errors with BFD does not support target powerpc-unknown-amigaos


Edited by Hedeon on 2018/11/12 22:48:31
Edited by Hedeon on 2018/11/12 22:51:05
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Joined:
2016/9/1 8:40
From Leiden ZH
Posts: 19
I guess the patches were not applied? Have to do that manually?

Edit: Doing gild checkout binutils 2.23.2 again fixed it somehow. Must binutils-build makefile also be adjusted for installation path just like gcc-build?

Edit2: And now it craps out on some multiple pattern error in a makefile.

Edit3: deleted all, redid all...and guess what...


In file included from E:/msys64/home/Dennis/amiga/adtools/binutils/repo/gas/hash.c:34:
E:/msys64/home/Dennis/amiga/adtools/binutils/repo/gas/hash.cIn function 'hash_new_sized':
E:/msys64/home/Dennis/amiga/adtools/binutils/repo/include/obstack.h:272:5errorcast between incompatible function types from 'void * (*)(size_t)' {aka 'void * (*)(long long unsigned int)'to 'void * (*)(long int)' [-Werror=cast-function-type]
     (
void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
     ^
E:/msys64/home/Dennis/amiga/adtools/binutils/repo/gas/hash.c:93:3notein expansion of macro 'obstack_begin'
   
obstack_begin (&ret->memorychunksize);
   ^~~~~~~~~~~~~
cc1.exeall warnings being treated as errors
make
[6]: *** [Makefile:874hash.oFout 1


I am going to cry myself to sleep now.


Edited by Hedeon on 2018/11/12 23:37:23
Edited by Hedeon on 2018/11/12 23:53:54
Edited by Hedeon on 2018/11/12 23:54:47
Edited by Hedeon on 2018/11/13 1:46:09
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4577
@Hedeon
Patches applies when you run those gild commands. Maybe you didn't scroll code block in first post, it is:

Quote:

$ cd /
$ mkdir /amiga
$ cd /amiga
$ git clone https://github.com/sba1/adtools
$ cd adtools

$ git submodule init
$ git submodule update

$ gild/bin/gild clone
$ gild/bin/gild checkout binutils 2.23.2
$ gild/bin/gild checkout gcc 8


Last 2 commands applied patches on binutils and on gcc (so you will have those necessary directories as well)

As for "make" - you run it from /amiga/adtools directory (ie where you are after running last 2 gild commands). In your case its /home/Dennis/amiga/adtools

Maybe because of no sleep you forget to enter to one or another directory, or skip some step, so better delete all and trying from scratch.

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Joined:
2016/9/1 8:40
From Leiden ZH
Posts: 19
@kas1e

I indeed probably forgot the gild checkout binutils step after the long clone step.
Being smart and copying what you did in gcc-build to binutils-build (adjusting the path) made the binutils build error. So that's also my fault.

The last error is weird. I am guessing some 64/32bit error and trying it all again with 686 instead of x64.

Edit: ok this time I am sure. binutils/gcc patches were again not applied the first time I did gild checkout


Edited by Hedeon on 2018/11/13 14:04:18
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4577
@Hedeon
Quote:

The last error is weird. I am guessing some 64/32bit error and trying it all again with 686 instead of x64.


On MSYS2 i use 7.3.0 to build our compiler, and i do check it and over mingw32 and mingw64. Maybe you have 8.2.0 one on MSYS2 ? It too freesh for them, maybe can cause issues.

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Joined:
2016/9/1 8:40
From Leiden ZH
Posts: 19
@kas1e

Also gild checkout does not apply patches first time invoked. I double checked now.

Edit: after setting name and email it worked........

git config --global user.email "you@example.com"
git config --global user.name "Your Name"


   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Joined:
2016/9/1 8:40
From Leiden ZH
Posts: 19
It's builds a lot further now while using 32. The noob in me says the difference in the declaration of void between the two is a problem (64 = size 8, 32 = size 4 I seem to see).

   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4577
@Hedeon
Ah damn! I was sure its me just didnt have git setuped correctly, and was sure that not need to be in text. But i have same of course at begining, just i have at first warnings about and deal with it.

Will update first post

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Joined:
2016/9/1 8:40
From Leiden ZH
Posts: 19
It completely compiled now. Latest msys32 uses gcc 7.3.

Lazy as I was I copied your test.c program to test. It has a typo and is missing a \ most likely.

But it works now! Great!

Oh and that native-build/gcc-cross-build-8.2.0 directory only appears after compiling.

   Report Go to top

Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4577
@Hedeon
Thanks, fixed all in first post. Good that you have it working as well :)

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project