Skip to content

[Windows] Enable tailcall VM on Windows with clang-cl#21619

Draft
henderkes wants to merge 8 commits intophp:masterfrom
henderkes:feat/clang-windows-tailcall
Draft

[Windows] Enable tailcall VM on Windows with clang-cl#21619
henderkes wants to merge 8 commits intophp:masterfrom
henderkes:feat/clang-windows-tailcall

Conversation

@henderkes
Copy link
Copy Markdown
Contributor

@henderkes henderkes commented Apr 3, 2026

requires #21618 first

Build PHPBench no-JIT PHPBench JIT FrankenPHP RPS
MSVC Release 450K 770K 200
Clang Master 330K 550K 170
Clang TAILCALL VM 880K (+96% vs MSVC, +167% vs Clang) 1.3M (+69% vs MSVC, +136% vs Clang) 334 (+67% vs MSVC, +96% vs Clang)

cc @php/windows-team any chance the official releases will be switched to clang? compiles a bit longer, but performance is improved vastly

@henderkes
Copy link
Copy Markdown
Contributor Author

@arnaud-lb since this requires the fixes to clang in the first place, perhaps it's better I just mark this PR as ready for review and close the other one?

@arnaud-lb
Copy link
Copy Markdown
Member

I would prefer if the other PR was merged first, then this one rebased so it contains only changes related to tailcall VM.

@shivammathur
Copy link
Copy Markdown
Member

cc @php/windows-team any chance the official releases will be switched to clang? compiles a bit longer, but performance is improved vastly

Probably not in the near term. Moving all dependencies and the Windows build toolchain over to clang is not trivial, and I’d like to first see how far we can get with improved MSVC PGO and possibly [[msvc::musttail]] before considering a compiler switch.

@henderkes
Copy link
Copy Markdown
Contributor Author

henderkes commented Apr 3, 2026

cc @php/windows-team any chance the official releases will be switched to clang? compiles a bit longer, but performance is improved vastly

Probably not in the near term. Moving all dependencies and the Windows build toolchain over to clang is not trivial

The dependencies can keep being compiled with MSVC perfectly fine (assuming you mean libraries). Clang has no issue using them. The full snapshot build succeeds for clang, so I think this only affects unbundled extensions from pie/pecl.

and I’d like to first see how far we can get with improved MSVC PGO and possibly [[msvc::musttail]] before considering a compiler switch.

Not very far. [[msvc::musttail]] is C++ only while __preserve_none is C only. __preserve_none did offer a 5-8% performance uplift for the CALL VM too (see: #21563). Other than that, --disable-security-flags helps MSVC performance (450k -> 620k, jit unchanged), but it doesn't get anywhere near Clang with the tailcall VM.

As for PGO; it generally didn't make a huge difference. I added a frankenphp case for the symfony demo and the uplift was just 10%, still 33% slower than Clang without PGO. It unsurprisingly helped the phpbench case a lot, but that barely improves what I was doing this whole thing for.

run: .github/scripts/windows/build.bat
- name: Test
run: .github/scripts/windows/test.bat
WINDOWS_CLANG:
Copy link
Copy Markdown
Member

@iluuu1994 iluuu1994 Apr 3, 2026

Choose a reason for hiding this comment

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

Please unify this with the other windows job. Please also enable it for nightly only. You'll need to adjust this in .github/matrix.php, but it should be pretty self-evident. This should also be done in a separate PR, as these changes will have to land in the PHP-8.2 branch.

If the official builds switch to Clang, it will of course make sense to switch them around (build with MSCV in nightly only).

Edit: Ah I see, that's already GH-21618. I don't know if all these changes are needed just to test in CI though. What matters to me is that .github/matrix.php and .github/workflows/test-suite.yml are synced across all branches. If the other changes are needed for the builds, we can also skip the Clang job for every branch but master, as we do for some other builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can refactor the CI addition out to a separate PR targetting 8.4 (8.2?). I'm not sure if clang-cl even manages to build there, though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would be great. 8.2 is correct, we keep the build green for security branches. If the aim is to enable the build for master (i.e. 8.6) only, then you can use version_compare() like we do in other places in .github/matrix.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants