Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo doesn't execute per-target runner for target set in Cargo.toml (per-package-target) #10779

Closed
elaforma opened this issue Jun 22, 2022 · 2 comments
Labels
C-bug Category: bug Z-per-package-target Nightly: per-package-target

Comments

@elaforma
Copy link

Problem

I'm working on an embedded Rust project. In order to be able to run it using cargo run, I use the target.<triplet>.runner attribute in .cargo/config.toml to launch an emulator. The target also used to be set in config.toml.

Recently, in order to use the xtask pattern, I decided to try out the per-package-target feature (#9406). I removed the target from config.toml and added a forced-target field to my Cargo.toml. Unfortunately, now cargo no longer executes my runner, instead trying to execute the binary directly (which, of course, doesn't work).

Cargo is building for the correct target, but for some reason not taking this into account when deciding whether or not to use the runner. Manually passing the --target option solves this issue, but that's exactly what I'm trying to avoid by using this feature.

Steps

  1. Create a #![no_std] project for a different target triplet
  2. Specify a runner for this triplet in .cargo/config.toml
  3. Use the per-package-target cargo feature and the default-target or forced-target keys in Cargo.toml to specify the triplet
  4. cargo run without a --target option
  5. Observe that cargo is building for the correct triplet, but not using the runner.

Possible Solution(s)

There are multiple other issues (e.g. the -Zbuild-std one in #9451) that suggest cargo assumes it's building for the host during various stages of the build if no --target flag is passed. I don't know enough about the internals of cargo to tell if this is what's happening here.

Notes

No response

Version

cargo 1.63.0-nightly (8d42b0e87 2022-06-17)
@elaforma elaforma added the C-bug Category: bug label Jun 22, 2022
@ehuss ehuss added the Z-per-package-target Nightly: per-package-target label Jun 23, 2022
@4LT
Copy link

4LT commented Jun 27, 2022

Possible duplicate of #10518 ?

@ehuss
Copy link
Contributor

ehuss commented Jun 27, 2022

Ah, yes, closing as a duplicate of #10518.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Z-per-package-target Nightly: per-package-target
Projects
None yet
Development

No branches or pull requests

3 participants