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

Profile rustflags are not propagated to target dependencies #15125

Open
stormshield-fabs opened this issue Jan 30, 2025 · 2 comments
Open

Profile rustflags are not propagated to target dependencies #15125

stormshield-fabs opened this issue Jan 30, 2025 · 2 comments
Labels
A-dependency-resolution Area: dependency resolution and the resolver C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-profile-rustflags Nightly: profile-rustflags

Comments

@stormshield-fabs
Copy link

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]
@stormshield-fabs stormshield-fabs added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jan 30, 2025
@stormshield-fabs
Copy link
Author

Possibly related to #12437

@epage epage added A-dependency-resolution Area: dependency resolution and the resolver Z-profile-rustflags Nightly: profile-rustflags labels Jan 30, 2025
@epage
Copy link
Contributor

epage commented Jan 30, 2025

If I'm reading the code correctly, resolving has no knowledge of the profile today

pub fn resolve_ws_with_opts<'gctx>(
ws: &Workspace<'gctx>,
target_data: &mut RustcTargetData<'gctx>,
requested_targets: &[CompileKind],
cli_features: &CliFeatures,
specs: &[PackageIdSpec],
has_dev_units: HasDevUnits,
force_all_targets: ForceAllTargets,
dry_run: bool,
) -> CargoResult<WorkspaceResolve<'gctx>> {

I'm not even sure if we can get that to work, at least if we were to also support this for profile overrides
https://doc.rust-lang.org/cargo/reference/profiles.html#overrides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-profile-rustflags Nightly: profile-rustflags
Projects
None yet
Development

No branches or pull requests

2 participants