Skip to content

Accumulate multiple -Zsanitizer target modifiers#157788

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
PiJoules:multiple-sanitizer-flags
Jun 18, 2026
Merged

Accumulate multiple -Zsanitizer target modifiers#157788
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
PiJoules:multiple-sanitizer-flags

Conversation

@PiJoules

@PiJoules PiJoules commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

View all comments

When passing multiple -Zsanitizer flags to the compiler (e.g., -Zsanitizer=address -Zsanitizer=shadow-call-stack), the options parser was overwriting the previous values in target_modifiers instead of accumulating them. This resulted in only the last sanitizer being recorded in the crate metadata's target modifiers, even though the frontend correctly enabled all of them. The only way to provide multiple sanitizers is to combine them into a comma-separated list passed to a single -Zsanitizer= flag, but this doesn't fit very well into the GN build system where different targets may pass different combinations of sanitizer flags.

Consequently, this caused spurious "incompatible target modifiers" ABI mismatch errors when linking against dependencies compiled with accumulated flags.

Fix this by entry-modifying the target_modifiers map to accumulate the sanitizers as a comma-separated list when the option is sanitizer.

@rustbot

rustbot commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in tests/codegen-llvm/sanitizer

cc @rcvalle

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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 Jun 11, 2026
@rustbot

rustbot commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 73 candidates
  • Random selection from 20 candidates

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 11, 2026
@PiJoules PiJoules force-pushed the multiple-sanitizer-flags branch from 17905c2 to fe9caed Compare June 11, 2026 20:33
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 11, 2026
@PiJoules PiJoules force-pushed the multiple-sanitizer-flags branch 2 times, most recently from b1fec2d to 0dcc9d6 Compare June 11, 2026 20:48
@rustbot

This comment has been minimized.

@PiJoules PiJoules force-pushed the multiple-sanitizer-flags branch from 0dcc9d6 to 76f555b Compare June 11, 2026 20:59
@rustbot

rustbot commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/cargo

cc @ehuss

Some changes occurred in src/tools/enzyme

cc @ZuseZ4

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` labels Jun 11, 2026
@rustbot

This comment has been minimized.

@PiJoules PiJoules force-pushed the multiple-sanitizer-flags branch from 76f555b to 1148afe Compare June 11, 2026 21:00
Comment thread compiler/rustc_session/src/options.rs Outdated
Comment thread tests/codegen-llvm/sanitizer/multiple-sanitizers.rs
@petrochenkov

Copy link
Copy Markdown
Contributor

@rustbot author

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2026
@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit dad6583 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 16, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 16, 2026
… r=petrochenkov

Accumulate multiple -Zsanitizer target modifiers

When passing multiple `-Zsanitizer` flags to the compiler (e.g., `-Zsanitizer=address -Zsanitizer=shadow-call-stack`), the options parser was overwriting the previous values in `target_modifiers` instead of accumulating them. This resulted in only the last sanitizer being recorded in the crate metadata's target modifiers, even though the frontend correctly enabled all of them. The only way to provide multiple sanitizers is to combine them into a comma-separated list passed to a single `-Zsanitizer=` flag, but this doesn't fit very well into the GN build system where different targets may pass different combinations of sanitizer flags.

Consequently, this caused spurious "incompatible target modifiers" ABI mismatch errors when linking against dependencies compiled with accumulated flags.

Fix this by entry-modifying the `target_modifiers` map to accumulate the sanitizers as a comma-separated list when the option is `sanitizer`.
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #157963 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 16, 2026
@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#157963), which was unapproved.

View changes since this unapproval

When passing multiple `-Zsanitizer` flags to the compiler (e.g.,
`-Zsanitizer=address -Zsanitizer=shadow-call-stack`), the options parser
was overwriting the previous values in `target_modifiers` instead of
accumulating them. This resulted in only the last sanitizer being
recorded in the crate metadata's target modifiers, even though the
frontend correctly enabled all of them.

The only way to provide multiple sanitizers was to combine them into a
comma-separated list passed to a single `-Zsanitizer=` flag, but this
does not fit well into the GN build system where different targets may
pass different combinations of sanitizer flags.

Consequently, this caused spurious "incompatible target modifiers"
ABI mismatch errors when linking against dependencies compiled with
accumulated flags (e.g., `-Zsanitizer=address,shadow-call-stack`).

Fix this by entry-modifying the `target_modifiers` map to accumulate
the sanitizers as a comma-separated list when the option is
`sanitizer`.

Also add a codegen test verifying that both CFI and SafeStack
attributes/metadata are present when enabled together via multiple
flags.

Test: ./x.py test tests/codegen-llvm/sanitizer/multiple-sanitizers.rs
@PiJoules PiJoules force-pushed the multiple-sanitizer-flags branch from dad6583 to 115338b Compare June 16, 2026 18:07
@PiJoules

Copy link
Copy Markdown
Contributor Author

The presubmit failed since it attempted to run the multiple-sanitizers.rs codegen test on x86_64-unknown-linux-musl which doesn't support safestack. I updated the test such that it's only run if the target supports safestack and and CFI which the normal x86_64-unknown-linux triple supports.

@petrochenkov could you take another look?

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try=test-various

@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Unknown command "try". Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try jobs=test-various

rust-bors Bot pushed a commit that referenced this pull request Jun 17, 2026
Accumulate multiple -Zsanitizer target modifiers


try-job: test-various
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 3de26f1 (3de26f1c0c8da56b3ab1530e4498e2a5b843466c)
Base parent: 98594f4 (98594f404ee741f97fefbae4aca049cde911bc94)

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 115338b has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 17, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 17, 2026
… r=petrochenkov

Accumulate multiple -Zsanitizer target modifiers

When passing multiple `-Zsanitizer` flags to the compiler (e.g., `-Zsanitizer=address -Zsanitizer=shadow-call-stack`), the options parser was overwriting the previous values in `target_modifiers` instead of accumulating them. This resulted in only the last sanitizer being recorded in the crate metadata's target modifiers, even though the frontend correctly enabled all of them. The only way to provide multiple sanitizers is to combine them into a comma-separated list passed to a single `-Zsanitizer=` flag, but this doesn't fit very well into the GN build system where different targets may pass different combinations of sanitizer flags.

Consequently, this caused spurious "incompatible target modifiers" ABI mismatch errors when linking against dependencies compiled with accumulated flags.

Fix this by entry-modifying the `target_modifiers` map to accumulate the sanitizers as a comma-separated list when the option is `sanitizer`.
rust-bors Bot pushed a commit that referenced this pull request Jun 17, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #157788 (Accumulate multiple -Zsanitizer target modifiers)
 - #158012 (Stabilize `strip_circumfix`)
 - #157810 (Query the trait solver in slow path for `missing_debug_implementations`)
 - #157829 (tests: adapt two tests for LLVM 23 changes)
 - #157917 (Don't suggest adding `in` to a `for` loop that already has one)
 - #157967 (Preserve track_caller for by-value dyn vtable shims)
 - #158019 (delegation: add simple test for incremental compilation)
 - #158023 (Move `UnusedDuplicate` diag struct to `rustc_attr_parsing`)
rust-bors Bot pushed a commit that referenced this pull request Jun 17, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #157788 (Accumulate multiple -Zsanitizer target modifiers)
 - #158012 (Stabilize `strip_circumfix`)
 - #157810 (Query the trait solver in slow path for `missing_debug_implementations`)
 - #157829 (tests: adapt two tests for LLVM 23 changes)
 - #157873 (mips: set llvm_args -mno-check-zero-division for all mips targets)
 - #157886 (Reject extra fields in MGCA struct const arguments)
 - #157917 (Don't suggest adding `in` to a `for` loop that already has one)
 - #157967 (Preserve track_caller for by-value dyn vtable shims)
 - #158019 (delegation: add simple test for incremental compilation)
 - #158023 (Move `UnusedDuplicate` diag struct to `rustc_attr_parsing`)
 - #158029 (Rename `project-stable-mir` to `project-rustc-public`)
 - #158044 (Add more tests for parallel frontend issues)
@rust-bors rust-bors Bot merged commit 47ce0db into rust-lang:main Jun 18, 2026
14 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 18, 2026
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 18, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#157788 (Accumulate multiple -Zsanitizer target modifiers)
 - rust-lang/rust#158012 (Stabilize `strip_circumfix`)
 - rust-lang/rust#157810 (Query the trait solver in slow path for `missing_debug_implementations`)
 - rust-lang/rust#157829 (tests: adapt two tests for LLVM 23 changes)
 - rust-lang/rust#157873 (mips: set llvm_args -mno-check-zero-division for all mips targets)
 - rust-lang/rust#157886 (Reject extra fields in MGCA struct const arguments)
 - rust-lang/rust#157917 (Don't suggest adding `in` to a `for` loop that already has one)
 - rust-lang/rust#157967 (Preserve track_caller for by-value dyn vtable shims)
 - rust-lang/rust#158019 (delegation: add simple test for incremental compilation)
 - rust-lang/rust#158023 (Move `UnusedDuplicate` diag struct to `rustc_attr_parsing`)
 - rust-lang/rust#158029 (Rename `project-stable-mir` to `project-rustc-public`)
 - rust-lang/rust#158044 (Add more tests for parallel frontend issues)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants