AROS World Exec

Development => AROS Software Development => Topic started by: PortablE on August 14, 2022, 12:47:24 PM

Title: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 14, 2022, 12:47:24 PM
Does anyone know where I can find a version of GCC/G++ compiler for Linux that will cross-compile for AROS? 

ZeroHero used to provide one, but his website is down, and no-one seems to have saved his AROS (nor MorphOS) versions:
http://www.zerohero.se/cross/aros.html (no-longer exists)
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 14, 2022, 12:56:41 PM
Hi,

If you follow these instructions: https://github.com/deadw00d/AROS/blob/alt-abiv0/INSTALL.md

You will get a local build of AROS together with local cross-compiler. For using the cross-compiler outside of AROS build-system, you need to add --sysroot switch pointing to Development directory inside of AROS build.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 16, 2022, 03:09:16 PM
Thanks for the pointer - but I was hoping for a pre-compiled version that would avoid me having to install subversion & the huge number of other dependencies needed to build AROS.  (That may not be a show-stopper, but it will at least greatly delay anything AROS-related that I do, as I don't want to have all that 'junk' installed onto my main Linux system.  Possibly I can use chroot or toolbox to keep it entirely separate, but I have not used either of them yet, and they will probably be more complicated than I hope.)

I hadn't realised that GCC/etc from the Linux-hosted version of AROS could be run outside of AROS (on Linux itself), so it seems I need to look for a pre-compiled version of the Linux-hosted AROS & it's developer tools (if that even exists).
Title: Re: AROS cross-compiler that runs on Linux?
Post by: magorium on August 16, 2022, 05:05:47 PM
I hadn't realised that GCC/etc from the Linux-hosted version of AROS could be run outside of AROS (on Linux itself),
Unfortunately it can't.

Quote
... so it seems I need to look for a pre-compiled version of the Linux-hosted AROS & it's developer tools (if that even exists).
Pre compiled versions of AROS ABIv0 Linux hosted can be found at https://axrt.org/index.php?tab=download-aros (https://axrt.org/index.php?tab=download-aros)

And as always has been the case you can use the contrib archive to 'obtain' the development directory which contains the /native/ AROS gcc compiler and tools.

What deadwood wrote is that when you build AROS as described that it automatically builds the AROS cross-compiler for you.

That compiler is used to build AROS itself but can be used outside the AROS build process by providing --sysroot with indicated directory to cross compile for AROS.

Quote
Thanks for the pointer - but I was hoping for a pre-compiled version that would avoid me having to install subversion & the huge number of other dependencies needed to build AROS.  (That may not be a show-stopper, but it will at least greatly delay anything AROS-related that I do, as I don't want to have all that 'junk' installed onto my main Linux system.  Possibly I can use chroot or toolbox to keep it entirely separate, but I have not used either of them yet, and they will probably be more complicated than I hope.)
I have no idea about your setup but in case you do have a development machine that has enough free ram (> 8 GB, Unfortunately I do not have an exact figure) then there is no need for a (permanent) installation.

The build instructions as indicated will build everything outside your current system setup. If your setup is able to accomplish that in ram (ramdisk) then you could zip/tarball the directories that you require/desire and re-use those at your disposal (to avoid having to build the whole AROS tree over and over again). Not an ideal solution but it might perhaps be able to address some of your concerns.

But perhaps deadwood has a quicker/better solution as I am not very familiar with AROS' build system.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: miker1264 on August 16, 2022, 05:18:03 PM
Not sure if it helps but I use the AROS 64bit Developer VMWare setup provided by Palone some time ago. It has all the prerequisites already installed in Ubuntu 18.04.

At first I used the VMWare Build System for compiling ABIv1 x86-64. But then I made a copy of the VM to compile AROS 68k. More recently I made two more copies - one to compile ABIv11 x86-64 & one to compile ABV0 x86.

These VM's are all running in VMWare Workstation. That way they don't clutter another workspace or interfere with each other. The Build Systems run well & sufficiently fast inside respective VM's.

Title: Re: AROS cross-compiler that runs on Linux?
Post by: AMIGASYSTEM on August 16, 2022, 05:45:12 PM
Without any doubt VMWare is the best solution to work with AROS x86, and very fast, works very well Network, Audio and Video.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 17, 2022, 01:24:12 AM
Thanks for the pointer - but I was hoping for a pre-compiled version that would avoid me having to install subversion & the huge number of other dependencies needed to build AROS.  (That may not be a show-stopper, but it will at least greatly delay anything AROS-related that I do, as I don't want to have all that 'junk' installed onto my main Linux system.  Possibly I can use chroot or toolbox to keep it entirely separate, but I have not used either of them yet, and they will probably be more complicated than I hope.)

I generally use VMs for such tasks, not to clutter my main system with "temporary" things.

I hadn't realised that GCC/etc from the Linux-hosted version of AROS could be run outside of AROS (on Linux itself), so it seems I need to look for a pre-compiled version of the Linux-hosted AROS & it's developer tools (if that even exists).

There are two compilers: one is a cross-compiler that is built based on instructions above and is a Linux-native program. Second is a AROS-native compiler that comes from "contrib" and is part of distributions. I was refererring to the first compiler, the cross-compiler. AROS-native compiler won't work under Linux.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 20, 2022, 02:28:04 PM
Thanks.  I've ended-up using this guide, as there's no need to use Subversion/etc
https://github.com/apiraino/aros_guide

Although it doesn't tell you to install "libpng-dev" (which is needed).  Then it fails trying to download gnu mpc, so it was necessary to edit "tools/crosstools/mmakefile", and add this path in the right place: https://ftp.gnu.org/gnu/mpc

I'm now trying to work-out how to convince the build scripts to use sensible (non-machine-specific) paths for the cross-compiler tools & include files...
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 21, 2022, 12:28:43 AM
Just a note - there is no longer a need to use Subversion, sources are now on Github.

BTW, where did you get the sources from for your local build?
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 21, 2022, 03:47:14 AM
Just a note - there is no longer a need to use Subversion, sources are now on Github.
OK, but that wasn't the impression I got from the instructions saying to install these packages:
subversion git-core gcc g++ make gawk bison flex bzip2 netpbm autoconf automake libx11-dev libxext-dev libc6-dev liblzo2-dev libxxf86vm-dev libpng-dev gcc-multilib libsdl1.2-dev byacc python-mako libxcursor-dev cmake zsh mingw64
Quote
BTW, where did you get the sources from for your local build?
https://aros.sourceforge.io/nightly.php
source
Core AROS sources.
https://sourceforge.net/projects/aros/files/nightly/20190520/Sources/AROS-20190520-source.tar.bz2/download
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 21, 2022, 12:33:26 PM
Hmm, I'll have to update instructions to remove svn.

I'd suggest using the sources from snapshots:

https://aros.sourceforge.io/snapshots.php

These are more up-to-date if you are interested in i386.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 21, 2022, 02:46:11 PM
I'd suggest using the sources from snapshots:
https://aros.sourceforge.io/snapshots.php
These are more up-to-date if you are interested in i386.
I'm not worried about being up-to-date, but how is a 2019-04-16 snapshot more recent than a 2019-05-20 nightly?
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 21, 2022, 03:42:11 PM
I believe I've now got a GCC installation which is fairly portable between Linux machines.  (Although I have another issue that currently makes thorough testing rather difficult.) 
As this wasn't so easy for an AROS & GCC compiling newbie like me to achieve, here are the main things I had to do:

First I needed to configure it with the following additional parameters:
../AROS-20190520-source/configure --target=linux-i386 --enable-debug --with-aros-toolchain-install=/usr/local/amiga/bin_aros --prefix=/usr/local/amiga/bin_aros

But that doesn't stop the resulting GCC from defaulting to looking for the AROS sysroot (includes, object files, etc) in a non-portable location.  So I then needed to edit "config/make.cfg", and change the following two assignments to be:
AROS_DIR_DEVELOPMENT := /usr/local/amiga/i386-aros
AROS_DEVELOPMENT     := $(AROS_DIR_DEVELOPMENT)


Obviously the contents of the Development folder needs to be copied to "/usr/local/amiga/i386-aros".  And there needs to be an empty folder for "/usr/local/amiga/bin_aros".

Then I could run "make".

The rather old version of AROS I am building fails to download GNU MPC, so after "make" starts compiling stuff, I needed to edit the "tools/crosstools/mmakefile" file it had created, and change the following assignment to be:
MPC_REPOSITORY := https://ftp.gnu.org/gnu/mpc

When it eventually finishes, it's worth checking the resulting executable, to ensure it doesn't contain any non-portable references:
/usr/local/amiga/bin_aros/i386-aros-g++ -v

BTW, to stop the above command reporting it was configured from the original user path I did this from, I created a symlink from /AROS to that folder, and then cd to /AROS before running "configure" & "make".
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 21, 2022, 11:35:21 PM
I'd suggest using the sources from snapshots:
https://aros.sourceforge.io/snapshots.php
These are more up-to-date if you are interested in i386.
I'm not worried about being up-to-date, but how is a 2019-04-16 snapshot more recent than a 2019-05-20 nightly?

The naming is confusing but this is temporary and will be fixed in future. The main difference is that using the 05-20 nightly you will build GCC 4.6.4 cross-compiler and using 04-16 snapshot you will build GCC 6.5.0.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 22, 2022, 04:04:50 PM
The naming is confusing but this is temporary and will be fixed in future. The main difference is that using the 05-20 nightly you will build GCC 4.6.4 cross-compiler and using 04-16 snapshot you will build GCC 6.5.0.
I'm giving it a go, but it looks like I'll need to do more trial & error to get something usable, and it's taking twice as long to finish compiling (I thought the previous one only failed near the end, but perhaps it was much earlier). 

Is there a way to get it to stop compiling AROS itself, so it just does the GCC stuff?
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 22, 2022, 11:47:09 PM
use

Code: [Select]
$ make -s crosstools

This should build just the cross-compiler and SDK headers/libraries instead of complete AROS
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 27, 2022, 02:56:36 PM
I had difficulty repeating what I'd done for GCC v4.6.4 with GCC 6.5.0, so I've done a lot of trial & error to devise a script to do it.  Also means I have a better v4.6.4 as well.  (I'll post the script later, once I've cleaned it up.)

Only problem is that (for both GCC versions) stripping the executable results in a corrupt executable, even if I follow the advice here to use "--strip-unneeded --remove-section .comment":
https://aros.sourceforge.io/sv/documentation/developers/app-dev/introduction.php

Using -s with GCC, instead of separately stripping, seems an OK work-around, but would it's a shame that "strip" doesn't work.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on August 29, 2022, 02:52:28 PM
To get the AROS cross-compiler to be portable between machines, I forced everything to be within "/usr/local/amiga" (actually two folders within that), to roughly match how the Amiga OS3 & OS4 cross-compilers do it.  I also ensured they contained no references to the original path they were built on, since that could reference the user/etc that did it.

To achieve all that I did the following below, which is presented as a script - and while it could probably be executed as one, it has no error handling, so instead I copied & pasted a few lines at a time:

Code: [Select]
# Prepare base directories.  NOTE: You can skip this part, if you are re-running this for some reason.
sudo mkdir -p /usr/local/amiga
# enter sudo password!
sudo chown $USER:$USER /usr/local/amiga
sudo mkdir /AROS
sudo chown $USER:$USER /AROS

# Specify the working directory & the AROS source code folder it contains:
clear
cd THE_FOLDER_THAT_CONTAINS_THE_EXTRACTED_AROS_SOURCES_FOLDER
#AROS_source="AROS-20190520-source" # GCC v4.6.4
AROS_source="AROS-20190416-2-source" # GCC v6.5.0

# Create two fake folders used to hide the full path of the working directory:
AROS_base="$(pwd)"
mkdir $AROS_base/build
# These work fine, but the executables still contain references to the non-/AROS path (mainly the build directory):
#ln -s $AROS_base/build        /AROS/build
#ln -s $AROS_base/$AROS_source /AROS/source
# While these work best:
mkdir /AROS/build;  sudo mount --bind $AROS_base/build        /AROS/build
# enter sudo password!
mkdir /AROS/source; sudo mount --bind $AROS_base/$AROS_source /AROS/source

# Prepare the two destination folders that contain the binaries & AROS compiler sysroot:
cd /AROS/build
mkdir -p /usr/local/amiga/bin_aros
mkdir -p /usr/local/amiga/i386-aros; mkdir -p "bin/linux-i386/AROS"; ln -s /usr/local/amiga/i386-aros "bin/linux-i386/AROS/Development"

# Configure GCC's make scripts:
/AROS/source/configure --target=linux-i386 --with-aros-toolchain-install=/usr/local/amiga/bin_aros --prefix=/usr/local/amiga/bin_aros
# Not necessary: --enable-debug

# Fix where the AROS sysroot is expected:
Search="$(pwd)/bin/linux-i386/AROS/Development" ; Replace="/usr/local/amiga/i386-aros"
sed -i "s/${Search//\//\\\/}/${Replace//\//\\\/}/g" bin/linux-i386/gen/config/conf.cmake
sed -i "s/\$(AROSDIR)\/\$(AROS_DIR_DEVELOPER)/${Replace//\//\\\/}/g" config/make.cfg
sed -i "s/\$(AROSDIR)\/\$(AROS_DIR_DEVELOPMENT)/${Replace//\//\\\/}/g" config/make.cfg
sed -i "s/\$(AROSDIR)\/\$(AROS_DIR_INCLUDE)/${Replace//\//\\\/}\/include/g" config/make.cfg
sed -i "s/\$(AROSDIR)\/\$(AROS_DIR_LIB)/${Replace//\//\\\/}\/lib/g" config/make.cfg

# This is only needed for "AROS-20190520-source", to fix MPC_REPOSITORY, but won't cause problems for others:
(while [ ! -f "tools/crosstools/mmakefile" ]; do sleep 1; done; sleep 1; grep "www.multiprecision.org/mpc/download" tools/crosstools/mmakefile >/dev/null && sed -i 's/MPC_REPOSITORY :=/MPC_REPOSITORY := https:\/\/ftp.gnu.org\/gnu\/mpc\n#MPC_REPOSITORY :=/g' tools/crosstools/mmakefile && sed -i 's/ISL_REPOSITORY :=  ftp:/ISL_REPOSITORY := https:/g' tools/crosstools/mmakefile) &

# Run make:
time make
# Or for "AROS-20190416-2-source" this WOULD faster, but for me GCC fails as it's missing "libm.a":
#time make -s crosstools

# Clean-up unneeded files in the destination
rm -r /usr/local/amiga/i386-aros/{bin,etc,Debug,man,S}
rm /usr/local/amiga/i386-aros/*.info

# Clean-up any mount points:
cd $AROS_base
sudo umount /AROS/build /AROS/source ; rmdir /AROS/build /AROS/source
# enter sudo password!

# Clean-up other stuff
rm /AROS/build /AROS/source #2>/dev/null
rm -fr $AROS_base/build

# Check result:
/usr/local/amiga/bin_aros/i386-aros-g++ -v 2>&1 | sed "s/ /\n/g" | grep / | cat

# Optionally make executables accessible from /usr/local/amiga/bin
cd /usr/local/amiga
mkdir -p bin
find bin_aros/ -maxdepth 1 -type f -iname "[a-z]*" | xargs -n1 basename | xargs -I {} ln -s /usr/local/amiga/bin_aros/{} bin/{}

# Very optionally create a distributable archive (assuming /usr/local/amiga/bin/ only contains executables for AROS & no other Amiga cross-compilers)
cd /usr/local/
tar --owner=root --group=root -cv -f $AROS_base/AROS_GCC.tar.gz --gzip amiga/bin_aros amiga/i386-aros amiga/bin
tar --owner=root --group=root -cv -f $AROS_base/AROS_GCC.tar.xz --xz   amiga/bin_aros amiga/i386-aros amiga/bin
# Check archive contents
tar -tvf $AROS_base/AROS_GCC.tar.gz | less

At some point I may make the end result available for others to download (probably after more testing), but as its rather large even when Zipped (170-320MB), I'll have to be careful how I host it.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on August 29, 2022, 11:39:00 PM
Thanks for publishing the script. It will be useful to other developers. :)
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on November 03, 2022, 04:40:26 PM
I've edited the above 'script' to append the following lines:
Code: [Select]
# Optionally make executables accessible from /usr/local/amiga/bin
cd /usr/local/amiga
mkdir -p bin
find bin_aros/ -maxdepth 1 -type f -iname "[a-z]*" | xargs -n1 basename | xargs -I {} ln -s /usr/local/amiga/bin_aros/{} bin/{}

# Very optionally create a distributable archive (assuming /usr/local/amiga/bin/ only contains executables for AROS & no other Amiga cross-compilers)
cd /usr/local/
tar --owner=root --group=root -cv -f $AROS_base/AROS_GCC.tar.gz --gzip amiga/bin_aros amiga/i386-aros amiga/bin
tar --owner=root --group=root -cv -f $AROS_base/AROS_GCC.tar.xz --xz   amiga/bin_aros amiga/i386-aros amiga/bin
# Check archive contents
tar -tvf $AROS_base/AROS_GCC.tar.gz | less

The first part (adding sym-links) was inspired by how BigFoot's MorphOS cross-compiler makes the executables accessible (without requiring the user to update their PATH).

The second part is basically what I've used to create a distributable archive - which I do intend to make downloadable.  The XZ archive is half the size of the GZip one, but takes far longer to create.
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on November 05, 2022, 03:01:29 PM
For anyone interested, the AROS cross-compilers I've built are now available to download from here:
http://cshandley.co.uk/crosscompilers/
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on November 06, 2022, 06:46:28 AM
I've now changed my cross-compiler archives, so they only need to be extracted inside "/usr/local" rather than "/" .
Title: Re: AROS cross-compiler that runs on Linux?
Post by: amigamia on November 06, 2022, 07:05:28 AM
Nice job Chris. Thank you!

Any chance you can make one for Mac OS X?
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on November 06, 2022, 11:17:59 AM
Any chance you can make one for Mac OS X?
Sadly not, as (1) I don't have a Mac, and (2) all I've really done is tweak the AROS build scripts that other people have already made work on Linux, so that the end result is self-contained & easily installed.  In a bit more detail:

The AROS build scripts already allow AROS to be built from source on Linux, and part of that process builds AROS GCC/etc to run on Linux, so that all the AROS executables can be built.  The GCC building part is all I needed, and as standard the GCC executables were configured to expect their various files to be found where they were built.  I had to trick the build scripts to put them & look for them in a machine & user independent location (/usr/local/amiga).

Going by this:
https://aros.sourceforge.io/introduction/ports.php#aros-darwin-i386-and-darwin-x86-64

The build scripts also support Mac OS on x86 & PPC, but not ARM.  So it might be possible to do what I did for Mac OS on x86 or PPC.  Mac OS is Unix underneath, so my 'script' might be a good starting point for someone sufficiently motivated...
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on November 10, 2022, 11:28:47 AM
The finished r6 release of PortablE is now on Aminet, and has support for this AROS cross-compiler on Linux :-)

Can anyone suggest a popular AROS news site where I could post this news?:
https://amigaworld.net/modules/news/article.php?storyid=8816

Or should I just create a new thread on this site?!?  (Which area though?)
Title: Re: AROS cross-compiler that runs on Linux?
Post by: deadwood on November 10, 2022, 11:37:21 AM

Or should I just create a new thread on this site?!?  (Which area though?)

Check the Support section. There is PortablE subsection there :)
Title: Re: AROS cross-compiler that runs on Linux?
Post by: PortablE on November 10, 2022, 12:03:13 PM
Check the Support section. There is PortablE subsection there :)
I tend to think of that as for supporting programming questions about PortablE... but I guess it would also make sense to announce a new version there as well :)
Title: Re: AROS cross-compiler that runs on Linux?
Post by: amigamia on November 10, 2022, 03:12:55 PM
The finished r6 release of PortablE is now on Aminet, and has support for this AROS cross-compiler on Linux :-)

Can anyone suggest a popular AROS news site where I could post this news?:
https://amigaworld.net/modules/news/article.php?storyid=8816

Or should I just create a new thread on this site?!?  (Which area though?)

forums.amiga.org, amigans.net, eab.abime.net, and it's already on arosworld.org
Title: Re: AROS cross-compiler that runs on Linux?
Post by: serk118uk on May 23, 2023, 05:04:07 AM
For anyone interested, the AROS cross-compilers I've built are now available to download from here:
http://cshandley.co.uk/crosscompilers/

This is great,

Chris can you compile aros 68k toolchain any chance (if you have bit of free time in hand)?  sorry i am pretty new to cross compilers....(i done my works native for ages, i decided to install ubuntu on my on one of my laptops, just so i can cross compile to all aros 68k,x86,x64)..

Thanks