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

Encoded CARGO_TARGET_<triple>_RUSTFLAGS just like CARGO_ENCODED_RUSTFLAGS? #14398

Open
MarijnS95 opened this issue Aug 14, 2024 · 3 comments
Open
Labels
A-rustflags Area: rustflags C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@MarijnS95
Copy link

Problem

According to https://doc.rust-lang.org/cargo/reference/environment-variables.html there's CARGO_ENCODED_RUSTFLAGS to properly escape independent arguments with separators, when those arguments themselves (i.e. file paths) already contain spaces. However, no similar environment argument appears to exist for CARGO_TARGET_<triple>_RUSTFLAGS so that I cannot set up per-target RUSTFLAGS containing arguments with spaces.

Proposed Solution

Would it be possible to add CARGO_TARGET_<triple>_ENCODED_RUSTFLAGS?

Notes

No response

@MarijnS95 MarijnS95 added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Aug 14, 2024
@epage epage added A-rustflags Area: rustflags S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Aug 14, 2024
@weihanglo
Copy link
Member

If you have access to Command, config command line override is available. See a relevant discussion #14381 and other alternatives in #3686 (comment).

@epage
Copy link
Contributor

epage commented Oct 22, 2024

See also #10462

@ehuss
Copy link
Contributor

ehuss commented Oct 22, 2024

I am slightly inclined to close, given that there are a number of alternatives listed in #3686 (comment).

I can see how it seems like there is a correlation between RUSTFLAGS and CARGO_TARGET_*_RUSTFLAGS, and thus would have the same extension as CARGO_ENCODED_RUSTFLAGS and CARGO_TARGET_*_ENCODED_RUSTFLAGS, but that's not how it works in cargo. The target flags are driven by the config system, whereas RUSTFLAGS (and CARGO_ENCODED_RUSTFLAGS) is a separate thing.

I'm a little concerned about the complexity of the number of ways that rustflags are set, and the interaction with things like target-applies-to-host and host-config.

I also have a slight inclination to lean on something like the undocumented -Z advanced-env, since that would be a general-purpose solution that would address all TOML config values. However, I would strongly encourage using --config instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustflags Area: rustflags C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

4 participants