Easy cross-compiling
#1
Smile 
Hey all, I created some Docker images to make cross-compiling for Linux arm64 easy. I've successfully used my Macbook Pro to compile software for my Pinebook Pro, and it was quite a bit faster than compiling on the PBP itself. Thought others might find the project useful, but I'm also looking for testers. 

The following instructions assume you have a PBP and a non-PBP running on the same LAN, and that the non-PBP has docker installed.

If compiling for Manjaro, run this on your non-PBP:

Code:
docker run -p 3708:3708 elijahru/distcc-cross-compiler-host-archlinux:latest-amd64

If compiling for Debian, run this on your non-PBP:

Code:
docker run -p 3608:3608 elijahru/distcc-cross-compiler-host-debian-buster:latest-amd64

On your PBP, install distcc via pacman or apt and update your PATH so that the distcc wrappers for gcc, g++, etc are found first.

Run this on your Manjaro PBP (assuming you use bash):

Code:
sudo pacman -S distcc
echo 'export PATH=/usr/lib/distcc/bin:$PATH' >> ~/.bash_profile
# Replace X.Y.Z with the LAN IP address or hostname of your non-PBP
echo 'export DISTCC_HOSTS=X.Y.Z:3708' >> ~/.bash_profile
source ~/.bash_profile

Or run this on your Debian PBP:

Code:
sudo apt-get install distcc
echo 'export PATH=/usr/lib/distcc:$PATH' >> ~/.bash_profile
# Replace X.Y.Z with the LAN IP address or hostname of your non-PBP
echo 'export DISTCC_HOSTS=X.Y.Z:3608' >> ~/.bash_profile
source ~/.bash_profile

Confirm that the executable found by running which gcc on your PBP is in /usr/lib/distcc:

Now any C / C++ compilation on the PBP will be transparently offloaded to the non-PBP. You can verify this by observing the distccd output on the non-PBP.

If the non-PBP can't be reached (for instance, if you are away from your LAN, or the docker isn't running), compilation will be performed locally.

Please let me know if you run into any issues.

Source code and documentation for the docker images: https://github.com/elijahr/distcc-cross-compiler
Cheers!
#2
This is supercool, thanks!
#3
Yes, this is also something I want to try - thank you for doing the Docker work...

I have many many ARM computers, and a few lower-middle end ThinkPad systems. However, for everything 'pretty' or that needs horsepower, we use iMac Pro 27" setups... I have 2 of those in the house.

So I'm excited, when compiling something on the larger side that I'm working on, to attempt to use your setup. I really appreciate it and gave you some rep - its deserved.

I dunno if I'm nutso, but I'd like a section of the PBP wiki, heck this could even be tweaked for other boards - but ... these should be on a 'at your own risk' or 'non-supported' section for future use and to document these cool ideas.

Great job - I think I'll even hunt and find SOMETHING to run thru this setup today. Gonna get my iMac pulling the carraige for my PBP.. thank you.
-----
 pAULIE42o
.  .  .  .   .  . .
/s
#4
(09-25-2020, 11:03 AM)Paulie420 Wrote: I have many many ARM computers, and a few lower-middle end ThinkPad systems. However, for everything 'pretty' or that needs horsepower, we use iMac Pro 27" setups... I have 2 of those in the house.

You could set up a build farm of these dockers if you wanted to try distributing compilation to multiple amd64 machines. The DISTCC_HOSTS environment variable can contain multiple host entries, separated by spaces, something like:

Code:
DISTCC_HOSTS="<ip1>:<port> <ip2>:<port> <ip3>:<port>"

See the distcc man page for more details on that environment variable. I think you can choose different distribution strategies and stuff.
#5
(09-25-2020, 11:52 AM)elijahr Wrote:
(09-25-2020, 11:03 AM)Paulie420 Wrote: I have many many ARM computers, and a few lower-middle end ThinkPad systems. However, for everything 'pretty' or that needs horsepower, we use iMac Pro 27" setups... I have 2 of those in the house.

You could set up a build farm of these dockers if you wanted to try distributing compilation to multiple amd64 machines. The DISTCC_HOSTS environment variable can contain multiple host entries, separated by spaces, something like:

Code:
DISTCC_HOSTS="<ip1>:<port> <ip2>:<port> <ip3>:<port>"

See the distcc man page for more details on that environment variable. I think you can choose different distribution strategies and stuff.

Hmmm... I think I'll try to get one working first; however its cool to know that the sky's the limit. Heck, I know that its nothing [super] new and that I could be using Docker for many cool things with the type of computing I do - but thanks for 'reminding' us...

I do think using my powerful iMac's for big things on ARM chipsets is smart... and I really hadn't thought about how that could be possible. I always kinda sandbox each architecture off - and then bam you remind me that we can drive our devices the way that works for us.

Anyway, I'll start at just getting it working. I don't know that I have anything that would require two powerhouses - however speeding up the ARM building process sounds great.
-----
 pAULIE42o
.  .  .  .   .  . .
/s


Possibly Related Threads…
Thread Author Replies Views Last Post
  compiling (large) programs on pbp pine76 8 5,014 09-25-2020, 10:24 AM
Last Post: e-minguez
  Make it easy? wdt 0 1,321 09-10-2020, 10:05 PM
Last Post: wdt
  Frequent segfaults etc. while compiling mfritsche 13 10,743 07-15-2020, 04:12 PM
Last Post: mfritsche
  Hate Manjaro - Easy Ubuntu Install? PaulMcGuinness 8 7,024 06-07-2020, 04:40 AM
Last Post: flyingscorpio
  Compiling WireGuard (and other things requiring linux-headers) on Debian+Mate Dendrocalamus64 1 2,707 04-02-2020, 07:07 PM
Last Post: Dendrocalamus64

Forum Jump:


Users browsing this thread: 1 Guest(s)