Skip to content

per-package-target ignores target configuration #14291

Open
@mamins1376

Description

@mamins1376

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configurationArea: cargo config files and env varsC-bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-per-package-targetNightly: per-package-target

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions