-
Notifications
You must be signed in to change notification settings - Fork 575
add -fsanitize=... flag if sanitizer is enabled in rust
#1672
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2026,6 +2026,12 @@ impl Build { | |
| self.add_inherited_rustflags(&mut cmd, &target)?; | ||
| } | ||
|
|
||
| if let Some(sanitizer) = self.getenv("CARGO_CFG_SANITIZE") { | ||
| let mut sanitizer_flag = OsString::from("-fsanitize="); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that rust and clang support So we probably want to map it to normal cc @madsmtm
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that we should parse the value here, and only emit the flag on tested configurations (Which also means I think we should have some sort of test for this in CI). |
||
| sanitizer_flag.push(sanitizer); | ||
| cmd.args.push(sanitizer_flag); | ||
| } | ||
|
|
||
| // Set flags configured in the builder (do this second-to-last, to allow these to override | ||
| // everything above). | ||
| for flag in self.flags.iter() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ordering here is a bit significant. I think it should be before
add_inherited_rustflags?(Probably also before
envflags("CFLAGS")above, butadd_inherited_rustflagsisn't, so let's not do that just yet).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe place it'd make sense to place in
add_default_flags?