Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,12 @@ impl Build {
self.add_inherited_rustflags(&mut cmd, &target)?;
}

if let Some(sanitizer) = self.getenv("CARGO_CFG_SANITIZE") {
Copy link
Copy Markdown
Contributor

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, but add_inherited_rustflags isn't, so let's not do that just yet).

Copy link
Copy Markdown
Contributor

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?

let mut sanitizer_flag = OsString::from("-fsanitize=");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that rust and clang support hwaddress sanitizer, but gcc doesn't.

So we probably want to map it to normal address right?

cc @madsmtm

Copy link
Copy Markdown
Contributor

@madsmtm madsmtm Feb 11, 2026

Choose a reason for hiding this comment

The 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() {
Expand Down