I need to cross-compile a Rust program (x86-64 to arm64), but I'm working in environment where I have to use Debian's rust package (because company policy forbids curl | sh). Debian doesn't ship rustup, and rustup refuses to install if Debian's rust is installed anyway.
dpkg --add-architecture aarch64
apt-get build-dep -a aarch64 libstd-rust-dev
but apt says it's not installable
The following packages have unmet dependencies:
builddeps:rustc:aarch64 : Depends: libllvm4.0:aarch64 (>= 1:4.0.1-8) but it is not installable
Depends: rustc:aarch64 but it is not installable
Depends: zlib1g-dev:aarch64 but it is not installable
Depends: binutils:aarch64 (>= 2.26) but it is not installable or
binutils-2.26:aarch64 but it is not installable
Depends: gdb:aarch64 (>= 7.12) but it is not installable
I think you want apt-get install, not apt-get build-dep. apt-get build-dep X installs the dependencies needed to build X, not X itself. If you did want to build the standard library yourself, it would probably make more sense to build the compiler along with it.
No, the build is already running in a VM. I'm just not allowed to use curl | sh hack, anywhere, at all. Company Policy, and I'm not going to stick my neck out in defense of piping to bash.
I think you might have some version mismatch. You say your rustc is version 1.28.0-1, but that's not a version that is distributed by Debian. All Debian-packaged Rust packages have dfsg in the version. You'll need to obtain the ARM64 libstd from whomever packaged your Rust installation.
I put some effort into the original rustc Debian packaging to make this "just work". So just to summarise the above thread into one place, here's an example of cross-compiling for aarch64-unknown-linux-gnu (using Debian "testing"):
Note the Debian name for this architecture is arm64. In practice, you would combine the various apt install invocations for a slight increase in overall speed - I've broken them out only for clarity.
dpkg --add-architecture arm64
apt update
# Important part here is "libstd-rust-dev:arm64"
apt install cargo rustc libstd-rust-dev:arm64
If you need to install something that uses gcc/g++ from build.rs then you'll need a C cross-toolchain
Tell cargo to use the right linker when cross compiling. Note this is ~/.cargo/config, not in a specific project, and note cargo/rustc expect to link via gcc, not ld directly.