Skip to content

[feat] easy LLVM_PROFILE_FILE config for cargo test #15186

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

Closed
loynoir opened this issue Feb 14, 2025 · 2 comments
Closed

[feat] easy LLVM_PROFILE_FILE config for cargo test #15186

loynoir opened this issue Feb 14, 2025 · 2 comments
Labels
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.

Comments

@loynoir
Copy link

loynoir commented Feb 14, 2025

Problem

Below workspace config leads to /path/to/project/crates/hello/target/xxx under each member cargo toml dir, but not /path/to/project/target/xxx under top cargo toml dir.

/path/to/project/.cargo/config.toml

[env]
LLVM_PROFILE_FILE = "target/xxx"

Below workspace config leads to target/xxx under top cargo toml dir, but it is a hard coded config.

/path/to/project/.cargo/config.toml

[env]
LLVM_PROFILE_FILE = "/path/to/project/target/xxx"

Proposed Solution

/path/to/project/.cargo/config.toml

[env]
LLVM_PROFILE_FILE = "${CARGO_CONFIG_PROJECT_CWD}/target/xxx"

Or maybe just add a new field ONLY for cargo test, as LLVM_PROFILE_FILE is not used in cargo build

[unstable]
profile-env-llvm-profile-file = true

[profile.test]
LLVM_PROFILE_FILE = "${CARGO_CONFIG_PROJECT_CWD}/target/xxx"

Notes

related env design

https://code.visualstudio.com/remote/advancedcontainers/environment-variables

@loynoir loynoir 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 Feb 14, 2025
@loynoir loynoir changed the title [feat] .cargo/config.toml [env] should support template string [feat] easy LLVM_PROFILE_FILE config for cargo test Feb 14, 2025
@epage
Copy link
Contributor

epage commented Feb 14, 2025

You can use the relative field to make an env variable be prefixed with the parent of the config dir, see https://doc.rust-lang.org/cargo/reference/config.html#env

@weihanglo
Copy link
Member

Variable expansion has been discussed in #10789, and has some relevance in #12193. However, as epage has mentioned, the relative field should do the trick for you, so going to close as resolved and favor #10789 for the expansion discussion.

If the relative field doesn't work, please comment below and let us know what went wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

3 participants