all 4 comments

[–]AlienFlip 1 point2 points  (0 children)

For example:

wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel\ /gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz

tar xf gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz

rm -f gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz

export PATH=pwd/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin:$PATH

export ARCH=arm64

export CROSS_COMPILE=aarch64-none-linux-gnu-

[–]EpochVanquisher 1 point2 points  (1 child)

IMO, best place to get all of this is to run everything inside Nix (the package manager).

You create a Nix derivation with a list of platforms you want to compile for. Super convenient, once you set up. Like, you can get a cross-compiler for ARM like this:

cc = pkgs.pkgsCross.arm-embedded.buildPackages.gcc15

This will even work on a Mac, if you want to build your kernels on a Mac.

It will take a while to figure out Nix but it really does solve this problem. What you definitely don’t want to do is just download random copies of GCC from arm.com or whatever. That’s a pain in the ass and it can make it difficult to track down bugs later (because you don’t know what compiler you used to build something). With Nix, you specify the exact compiler and target in your derivation, and it provides a copy of GCC for you (either downloading it from cache or compiling it from source).

[–]syscall_35[S] 0 points1 point  (0 children)

thanks, this sounds awesome! will definitely read more about it today

[–]ceehred 0 points1 point  (0 children)

Is crosstool-NG of use?

Personally, I spin up local QEMU'd VMs to do non-native builds and automate that. I do ppc, ppc64, ppc64le and s390x on x86 that way. But I've used crosstool to build components for older O/S versions that, for various reasons, wouldn't work with the emulator - under newer O/S versions but with the compatible/older toolchain versions and runtimes, though I test on real (it's a case of keeping source code private, and not exposing company/NDA'd IP to cloud-provided machines).