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

Export sanitizer settings in cargo CLI #14523

Open
Kixunil opened this issue Sep 9, 2024 · 4 comments
Open

Export sanitizer settings in cargo CLI #14523

Kixunil opened this issue Sep 9, 2024 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@Kixunil
Copy link

Kixunil commented Sep 9, 2024

Problem

Using sanitizers currently requires RUSTFLAGS this is not discoverable.

Proposed Solution

Expose sanitizer settings in cargo's CLI.

Notes

I've opened this as requested in #12739 (comment)

@Kixunil Kixunil 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 Sep 9, 2024
@epage epage added the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Sep 9, 2024
@epage
Copy link
Contributor

epage commented Sep 9, 2024

Could you provide more details on this as it doesn't provide enough background to understand requirements. Which sanitizer settings? How do you use them?

@epage epage removed the S-triage Status: This issue is waiting on initial triage. label Sep 9, 2024
@Kixunil
Copy link
Author

Kixunil commented Sep 9, 2024

For instance, we currently set these flags in CI: RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes'

Having something like cargo test --sanitize=address would be more discoverable and easier to type.

@epage
Copy link
Contributor

epage commented Sep 9, 2024

As in you'd want cargo test --sanitize=address to mean RUSTFLAGS='-Zsanitizer=address or RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes'?

If the latter, why is that specific policy the one we should set on users behalf? It especially seems worrisome to override the linker as that would be surprising.

Could you go into:

How do you use them?

What is important for us to understand is the requirements behind this. You suggested this to be in the CLI but is that the right place? Would this be better as a profile config? Understanding how people would expect to use it will help in understanding how to abstract these rustc features.

@Kixunil
Copy link
Author

Kixunil commented Sep 9, 2024

I'm not super knowledgeable about sanitizer specifics but IIRC without the linker flag it doesn't work at all and without -Cforce-frame-pointers=yes the backtraces are messed up and it's hard to understand what went wrong, so it likely should be the defaul.

How do you use them?

Each sanitizer is ran in a separate process (because it requires different recompilation). I think it could work with custom profiles, though requiring everyone to set the same profiles (possibly polluting Cargo.toml) seems too much to me. If only one sanitizer existed I guess I would be more open to it but since there's multiple of them and people likely want to use more than one it's quite some boilerplate.

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-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants