I am attempting to cross compile on host x64 for target arm using llvm / clang. I know a sysroot and gcc-toolchain are required, and their flags point to a gcc compiler for the target platform.
I’m confused whether the gcc toolchain should be one that runs on the target arch? Or should it be a cross toolchain that can run on the host arch but compile for the target arch?
I have cross compiled a simple hello world using a target arch gcc toolchain as the sysroot. But, had to use llvm lld for linking. I believe this may be related to not being able to run the gcc toolchains provided ld?
GCC is a compiler and clang is a different compiler. You only need one of the two. You might use GNU binutils to link the output of the compiler, but that is not GCC.
Whatever programs you run during cross compilation must be built for the build system (x64), and be configured to allow targeting the target system (ARM).
P.S. Maybe you should look at my project: https://github.com/DavidEGrayson/nixcrpkgs . It shows how to cross-compile on x64 Linux for ARM Linux using GCC (not clang).