According to various guides on cross-compiling Rust I need to set something like this in .cargo/config:
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
In my case I am cross compiling for Linux on Mac. This is fine, but I'd also like to be able to build the code natively on Linux (i.e. not cross-compiling). In that case surely the target is still x86_64-unknown-linux-musl, but I don't want to override linker then.
I guess you can probably do this using a custom build.rs, but is there any way to do this from .cargo/config? I thought you'd be able to do something like this:
[target.'cfg(all(host_os = "macos", target_os = "linux"))']
linker = "x86_64-linux-musl-gcc"
But there is no host_os.