How to generate binaries for multiple targets?

I want to generate binaries for multiple targets, i have tried this:
cargo r --target x86_64-unknown-linux-musl --target x86_64-unknown-linux-gnu
but it didn't work.

How can i pass these to cargo correctly ?

Is there an way to hard code this in cargo.toml or .cargo/config.toml as it's annoying to pass this long text to cargo ?
Something like:

target = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "i686-unknown-linux-gnu"]

I have checked those:

You can run cargo multiple times, one target at a time.


Thanks for help. In fact, i already know i can do this, i want to hard code the target builds in config.toml or any place else or at least pass all the targets in one command. Are there any future plans to support something like i this ?

The tracking issue hints it should work. It's probably just not fully implemented. Cargo currently is severely understaffed, unfortunately.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.