crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.34k stars 233 forks source link

Add initial intl-icu windows support #445

Closed crazywhalecc closed 6 months ago

crazywhalecc commented 6 months ago

What does this PR do?

Try to fix #435

Checklist before merging

If your PR involves the changes mentioned below and completed the action, please tick the corresponding option. If a modification is not involved, please skip it directly.

crazywhalecc commented 6 months ago

@simonhamp

I traveled across almost entire internet, and found a lot of things that proved we cannot statically build icu with Visual Studio. If we want to compile statically on Windows, we may have to use Cygwin or MSYS2, but they are also not suitable for static linking.

The first evidence is the mail list from SourceForge: In short, it can't be done.

The second one is from icu official docs: the following configure options (including --enable-static) currently do not work on Windows with Microsoft’s compiler.

I also tried to patch icu code, such as adding /MT, replacing .dll with .lib, applying other static build patch, and all of my work just failed to achieve this.

Although I don't want to say it, it is almost impossible for me to solve this now, unless the icu official or others who are more familiar with VC++ can provide more details.

But don't have to worry about not being able to use the intl extension under static-php.exe. It is also possible to compile intl.dll and icu*.dll separately, enable extension and place them in the current directory.

simonhamp commented 6 months ago

Thanks for your work! and thorough explanation. This is super helpful. I will explore your suggestion as an alternative on Windows to see where we can get to.

Do I need to anything special when building static-php.exe in order to enable the extension to be loaded dynamically in this way?

crazywhalecc commented 6 months ago

Do I need to anything special when building static-php.exe in order to enable the extension to be loaded dynamically in this way?

I haven't tested more extensions, but what is certain is that the default compilation results in working directly with php.ini and extension=C:\path\to\ext.dll. The condition is the target of dll extension compilation needs to be consistent with PHP (VS main version, thread safety, PHP version).

Under normal circumstances, it is not difficult to match the three, but if possible, we can reuse the static-php build kit to build the extension dll.