Right now I'm hoping to do a robotics project in Swift on a Jetson Nano (which has an ARM Cortex-A57 CPU), which is constrained to using Ubuntu 18.04. There are no pre-built 5.8 .deb packages for 18.04, which is a bit of a pain because it means I have to build from source, and some of the build dependencies (e.g. cmake) have to be built from source to get a recent enough version. I've built the toolchain before, and I'm building it right now on the Jetson Nano, but it's taking a loooong time, despite building on an attached SSD (the OS runs off SD Card).
I was wondering if it would make sense to build the toolchain in an Ubuntu 18.04 Docker container (or maybe Parallels VM) on my M1 Max MacBook Pro, and then build a .deb of the toolchain that will properly install on any 18.04 ARM machine.
Do you think that would build faster?
Is there existing support for building .deb packages? How are the 20.04 and 22.04 packages built?
Another alternative would be to build a MacOS -> 18.04 cross-compile toolchain. I moved the x-compiler configs to focal a while back, but it ought to be pretty easy to flip back to the bionic configurations.
Is this even possible to do this? My experience with cross-compiling for Linux is I needed to do it from a Linux host.
Please do, I'm excited to see what you can do!
FWIW, my Jetson Nano was very old (original dev kit) and wouldn't work with the $180 carrier I bought from SeeedStudio the other day, so that's now a paperweight. I bought it so I could use an NVMe drive instead of SD Card to speed up my builds. Ended up having to use a USB adapter. That ended up being flaky (or the Nano USB is, as it seems to work on other devices), and I couldn't reliably write to it.
In the end I broke down and bought an Orin Nano Dev Kit (they just started shipping), so now I'm trying to get that up and running. It can run Ubuntu 20.04, so the cross-compiling need is reduced, but Jetson still requires the host machine to match the target OS, but the host has to be x86. Sigh.
That's to build a Swift toolchain that runs on macOS but generates ARM/Linux targets, right?
Is there a way to build the Swift toolchain on macOS that runs on ARM/Linux targets?
Unfortunately, I have to link against so many Nvidia binaries (and others, like OpenCV and Eigen), and the Nvidia SDK is an incredible black box mess. I don't think I'd be able to write code that targets Tegra (Jetson) on a Mac. But wow, that would be a dream.
Yes, that cross-compiles from Mac to R/Pi. To do that from mac to jetson should just be copying the libraries from the Jetson back to the mac and linking against them. "Just"
if you are going to do compilation on Arm/Linux, then I would think just installing @futurejones 's toolchains for bionic would be the ticket.
I'll probably try to copy the Nvidia shlibs back to the mac and see if I can't get cross-compilation going sometime soon. I'd really like to incorporate the Nvidia ML stuff into my SwiftNIO server code.
Being able to build binaries on my Mac and just copy the results over to the Jetson would be amazing, so once I get this Orin Nano up and running, I'll look into it. I probably need to go through their tedious hello world examples a few times to learn what gets built and where it goes before I bring Swift into the mix.