Skip to content

Profile rustflags are not propagated to target dependencies #15125

Open
@stormshield-fabs

Description

@stormshield-fabs

Problem

When using the profile-rustflags Cargo feature with a --cfg flag, dependency resolution appears to be performed without the additional flag.

Steps

Minimal reproduction:

# Cargo.toml

cargo-features = ["profile-rustflags"]

[package]
name = "cargo-profile-rustflags-bug"
version = "0.1.0"
edition = "2021"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(unstable)'] }

[target.'cfg(unstable)'.dependencies]
thiserror = "1"

[profile.dev-unstable]
inherits = "dev"
rustflags = ["--cfg=unstable"]
// src/main.rs

#[cfg(unstable)]
use thiserror;

fn main() {
    println!("Hello, world!");
}
  • cargo check and RUSTFLAGS="--cfg=unstable" both work fine
  • cargo check --profile=dev-unstable fails (no external crate thiserror).

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.86.0-nightly (cecde95c1 2025-01-24)
release: 1.86.0-nightly
commit-hash: cecde95c119a456c30e57d3e4b31fff5a7d83df4
commit-date: 2025-01-24
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ubuntu 22.4.0 (jammy) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Z-profile-rustflagsNightly: profile-rustflags

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions