Microsoft only offers their latest installer called VisualStudioSetup.exe for community edition which is at the time of writing VS2022: https://visualstudio.microsoft.com/vs/older-downloads/
And I can't compile a compatible PHP-binary with it.
The problem I'm facing is that when you compile PHP from source (PHP 8.1, PHP 8.2, PHP 8.3) it is linked to MSVC 14.40. When you download from https://windows.php.net it is linked to MSVC 14.29.
Therefore the self-compiled PECL extensions are not compatible with the downloaded PHP binary.
They won't get loaded on startup with the following message:
Warning: PHP Startup: Can't load module 'php_jsmin.dll' as it's linked with 14.40, but the core is linked with 14.29 in Unknown on line 0
This does apply to all self-compiled extensions, not only jsmin.
I can't install MSVC 14.29 only, because PHP needs two components:
C++ CMake tools for Windows has a damn dependency:
The php compile environment now always links against v14.40. This was no problem with Visual Studio 2019 Setup, but Microsoft forbids to download old community versions - You can only download Visual Studio 2022 Setup with that before mentioned dependency problem.
How can I link against MSVC 14.29 when using Visual Studio 2022 Setup to compile PHP from source.
Thank you very much in advance!
Disclaimer: This is an answer from @IanKemp's comment.
There is basically no known way (at least not to me) to change the php compile environment's behaviour.
But there is a simple way to circumvent that problem altogether. Just download the old VisualStudioSetup.exe community edition 2019 where MSVC 14.29 is the latest MSVC.
It can be downloaded here: https://download.visualstudio.microsoft.com/download/pr/93f24e82-778c-46ae-92f9-8d3010ecd011/a5da04d78b1f94ab145a365733476df7a1ec6219fa17f09c7e2f3c7cd74d9c9e/vs_Community.exe
Alternative
I found a not-accepted answer which even provides a more structured download and even older VS versions: https://stackoverflow.com/a/78644904/1519125
Thanks to @andrés-lópez
I can't/won't nominate it as duplicate, since the answer I'm referring to is not the accepted one. Here is the content:
Here you can download the other versions as well: