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:
[build]
target = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "i686-unknown-linux-gnu"]
I have checked those:
Greetings Rustaceans,
After thinking a lot about it, I started porting a little software I made initially in Go, to Rust. Let's say I started having real issues with the language, the decisions that were made, and the general behavior "embrace it or get out, but don't bother us ". So, Rust.
The development is going quite well, pretty sure the quality of the code is not that good, but I'm learning a lot, I love the design choices that were made (sum types feel like a blessing, clap puts any CLIβ¦
rust-lang:master
β weihanglo:multitarget-config
opened 06:33PM - 11 Mar 22 UTC
### What does this PR try to resolve?
Support `-Zmultitarget` in cargo config⦠. This patch also takes care of backward compatibility, so basically it means that `build.target` accepts input from both string and array.
https://github.com/rust-lang/cargo/issues/8176#issuecomment-733043914
```toml
[unstable]
multitarget = true
[build]
target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
```
### How should we test and review this PR?
Several new tests in `multitarget`.
I didn't add tests for all compile modes, since doing that would produce too many duplications. If anyone thinks it necessary to avoid potential regression please tell me.
### Unresolved questions
- How to handle `CARGO_BUILD_TARGET` environment variable? Should it remain accepting a single target value only and hope [`advanced-env`] save us?
- This unstable feature on CLI has landed for a while. What are other difficulties blocking it from stabilizing?
[`advanced-env`]: https://github.com/rust-lang/cargo/issues/7406
opened 10:54PM - 24 Apr 20 UTC
closed 09:49PM - 29 Apr 20 UTC
C-feature-request
**Describe the problem you are trying to solve**
When building rust code for β¦ an Android app, it is common to build for multiple targets, e.g. (ARM, x86) β (32 bits, 64 bits). While `cargo build` is already parallel in some sense, LTO (or last step compilation in general) is single threaded and can take a long time to run. It makes sense to use up the CPU resources for building other targets.
**Describe the solution you'd like**
Multi-target build with `--target=armv7-linux-androideabi --target=aarch64-linux-android ...`.
**Notes**
See also plugin: https://github.com/mozilla/rust-android-gradle
opened 07:34PM - 28 Apr 20 UTC
closed 07:39PM - 17 Jul 22 UTC
A-cross-compiling
T-cargo
C-tracking-issue
finished-final-comment-period
disposition-merge
to-announce
This is intended to be a tracking issue for `-Zmultitarget` being implemented in⦠https://github.com/rust-lang/cargo/pull/8167. This feature allows passing the `--target` flag multiple times to Cargo to build code simultaneously for multiple targets. This was originally requested in https://github.com/rust-lang/cargo/issues/8156 and https://github.com/rust-lang/cargo/issues/3913.
Currently the semantics of `-Zmultitarget` is that it simply allows passing `--target` multiple times (2 or more) to Cargo. Cargo recognizes this as doing what it was already doing, only now for multiple targets instead of just a single target. Internally Cargo's unit graph should still have all the edges drawn correctly and whatnot.
kornel
June 15, 2023, 3:00pm
2
You can run cargo
multiple times, one target at a time.
2 Likes
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 ?
kornel
June 20, 2023, 12:34am
4
The tracking issue hints it should work. It's probably just not fully implemented. Cargo currently is severely understaffed, unfortunately.
1 Like
system
Closed
September 18, 2023, 12:34am
5
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.