Skip to content

fix(runtime): do not export PERRY_AGENT_PTRS on Windows (MSVC TLS export breaks the build) - #11595

Merged
proggeramlug merged 2 commits into
mainfrom
fix/windows-agent-ptrs-export
Sep 27, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
fix/windows-agent-ptrs-export

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every release build of perry-runtime for x86_64-pc-windows-msvc is broken on main. crates/perry-runtime/src/agent_ptrs.rs declares #[no_mangle] #[thread_local] static PERRY_AGENT_PTRS (added with #11489). MSVC targets cannot export TLS across images, so rustc emits a thread-local shim under the static's own symbol name, and the build fails with "symbol PERRY_AGENT_PTRS is already defined".

The fix is #[cfg_attr(not(windows), no_mangle)]. Only ELF executables name the symbol (perry-codegen/src/expr/agent_ptr.rs); Windows already takes the accessor call. Nothing changes on other targets.

It was found and reproduced with a minimal crate under cargo xwin while rebasing #11565, whose Windows gc-call-effects leg it broke. The same commit is on #11565's branch; landing it separately unblocks Windows builds now.

Validation

  • cargo xwin build --release -p perry-runtime --target x86_64-pc-windows-msvc fails before this change and succeeds after it.
  • Native cargo check -p perry-runtime is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a build issue affecting Windows release versions. Windows builds using MSVC should now complete without the duplicate-symbol error.

Ralph Küpper and others added 2 commits September 27, 2026 23:50
MSVC targets cannot export TLS across images, so rustc emits a
thread-local shim under the static's own symbol name and a #[no_mangle]
#[thread_local] static fails to build ("symbol PERRY_AGENT_PTRS is already
defined"). Only ELF executables name the symbol; Windows takes the accessor
call. This broke every release build of perry-runtime for
x86_64-pc-windows-msvc (the gc-call-effects windows leg).
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: cede5daa-eb73-453d-bc8a-0fc30260f44c

📥 Commits

Reviewing files that changed from the base of the PR and between f702361 and 59e05f2.

📒 Files selected for processing (2)
  • changelog.d/11595-windows-agent-ptrs-export.md
  • crates/perry-runtime/src/agent_ptrs.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The PERRY_AGENT_PTRS declaration now applies no_mangle only on non-Windows targets. Its documentation describes the Windows accessor call, and a changelog entry records the reported MSVC TLS export limitation and duplicate-symbol build failure.

Changes

Agent pointer declaration

Layer / File(s) Summary
Conditional symbol export
crates/perry-runtime/src/agent_ptrs.rs, changelog.d/11595-windows-agent-ptrs-export.md
PERRY_AGENT_PTRS uses cfg_attr(not(windows), no_mangle). The documentation notes that Windows code uses the accessor call. The changelog records the reported MSVC TLS export limitation and duplicate-symbol build failure.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 59e05

The Windows accessor path remains compatible with the conditional TLS export, and non-Windows targets retain the named symbol. No actionable merge-blocking risk is evident.

Architecture Summary

Architecture risk: 🔵 Low · up to 59e05

The change affects 2 systems.

Changed systems: changelog.d, crates

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — changelog.d (service) was modified; 1 changed file maps to changed impact.
  • observed — crates (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in changelog.d/11595-windows-agent-ptrs-export.md: Added a changelog entry stating that PERRY_AGENT_PTRS is no longer #[no_mangle] on Windows and describing the reported MSVC TLS export limitation and duplicate-symbol build failure.
  • observed — Modified behavior in crates/perry-runtime/src/agent_ptrs.rs: The documentation now describes why the TLS symbol is not exported on Windows and notes that Windows code uses the accessor call. The unconditional no_mangle attribute is replaced with cfg_attr(not(windows), no_mangle), so the attribute applies only on non-Windows targets.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: preventing Windows/MSVC TLS export issues for PERRY_AGENT_PTRS.
Description check ✅ Passed The description clearly explains the Windows/MSVC build failure, the code change, its scope, and validation results. It omits several template headings, including Changes, Related issue, and Checklist…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug merged commit b3f8d02 into main Sep 27, 2026
55 of 57 checks passed
@proggeramlug
proggeramlug deleted the fix/windows-agent-ptrs-export branch September 27, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant