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

per-package-target ignores target configuration #14291

Open
mamins1376 opened this issue Jul 23, 2024 · 3 comments
Open

per-package-target ignores target configuration #14291

mamins1376 opened this issue Jul 23, 2024 · 3 comments
Labels
A-configuration Area: cargo config files and env vars C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. Z-per-package-target Nightly: per-package-target

Comments

@mamins1376
Copy link

Problem

Using per-package-target without an explicit --target results in configuration specified in .cargo/config.toml keys relevant to the current compilation target being ignored, while specifying the same target explicitly would respect configuration.

Since I discovered this during development of an embedded arm project, I am using the same target (thumbv7em-none-eabihf) here, but I doubt that it matters.

Cargo.toml:

cargo-features = ["per-package-target"]

[package]
name = "per-package-target-run"
version = "0.1.0"
edition = "2021"
default-target = "thumbv7em-none-eabihf"

.cargo/config.toml:

[target.thumbv7em-none-eabihf]
runner = "echo"

Implicitly:

$ cargo run
   Compiling per-package-target-run v0.1.0 (.../per-package-target-run)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/thumbv7em-none-eabihf/debug/per-package-target-run`
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)

Explicitly:

$ cargo run --target thumbv7em-none-eabihf
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `echo target/thumbv7em-none-eabihf/debug/per-package-target-run`
target/thumbv7em-none-eabihf/debug/per-package-target-run

Steps

  1. Download and extract the attached project: per-package-target-run.tar.gz
  2. cd and compare running cargo run with and without --target ....

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.81.0-nightly (154fdac39 2024-07-07)
release: 1.81.0-nightly
commit-hash: 154fdac39ae9629954e19e9986fd2cf2cdd8d964
commit-date: 2024-07-07
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.8.0-DEV (sys:0.4.73+curl-8.8.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Arch Linux [64-bit]
@mamins1376 mamins1376 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 23, 2024
@epage epage added Z-per-package-target Nightly: per-package-target A-configuration Area: cargo config files and env vars labels Jul 23, 2024
@soloturn
Copy link
Contributor

soloturn commented Jul 24, 2024

why having per package targets does make sense, in general?

@mamins1376
Copy link
Author

why having per package targets does make sense, in general?

In my workspace, there is one package for the ARM firmware, and one package for host app which communicates with the hardware running that firmware, plus one other shared crates for protocol description.

This kind of situation is common in embedded and/or microcontroller projects.

@weihanglo
Copy link
Member

See #14833

Several places calling BuildConfig::requested_kinds don't consider anything from default-target or forced-target, so some target platform info may be missing.
...
The fix for the latter should be a bit easier. Managing all calls to requested_kinds through on a new requested_kinds method, which reuse a similar logic like this one. This should resolve the issue if only your top-level primary package has forced-target specified.

My feeling is that the scenario of the per-package-target feature is a bit overlapped. I am not sure whether we should reorganize them or have both separately.

@weihanglo weihanglo added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-triage Status: This issue is waiting on initial triage. labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. Z-per-package-target Nightly: per-package-target
Projects
None yet
Development

No branches or pull requests

4 participants