Skip to content

Add MSVC portability for runtime and generated startup - #21

Merged
mstan merged 1 commit into
masterfrom
fix/msvc-generated-init-shaneomac
Jul 14, 2026
Merged

Add MSVC portability for runtime and generated startup#21
mstan merged 1 commit into
masterfrom
fix/msvc-generated-init-shaneomac

Conversation

@mstan

@mstan mstan commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Add MSVC bit-scan intrinsics, generated .CRT$XCU startup initialization, and explicit C linkage for cross-language runtime globals while retaining the GCC/Clang constructor path.

Source and credit

Focused cherry-pick/adaptation of Martin Penkava's PR #16, exact source commit df4cc5c70ab1e5d0fd2a8f817dd346905d4d0eeb. Martin remains the commit author and the original Claude Fable 5 co-author trailer is preserved.

Deliberately excluded

No SmackDown scripts/data, discovery fallback, SPU, primitive rejection, Vulkan, CRT shader, or other PR #16 work is included.

Validation

  • VS2022/MSVC 19.41: psxrecomp-game, psxrecomp-bios, and l2_structural_test built
  • L2 structural suite: 44/44
  • Generated CPS startup hook test: PASS
  • Fresh BIOS runtime: all 63 object steps compiled under MSVC
  • Final BIOS-only link remains blocked by the documented pre-existing missing game-symbol definitions
  • git diff --check: PASS

Draft for focused review.

- psx_cyc.h / psx_cycles.c: _BitScanForward/_BitScanReverse shims for
  __builtin_ctz/__builtin_clz under _MSC_VER
- full_function_emitter.cpp / main_psx.cpp: emit a portable .CRT$XCU
  init-pointer instead of GCC-only __attribute__((constructor)) in
  generated dispatch/game code
- main.cpp: declare cross-language globals extern "C" so MSVC links
  them against their C definitions (no-op for GCC/Clang)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mstan
mstan marked this pull request as ready for review July 14, 2026 07:03
@mstan
mstan merged commit e94574a into master Jul 14, 2026
@mstan
mstan deleted the fix/msvc-generated-init-shaneomac branch July 21, 2026 02:01
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.

2 participants