Skip to content

fix(unrar): use the stdcall ("system") ABI so 32-bit Windows links - #128

Open
bodencrouch wants to merge 1 commit into
mainfrom
fix/unrar-stdcall-i686
Open

bodencrouch wants to merge 1 commit into
mainfrom
fix/unrar-stdcall-i686

Conversation

@bodencrouch

Copy link
Copy Markdown
Owner

Why

package (windows-2025, i686-pc-windows-msvc, windows) fails at link with 7 unresolved externals (_RARCloseArchive, _RAROpenArchiveEx, _RARReadHeaderEx, _RARProcessFile, _RARProcessFileW, _RARSetCallback, _RARSetPassword). Analysis: #125 (comment)

UnRAR's dll.hpp declares its API PASCAL and its callbacks CALLBACK. Both are __stdcall on Windows; they are defined empty only under _UNIX. The bindings declared them extern "C". That matches on x64 and Unix, but on 32-bit Windows stdcall decorates names (_RARCloseArchive@4), so nothing resolves. This target has never linked.

What

  • vendor/unrar_sys/src/lib.rs: the FFI block and the ChangeVolProc, ProcessDataProc and Callback types are now extern "system". That is stdcall on 32-bit Windows and C on every other target, so behavior elsewhere is unchanged.
  • vendor/unrar/: unrar 0.5.8 vendored like unrar_sys, wired through [patch.crates-io]. The only code change is extern "system" fn callback (src/open_archive.rs:504), the one Rust function handed to RARSetCallback. Changing only the declarations would link but corrupt the stack on 32-bit Windows, because UnRAR calls the callback as stdcall. Upstream #[cfg(test)] modules, tests and examples are left out, as in unrar_sys. Provenance and the exact patch are in vendor/unrar/README.md.
  • Cargo.lock: only unrar's registry source/checksum lines are removed, with no version changes.

Verification

  • cargo build and cargo build --no-default-features: Finished.
  • cargo clippy --locked --lib --bin modsync -j2 -- -D warnings, with and without --no-default-features, on CI's pinned 1.95.0: clean.
  • cargo fmt --all -- --check: exit 0.
  • cargo tree -i unrar resolves to vendor/unrar.
  • Vendored unrar/src vs the registry crate: the only non-test difference is the callback ABI.
  • The i686 MSVC link can't run here. The package-manual dispatch on this branch is the proof.

Generated by Claude Code

UnRAR's dll.hpp declares the API PASCAL and callbacks CALLBACK, both
__stdcall on Windows. unrar_sys declared them extern "C", so the
i686-pc-windows-msvc link looked for undecorated _RAR* symbols and failed.

- vendor/unrar_sys: FFI block and ChangeVolProc/ProcessDataProc/Callback
  types are now extern "system" (stdcall on 32-bit x86 Windows, identical
  to "C" everywhere else).
- vendor/unrar: vendor unrar 0.5.8 (production sources only) with its
  RARSetCallback callback changed to extern "system" so it matches the
  corrected type; wired through [patch.crates-io].

Cargo.lock only drops the registry source/checksum for the patched unrar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDKiomK3BZE8fScCAGRfuq

Copy link
Copy Markdown
Owner Author

The install lanes failing here (k2, cli and gui, holo-patcher and mod-packaged) all stop at Recover and verify the lane-local game baseline. That's the cross-filesystem (EXDEV) baseline bug that #122 fixes. This branch doesn't contain that fix yet, and #125 and #126 fail at the same step.

This PR's own change (the i686 unrar stdcall fix) isn't the cause: the package-manual i686 lane passed. Once #122 merges, updating this branch onto main should clear these lanes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QDKiomK3BZE8fScCAGRfuq


Generated by Claude Code

This branch has not been deployed

No deployments
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