Skip to content

Add frame pointer annotations to the module#156980

Open
Darksonn wants to merge 1 commit into
rust-lang:mainfrom
Darksonn:frame-ptrs-module
Open

Add frame pointer annotations to the module#156980
Darksonn wants to merge 1 commit into
rust-lang:mainfrom
Darksonn:frame-ptrs-module

Conversation

@Darksonn
Copy link
Copy Markdown
Member

@Darksonn Darksonn commented May 26, 2026

While working on #156973 I found llvm/llvm-project#188234 which points out that the frame pointer annotation is also missing.

@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 May 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
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 18 candidates

@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented May 27, 2026

cc #156973 (comment) is the function level attribute still necessary here?

@Darksonn
Copy link
Copy Markdown
Member Author

Darksonn commented May 27, 2026

Yes, see #156973 (comment). Module level annotations control what annotations LLVM places on functions it generates, but it does not affect annotations on functions generated by the frontend, afaik.

@Darksonn
Copy link
Copy Markdown
Member Author

We tested this via adding the -Zllvm_module_flag=frame-pointer:u32:2:max flag, and Linux still boots up fine. I didn't discover this from any actual symtoms, though I believe it could affect stacktraces if there are crashes inside asan.module_ctor.

Darksonn added a commit to Darksonn/linux that referenced this pull request May 27, 2026
Due to a rustc bug [1] the -Cforce-unwind-tables=y flag only emits the
uwtable annotation for functions, but not for the module. This means
that compiler-generated functions such as 'asan.module_ctor' do not
receive the uwtable annotation.

When CONFIG_UNWIND_PATCH_PAC_INTO_SCS is enabled, this leads to boot
failures because the dwarf information emitted for the kasan
constructors is wrong, which causes the SCS boot patching code to
patch the constructor in an illegal manner. Specifically, the paciasp
instruction is patched, but the autiasp instruction is not. This
mismatch leads to a crash when the constructor is called during boot.

	==================================================================
	BUG: KASAN: global-out-of-bounds in do_basic_setup+0x4c/0x90
	Read of size 8 at addr ffffffe3cc7eb488 by task swapper/0/1

Specifically the faulting instruction is the (*fn)() to invoke the
constructor in do_ctors() of the init/main.c file.

Once the fix lands in rustc, this flag can be made conditional on the
rustc version. Note that passing the flag on a rustc with the fix
present has no effect.

Fixes: d077242 ("rust: support for shadow call stack sanitizer")
Cc: stable@kernel.org
Link: rust-lang/rust#156980 [1]
Reported-by: Bo Ye <bo.ye@mediatek.com>
Debugged-by: Isaac Manjarres <isaacmanjarres@google.com>
Debugged-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Isaac Manjarres <isaacmanjarres@google.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
@rust-bors

This comment has been minimized.

@chenyukang
Copy link
Copy Markdown
Member

@rustbot reroll

@Darksonn
Copy link
Copy Markdown
Member Author

Darksonn commented May 28, 2026

r? @nnethercote to match the other PR

@rustbot rustbot assigned nnethercote and unassigned folkertdev May 28, 2026
@Darksonn Darksonn force-pushed the frame-ptrs-module branch from 9b9ff47 to df84fea Compare May 28, 2026 05:58
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 28, 2026

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.

@nnethercote
Copy link
Copy Markdown
Contributor

Let's do a perf run, just in case:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 28, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 28, 2026
Add frame pointer annotations to the module
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 28, 2026

☀️ Try build successful (CI)
Build commit: c8369ce (c8369cea31120991abeca2842069a7a349bc66ad, parent: 59bc26c76496c81c01963b59bca3563b60be5722)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (c8369ce): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 2.6%, secondary -0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [2.0%, 3.1%] 2
Regressions ❌
(secondary)
2.4% [1.9%, 3.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-3.4%, -0.8%] 3
All ❌✅ (primary) 2.6% [2.0%, 3.1%] 2

Cycles

Results (primary -2.8%, secondary 0.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.5% [5.5%, 5.5%] 1
Improvements ✅
(primary)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
-4.1% [-4.1%, -4.1%] 1
All ❌✅ (primary) -2.8% [-2.8%, -2.8%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 510.899s -> 511.257s (0.07%)
Artifact size: 400.68 MiB -> 400.69 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 28, 2026
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.

7 participants