rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.53k stars 2.38k forks source link

allow setting `codegen-backend` per-target #13001

Closed flippette closed 9 months ago

flippette commented 9 months ago

Problem

i'm currently testing the codegen-backend option, but every target besides x86_64-unknown-linux-gnu does not work with cranelift. i would like to be able to select the backend for each individual target, or even better, for each cfg() target.

Proposed Solution

add a codegen-backend field to [target.<triple>] and [target.<cfg-expr>] sections.

Notes

p.s. would also be nice if we could somehow do something akin to

[target.x86_64-unknown-linux-gnu.profile.dev]
codegen-backend = "cranelift"
weihanglo commented 9 months ago

I consider this as a subset of https://github.com/rust-lang/cargo/issues/4897, so close in favor of that.

In the mean time, you can use "custom profile" instead. A bit more typing but should work.

Feel free to add more comments here or there if you have any further question :)