...[b]Intro[/b]... [img]http://kas1e.mikendezign.com/aos4/cross_compiling/msys2/images/gcc.png[/img] 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. We need ability to use c++XX till c++17, ability to use thread support in c++XX 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 ! [img]http://kas1e.mikendezign.com/aos4/cross_compiling/msys2/images/adtools.png[/img] 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/ [img]http://kas1e.mikendezign.com/aos4/cross_compiling/msys2/images/msys2.jpg[/img] 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. [/quote] So if you like it, you can follow instructions from their site to download and install it. ...[b]Prepare for compiling[/b]... 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 [/quote] 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 [/quote] 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. ...[b]Get ready for crosscompiler[/b]... Now to the most interesting part: actuall compilation of our amigaos4 crosscompiler. All you need is follow steps on Sebastian's adtools page,i.e: [code] $ cd / $ mkdir /amiga $ cd /amiga $ git clone https://github.com/sba1/adtools $ cd adtools $ git submodule initi $ git submodule update $ gild/bin/gild clone $ gild/bin/gild checkout binutils 2.23.2 $ gild/bin/gild checkout gcc 8 [/code] 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++ [/quote] on that [quote] --enable-languages=c,c++,objc,obj-c++ [/quote] 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). ...[b]Let's do it[/b]... Now, before we will call "make" and to avoid issues in the process, we firstly will fix some cosmetic issues because of MSYS2. [b]1.[/b] 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: [code] cd /amiga git clone https://github.com/fragglet/lhasa cd lhaasa ./autogen.sh make make install [/code] [b]2.[/b] 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): [code] cd /amiga git clone https://github.com/dlfcn-win32/dlfcn-win32.git cd dlfcn-win32/ ./configure make make install ln -s /mingw/lib/libdl.a /mingw32/lib/libdl.a ln -s /mingw/lib/libdl.a /mingw64/lib/libdl.a [/code] [b]3.[/b] 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)) [/quote] on that: [quote] REAL_SRC_DIR=d:/msys64$(realpath $(SRC_DIR)) [/quote] 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/ [/quote] 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 [/quote] 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 ! [img]http://kas1e.mikendezign.com/aos4/cross_compiling/msys2/images/cross_ready.jpg[/img] (press open image in new tab for full size) Some test code now: [code] #include void main() { pritnf("gcc 8.2.0\n"); } $ ppc-amigaos-gcc test.c -o test [/code] [img]http://kas1e.mikendezign.com/aos4/cross_compiling/msys2/images/test1.jpg[/img] (press open image in new tab for full size) Going a bit heavy (c++11 and threading via Sebastian's native implementation): [code] #include #include //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.c -o test2 [/code] [img]http://kas1e.mikendezign.com/aos4/cross_compiling/msys2/images/test2.jpg[/img] (press open image in new tab for full size) ...[b]Outro[/b]... 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 :)