Skip to content

fix(rar): keep the PHP Windows SDK WINVER for unrar os.hpp - #1263

Merged
crazywhalecc merged 2 commits into
v3from
fix/windows-rar-winver
Oct 22, 2026
Merged

crazywhalecc merged 2 commits into
v3from
fix/windows-rar-winver

Conversation

@crazywhalecc

@crazywhalecc crazywhalecc commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Why

The [v3] Build Self-Hosted PHP Binary (Windows) run #39647065053 has all four spc-min jobs green and all four spc-max jobs red. There are two separate causes.

1. rar / unrar redefines the Windows SDK version macros

The spc-max extension list includes rar; spc-min does not. unrar/os.hpp unconditionally does:

#define WINVER _WIN32_WINNT_WINXP
#define _WIN32_WINNT _WIN32_WINNT_WINXP

PHP's Windows build already defines both for the modern SDK (/D WINVER=0x0602, main/config.w32.h for _WIN32_WINNT). The generated main/internal_functions.c includes the rar header and therefore unrar/os.hpp; a later extension header includes urlmon.h. Mixing the old XP definitions with Windows SDK 10.0.26100 in one translation unit makes urlmon.h fail:

D:\...\ext\rar\unrar/os.hpp(43): warning C4005: 'WINVER': macro redefinition
D:\...\ext\rar\unrar/os.hpp(44): warning C4005: '_WIN32_WINNT': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\um\urlmon.h(6694): error C2059: syntax error: 'constant'
urlmon.h(6803): error C2146: syntax error: missing ')' before identifier 'ParseAction'
...
NMAKE : fatal error U1077: '"cl.exe" ... main\internal_functions.c' : return code '0x2'

This is the failure in 8.2-spc-max and 8.3-spc-max.

2. GitHub API download failures (separate, transient)

8.4-spc-max and 8.5-spc-max fail earlier, before compiling PHP:

[18:35:03 ERROR] ✘ Download failed: Download artifact 'libzip' failed.
...
Cause: Failed to get GitHub release API info for ... from https://api.github.com/repos/...

(8.5-spc-max: libyaml instead of libzip.) These are exit-75 download errors from the GitHub API, not the rar code path. Re-running may pass; if it persists, the artifact downloader/token/rate-limit path needs a separate fix.

Changes

  • src/Package/Extension/rar.php: add a makeForWindows hook that wraps the two unrar/os.hpp defines in #ifndef, preserving the WINVER / _WIN32_WINNT values already selected by the PHP build. If neither is defined, unrar still falls back to its previous XP values.

The patch only runs on Windows and is idempotent.

Validation

  • php -l src/Package/Extension/rar.php
  • composer analyse — no errors
  • composer test — 468 tests pass (the local untracked tests/StaticPHP/Package/ZipTest.php was excluded; it is unrelated and currently fails against v3)
  • I cannot run MSVC locally (macOS host), so need-test is set to run the extension matrix, which includes the Windows rar job.

Scope

This is independent of #1260 (Unix Swoole/pgsql fixes); it only touches the Windows rar build.

unrar/os.hpp unconditionally redefines WINVER/_WIN32_WINNT to Windows XP. The generated main/internal_functions.c includes it before urlmon.h, so the mixed SDK versions break urlmon.h parsing (C2059 around PARSEACTION) in every Windows spc-max build. Guard both defines so the values chosen by the PHP build are preserved.
@crazywhalecc crazywhalecc added need-test This PR has not been tested yet, cannot merge now os/windows Things only for Windows labels Oct 22, 2026
@github-actions

Copy link
Copy Markdown

StaticPHP Test Bot

Detected: Extensions: rar | Libraries: none | Targets: none
Active labels: none
Available labels: need-test (gate), test/linux test/windows test/macos (platform), test/tier2 (extra arch), test/php-83 test/php-84 (PHP version), sapi/frankenphp (extra FrankenPHP SAPI build)
Config: Linux x86_64 + Windows x86_64 + macOS arm64 | PHP 8.5 NTS

@crazywhalecc

Copy link
Copy Markdown
Owner Author

The Linux ext-test failure is not related to the rar/WINVER fix. The build compiles and links rar successfully; it fails later in the CLI smoke test with:

Failed to load OpenSSL legacy provider
hello

This comes from net-snmp 5.10 (snmplib/scapi.c), which logs a warning when OpenSSL is built with no-legacy. Fixed separately in #1265. Windows and macOS already pass; after #1265 merges, re-running this job should go green.

@henderkes

Copy link
Copy Markdown
Collaborator

Are we not using the bundled version of rar? I'd be surprised if that's a bundled extension issue.

@crazywhalecc

Copy link
Copy Markdown
Owner Author

It's not a php-src bundled extension, but static bundling puts the rar header into the php core.

@henderkes henderkes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, you're right, I could have sworn rar was bundled

@crazywhalecc
crazywhalecc merged commit aa1bee0 into v3 Oct 22, 2026
10 checks passed
@crazywhalecc
crazywhalecc deleted the fix/windows-rar-winver branch October 22, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-test This PR has not been tested yet, cannot merge now os/windows Things only for Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants