Skip to content

sanitizers: Implicitly disable mutually exclusive sanitizers - #161953

Open
PiJoules wants to merge 1 commit into
rust-lang:mainfrom
PiJoules:implicit-remove-incompatible-sanitizers
Open

sanitizers: Implicitly disable mutually exclusive sanitizers#161953
PiJoules wants to merge 1 commit into
rust-lang:mainfrom
PiJoules:implicit-remove-incompatible-sanitizers

Conversation

@PiJoules

Copy link
Copy Markdown
Contributor

This attempts to match clang's behavior of implicitly disabling sanitizers that are incompatible. Specifically, if a set of default sanitizers would be incompatible with ones provided by -Zsanitize=..., then clang (and now rust) will opt for keeping the ones specified via flags over the ones used as platform defaults. This helps maintain build consistency where we can just enable sanitizers via flags for both rust and c++ code without needing to manually disable others.

The driving reason for this is asan and safestack where we'd like to enable safestack by default for x86_64 fuchsia but disable it if -Zsanitize=address is passed (matching clang's behavior).

This commit also refactors all uses of self.opts.unstable_opts.sanitizer to go through the updated sanitizer() method.

AI: Gemini was used to help review the code and write some tests, but it did not generate the whole patch. I edited and reviewed this PR to the best of my ability before pushing for review.

This attempts to match clang's behavior of implicitly disabling
sanitizers that are incompatible. Specifically, if a set of default
sanitizers would be incompatible with ones provided by -Zsanitize=...,
then clang (and now rust) will opt for keeping the ones specified via
flags over the ones used as platform defaults. This helps maintain build
consistency where we can just enable sanitizers via flags for both rust and
c++ code without needing to manually disable others.

The driving reason for this is asan and safestack where we'd like to
enable safestack by default for x86_64 fuchsia but disable it if
-Zsanitize=address is passed (matching clang's behavior).

This commit also refactors all uses of `self.opts.unstable_opts.sanitizer`
to go through the updated `sanitizer()` method.

AI: Gemini was used to help review the code and write some tests, but it
did not generate the whole patch. I edited and reviewed this PR to the
best of my ability before pushing for review.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 28, 2026
@rustbot

rustbot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 20 candidates

@PiJoules

Copy link
Copy Markdown
Contributor Author

cc @ilovepi just in case I'm missing something here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants