Simply compiling with gcc on a single architecture (no cross compile) requires more than one binary. In my experience (20 years of embedded work), cross compiling is hard not because of the compiling, but because of the linking. The linker has to know where all your target architecture libraries are so it can link your executable.
That said, this is getting easier and easier to do. I think this is because debian packages have to be architecture specific just for Intel architectures now, to handle both x86 (32 bit) and x86_64 ISAs. Once you have the environment, creating and using a different compiler executable is the easy part.
It's one reason to favor Go over Rust for a particular project, It's much easier to set GOOS and GOARCH and run go than to download and install a complete target with rustup assuming the target is actually available to install.
Could cranelift or similar allow rust to support multiple targets easier than llvm?
Re:Porting Alpine Linux to RISC-V
by steveklabnik on Friday December 21, 2018 @11:31AM
(#18734358)
I don't know, but I'm also interested!
I wonder, could the GNU toolchain devs be convinced to add support for multiple hosts/targets in one binary? Do they have a philosophical objection to it? Or is it simply that it is a lot of work and nobody has done it? It would make cross-compiling with the GNU toolchain a lot easier.