Skip to content

Add -Zstack-protector-guard target modifier#159165

Open
alvinsun039 wants to merge 1 commit into
rust-lang:mainfrom
alvinsun039:stack-protector-guard-wip
Open

Add -Zstack-protector-guard target modifier#159165
alvinsun039 wants to merge 1 commit into
rust-lang:mainfrom
alvinsun039:stack-protector-guard-wip

Conversation

@alvinsun039

@alvinsun039 alvinsun039 commented Jul 12, 2026

Copy link
Copy Markdown

Add a new unstable -Z stack-protector-guard target modifier to
configure how the stack canary is accessed, equivalent to Clang's
-mstack-protector-guard=* options.

Usage: -Z stack-protector-guard=<mode>[,offset=N][,reg=R][,symbol=S]

This is needed by Rust-for-Linux to support per-task stack canary
(CONFIG_STACKPROTECTOR_PER_TASK), where the canary is stored in a
per-task location rather than a global __stack_chk_guard variable.

MCP: rust-lang/compiler-team#1013
Zulip: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/-Z.20stack-protector-guard.20flags

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Jul 12, 2026
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @chenyukang (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
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 16 candidates

@rust-bors

This comment has been minimized.

@alvinsun039 alvinsun039 force-pushed the stack-protector-guard-wip branch from 55ce98f to f9353d7 Compare July 15, 2026 07:24
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

Equivalent to Clang's `-mstack-protector-guard=*`. Allows configuring
how the stack canary is accessed (global, TLS, or system register),
which must be consistent across the crate graph.
@alvinsun039 alvinsun039 force-pushed the stack-protector-guard-wip branch from f9353d7 to d9c1148 Compare July 16, 2026 02:20
@rustbot

rustbot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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. 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.

4 participants