I hope all is well with everyone. I have been struggling with attempting the following and would appreciate insight (please consider that I am rather new to Rust so patience is appreciated):
I have an offline system that I would like to cross-compile Rust code on. Whilst I could plop files to/from the offline system, the system must be offline.
Rust does offer an offline installer for such an offline system, but there is a catch: there is no rustup as part of that offline installer as Rustup is heavily reliant on internet access. This is proving to be an issue with cross-compilation as Rustup is typically used to acquire a desired target.
Moreover, this is what I would like insight on: how can I add a target for cross-compiling on an offline system that does not have Rustup, if it is even possible? If it is a matter of having rustup on a seperate online system, getting the target and then moving files to the offline system then I would appreciate guidance on what files to grab and how to point to them in the offline system?
If you read the stable manifest, then you can find the url for pkg.rust.target.* for your host toolchain, and pkg.rust-std.target.* for the standard library for your cross-compilation targets. Extract those and run their install script into a common --prefix, and you'll have a sysroot just like what rustup installs.
Apologies for the late reply, finally got time to get back around to this. For reference, the offline server is x86 and I would like to cross-compile to arm.
So I downloaded the desired targets from the stable manifest and ran their install scripts. It appears to uninstall whatever cargo I currently have and then installs the cargo I am installing.
Howbeit, when I attempt any commands with cargo I will now get "cannot execute binary file: Exec format error" message. I assume it is because the cargo I downloaded and installed is of another architecture and running it install scripts replaces the proper cargo.
Should I be choosing a different path for cargo when I run the install script and if so then what additonal steps am I missing? Apologies in advance if this has already been covered, I am new to cross-compiling so I am learning and getting confused as I go haha
So it appears that with the "relocations in generic ELF" errors, those were because the linker is x86 and I have to use arm, so I proceeded to add gcc-arm-linux-gnueabihf except for some silly reason, it has to be called "arm-linux-gnueabihf-gcc" in config.toml. Regardless, I can now build successfully!
Thanks everyone! I will mark the original answer from @cuviper as the solution as that was what started to lead me on the right path. I appreciate the help and I hope everyone has an awesome day!