Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
74 user(s) are online (54 user(s) are browsing Forums)

Members: 1
Guests: 73

LiveForIt, more...

Support us!

Headlines

 
  Register To Post  

(1) 2 »
How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
...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!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Quite a regular
Quite a regular


See User information
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.

This is just like television, only you can see much further.
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Site Builder


See User information
Great guide Kas1e, as always. Do you mind to add that at os4coding.net as a blog post as well?

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Site Builder


See User information
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?

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@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!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Site Builder


See User information
Thank you for your fast reply.
Keep up the good work.

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Just popping in


See User information
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
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Just popping in


See User information
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
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@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!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Just popping in


See User information
@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
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@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!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Just popping in


See User information
@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"


Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Just popping in


See User information
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).

Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@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!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Just popping in
Just popping in


See User information
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.

Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@Hedeon
Thanks, fixed all in first post. Good that you have it working as well :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Quite a regular
Quite a regular


See User information
@kas1e

So this is the shit? :)
This will build Odyssey, MPlayer and all that heavy stuff?

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@Deniil
It probably can, but will be harder than with cygwin: all of them use cmake, but with msys2 cmake works different and because of pathes, and because it will think that its win32 and not linux, so there will need some adoptation work (not to the code, but to cmake scripts, etc)

Cygwin can be used same easy to build adtools cross compiler (if there needs i can write little howto about how to setup it all)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Site Builder
Site Builder


See User information
At the adtools repo there is a wrong link at the native-build/makefile, where it downloads the SDK 53.24 instead of the latest 53.30.

have a look at
https://github.com/sba1/adtools/pull/55/commits

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: How to build AmigaOS4 cross-compiler (binutils 2.23.2 & gcc 8.2.0) on MSYS2.
Home away from home
Home away from home


See User information
@walkero
I have to check, but at least name of downloaded archive was 53.30 for sure. If only it download 53.24 and save it with 53.30 name :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project