How can I compile a binary crate to be executed, as a command (i.e bin/hello_world) , in Heroku which uses an Ubuntu distribution? I imagine that is setting a value for the flag --target maybe, but I am helpless as I don't know which name should I use.
I tried to use emk's buildpack among others, but my existing buildpacks are incompatible (the main app is a Rails one) with these ones.
Rust binaries are statically linked by default and can usually be compiled on one Linux machine and run on a different one without much difficulty. There are a couple of caveats, however:
The default Linux toolchain links Rust binaries dynamically to glibc (because glibc doesn't support static linking). This may cause problems if the host machine uses a newer glibc than the target machine. You can solve this by compiling on a distro whose glibc version is equal to or lower than your target environment, or by using the musl target which links statically to the MUSL libc.
If you have dependencies that link to system libraries (for example the openssl-sys crate), these might also use dynamic linking. You’ll need to make sure any dynamically-linked C libraries are installed on your target machine, just as they are on your host machine. Or in some cases you can configure these dependencies to link statically. See the openssl docs for example.