AROS cross-compiler that runs on Linux?

PortablE · 3073

deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #15 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



PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #16 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.
« Last Edit: August 27, 2022, 03:19:10 PM by PortablE »

ChrisH
--
Author of the PortablE programming language.


PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #17 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.
« Last Edit: November 06, 2022, 06:44:30 AM by PortablE »

ChrisH
--
Author of the PortablE programming language.


deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #18 on: August 29, 2022, 11:39:00 PM
Thanks for publishing the script. It will be useful to other developers. :)



PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #19 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.
« Last Edit: November 06, 2022, 06:44:08 AM by PortablE »

ChrisH
--
Author of the PortablE programming language.


PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #20 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/

ChrisH
--
Author of the PortablE programming language.


PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #21 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 "/" .

ChrisH
--
Author of the PortablE programming language.


amigamia

  • Administrator
  • Member
  • *****
    • Posts: 134
    • Karma: +49/-0
    • AROS World
Reply #22 on: November 06, 2022, 07:05:28 AM
Nice job Chris. Thank you!

Any chance you can make one for Mac OS X?
« Last Edit: November 06, 2022, 07:15:45 AM by amigamia »



PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #23 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...

ChrisH
--
Author of the PortablE programming language.


PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #24 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?)

ChrisH
--
Author of the PortablE programming language.


deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #25 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 :)



PortablE

  • Newbie
  • *
    • Posts: 25
    • Karma: +49/-0
    • The homepage of Chris Handley
Reply #26 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 :)

ChrisH
--
Author of the PortablE programming language.


amigamia

  • Administrator
  • Member
  • *****
    • Posts: 134
    • Karma: +49/-0
    • AROS World
Reply #27 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


serk118uk

  • Member
  • ***
    • Posts: 187
    • Karma: +67/-0
Reply #28 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

Lets Build Not Destroy...