-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Code change for compile on windows. Needs to modify php-src. #1286
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for moving Windows support forward!
frankenphp.c
Outdated
#elif defined(__MINGW64__) | ||
#include <pthread.h> | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#elif defined(__MINGW64__) | |
#include <pthread.h> | |
#endif |
pthread.h
is always included (line 20)
frankenphp.go
Outdated
// #cgo linux CFLAGS: -Wall -Werror | ||
// #cgo darwin CFLAGS: -Wall -Werror | ||
// #cgo openbsd CFLAGS: -Wall -Werror | ||
// #cgo freebsd CFLAGS: -Wall -Werror |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// #cgo linux CFLAGS: -Wall -Werror | |
// #cgo darwin CFLAGS: -Wall -Werror | |
// #cgo openbsd CFLAGS: -Wall -Werror | |
// #cgo freebsd CFLAGS: -Wall -Werror | |
// #cgo unix CFLAGS: -Wall -Werror |
Should work
Thanks for your comments. I've take them and added the compilation documentation. |
@dunglas Is it still worthwhile to carry on with this route? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it looks like a good step forward Windows support to me.
patch.php
Outdated
|
||
if ($content !== $new_content) { | ||
file_put_contents($file_path, $new_content); | ||
echo "$file_path 中的 __forceinline 已替换为 inline\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this file coming from? We should add the proper copyright and license header. We should also translate it in English.
Also, can't this patch be upstreamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
This php script was written by myself to modify part of the code of php-8.3.0. So that the compiled .dll can be linked by the mingw-w64 linker. I should have forgotten to change it to English in this line. Slip-up.
echo "\"__forceinline\" in $file_path has been replace by \"inline\"\n";
I'll correct it.
About copyright. I read php license again and noticed that "Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer." Honestly, I'm not sure if the act of uploading a public repo of the script I used to modify the php source code counts as Redistribution. Maybe I should ask someone else.
About this patch could or not be upstreamed. I could sort this patch out and submit a pull request to php-src. but the patch is only meant to be compatible with frankenphp, and I'm not sure if it would be adopted. But I can give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forget what I said about the copyright, as you're the original author of this script, it's fine!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be cool to upstream the patch. I don't see what is FrankenPHP-specific in it, it would be useful for all users of the embed SAPI on Windows, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this patch aim to compile php by msvc on windows with php8embed.dll out and make php8ts.dll & php8embed.dll could be linked by mingw-w64 linker. I've tried compile php with mingw-w64, but failed.
So the core problem is php on windows needs to be compiled by msvc but frankenphp's cgo need to compiled by gnu gcc(mingw-w64-gcc). Then in some cases mingw-w64-ld could link the dll compiled by msvc, if remove some specifics that are supported by msvc but not by mingw-w64-gcc.
The origin targets output by msvc are no php8embed.dll, only php8embed.lib. In msvc its designed to link php8embed.lib the php8embed.lib call php8ts.dll. But mingw-w64-ld could not link .lib that msvc output.
The file patch.php completed both goals.
- Remove some specifics that are supported by msvc but not by mingw-w64-gcc;
- Modify Makefile make php8embed.dll out.
So it looks like this patch can be used to make mingw-w64-gcc call php-win embed sapi. It's just that I don't know of any other program besides frankenphp that has this need to not be bypassed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clear! Don't hesitate to add this as a comment in the script.
To me, it will be valuable for PHP to compile with mingw, but it's up to the PHP core team to decide.
Would you mind opening an issue or asking on the intervals mailing list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments and docs.
Opened a issue about this on php-src. php-src/issues/17476
No description provided.