| I’m using Bazel to build my rust project (Using the rules_rust rules) and it’a become quite a pain to use in concert with docker. This is not a complaint about Bazel specifically, its fantastic, and easily my favourite build system bar none. However it cannot cross compile Rust. This means if I’m developing on my MacBook, and I want to compile a Rust binary and put it in an Ubuntu docker container, I can’t do it on my host machine. I need to copy the source into the container and build it there, using multistage builds. But this is -extremely slow- because it cannot take advantage of Rusts build caching. I’m talking 10-15 minutes for my small Rust project. Has anyone run into this? How do you work around it? I’ve considered running a Bazel remote execution server on a local Ubuntu VM, but this feels like so much extra complexity just to use Rust, Bazel and containers. |
Apple ld doesn't support Linux as an output target, so you need to use GNU ld or LLVM lld instead.
Code examples at https://john-millikin.com/notes-on-cross-compiling-rust#baze...