Skip to content
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

Windows support #263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Windows support #263

wants to merge 1 commit into from

Conversation

NoiseByNorthwest
Copy link
Owner

@NoiseByNorthwest NoiseByNorthwest force-pushed the windows-support branch 17 times, most recently from 38263ad to d93b00e Compare September 8, 2024 17:35
@DanielRuf
Copy link
Contributor

Regarding zlib, there might be some additional logic at https://github.com/DanielRuf/php-spx/pull/1/files that can be helpful.

I didn't test this so far due to other more important things.

@NoiseByNorthwest NoiseByNorthwest force-pushed the windows-support branch 5 times, most recently from d3b1a59 to 114469d Compare September 8, 2024 21:35
@NoiseByNorthwest
Copy link
Owner Author

@DanielRuf Yes, I now have to add zlib dev package to the windows image. I'm looking for an example, without success so far.

@DanielRuf
Copy link
Contributor

DanielRuf commented Sep 8, 2024

Maybe vcpkg.exe install zlib helps further (see https://vcpkgx.com/details.html?package=zlib and https://vcpkg.io/en/).

https://github.com/DanielRuf/spx-windows-build/actions/runs/10763553391/job/29845207008#step:2:54

I also found this: https://wiki.php.net/internals/windows/libs/apache22

https://github.com/madler/zlib/tree/develop/win32

Not sure if there is some more step needed to compile and load the zlib library.

@NoiseByNorthwest NoiseByNorthwest force-pushed the windows-support branch 3 times, most recently from 953727e to ac17287 Compare September 8, 2024 22:53
@DanielRuf
Copy link
Contributor

DanielRuf commented Sep 8, 2024

zlib.lib and zlibd(ebug).lib should be there:

vcpkg.exe install zlib
dir C:/vcpkg/packages/zlib_x64-windows/debug/lib
dir C:/vcpkg/packages/zlib_x64-windows/lib
vcpkg.exe install zlib:x64-windows-static
dir C:/vcpkg/packages/zlib_x64-windows-static/debug/lib
dir C:/vcpkg/packages/zlib_x64-windows-static/lib

C:\vcpkg\packages\zlib_x64-windows\bin contains zlib.pdb and zlib1.dll.
C:\vcpkg\packages\zlib_x64-windows\include contains zconf.h and zlib.h.

I think these should be all relevant files.

I will check later, because a quick search at https://github.com/search?q=repo%3Aphp%2Fphp-windows-builder+libraries&type=code makes me think, that we can simply drop the files in some deps folder, that is linked somehow.

Upon further inspection, this is used via configure --with-php-build="..\deps" in the other project (deps is probably the src folder of PHP, didn't check further). The referenced URLs like https://downloads.php.net/~windows/php-sdk/deps contain some more dependencies (if needed). There we can also find the dll files (see https://downloads.php.net/~windows/php-sdk/deps/dllmapping.json).

@DanielRuf
Copy link
Contributor

@cmb69 before I am going in circles, where can we drop the files to let config.w32 find them with the least amount of changes and most portable setup (configure paramaters / changes only in the CI step)?

@NoiseByNorthwest NoiseByNorthwest force-pushed the windows-support branch 12 times, most recently from 6c0285a to 41dc7a3 Compare October 8, 2024 20:53
@NoiseByNorthwest
Copy link
Owner Author

I can't port the logic of the Makefile.frag (adding assets dir copy to install target and defining SPX_HTTP_UI_ASSETS_DIR macro) to win32.
I tried to do the equivalent in a Makefile.frag.w32, without success.
I need some help.

@DanielRuf
Copy link
Contributor

I can't port the logic of the Makefile.frag (adding assets dir copy to install target and defining SPX_HTTP_UI_ASSETS_DIR macro) to win32. I tried to do the equivalent in a Makefile.frag.w32, without success. I need some help.

@cmb69 would you be open to support here and is there something that I can do to cover the efforts or shall I try my luck (still not much C knowledge so it would be pure trial & error on my side)?

@cmb69
Copy link

cmb69 commented Oct 9, 2024

Something like

this patch
 Makefile.frag.w32     | 9 +++++++++
 config.w32            | 3 ++-
 src/php_spx.c         | 2 +-
 src/spx_reporter_fp.c | 2 +-
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Makefile.frag.w32 b/Makefile.frag.w32
new file mode 100644
index 0000000..da1aaee
--- /dev/null
+++ b/Makefile.frag.w32
@@ -0,0 +1,9 @@
+
+spx_ui_assets_dir = $(PHP_PREFIX)/share/misc/php-spx/assets/web-ui
+
+install-spx-ui-assets:
+	@echo "Installing SPX web UI to: $(spx_ui_assets_dir)"
+	@mkdir -p $(spx_ui_assets_dir)
+	@cp -r assets/web-ui/* $(spx_ui_assets_dir)
+
+install: $(all_targets) $(install_targets) install-spx-ui-assets
diff --git a/config.w32 b/config.w32
index d6cc0f5..4231332 100644
--- a/config.w32
+++ b/config.w32
@@ -5,7 +5,7 @@ ARG_ENABLE("spx-dev", "Compile SPX with debugging symbols", "no");
 if (PHP_SPX == "yes") {
     AC_DEFINE("HAVE_SPX", 1, "spx");
 
-    ADD_FLAG("CFLAGS", "/Ox /Wall /WX /W2 /wd4820 /wd4774 /wd4711 /wd4710 /wd4464 /wd4005");
+    ADD_FLAG("CFLAGS", "/Ox /Wall /W2 /wd4820 /wd4774 /wd4711 /wd4710 /wd4464 /wd4005");
 
     if (PHP_SPX_DEV == "yes") {
         ADD_FLAG("CFLAGS", "/Zi");
@@ -18,6 +18,7 @@ if (PHP_SPX == "yes") {
         ERROR("zlib not found");
     }
 
+    AC_DEFINE("SPX_HTTP_UI_ASSETS_DIR", PHP_PREFIX.replace(/\\/g, "/") + "/share/misc/php-spx/assets/web-ui");
     EXTENSION("spx", "src/php_spx.c \
         src/spx_profiler.c \
         src/spx_profiler_tracer.c \
diff --git a/src/php_spx.c b/src/php_spx.c
index 02276f9..b9759cc 100644
--- a/src/php_spx.c
+++ b/src/php_spx.c
@@ -926,7 +926,7 @@ static void http_ui_handler_shutdown(void)
         goto finish;
     }
 
-    char local_file_absolute_path[PATH_MAX];
+    char local_file_absolute_path[MAXPATHLEN];
 
     if (
         spx_utils_resolve_confined_file_absolute_path(
diff --git a/src/spx_reporter_fp.c b/src/spx_reporter_fp.c
index 6c503ee..f4828d7 100644
--- a/src/spx_reporter_fp.c
+++ b/src/spx_reporter_fp.c
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <math.h>
 
-#include <unistd.h>
+// #include <unistd.h>
 
 #include "spx_reporter_fp.h"
 #include "spx_resource_stats.h"

should be a step in the right direction. With this patch applied (and also having pthreads in the deps/ folder; should be checked in config.w32), I get:

src/spx_metric.c(30): fatal error C1189: #error:  "Please open an issue"

@NoiseByNorthwest NoiseByNorthwest force-pushed the windows-support branch 4 times, most recently from bece402 to a9f39df Compare October 9, 2024 22:11
@NoiseByNorthwest
Copy link
Owner Author

Thanks @cmb69, I've applied your patch, with a slight variation around PATH_MAX management, and I got this error:

D:\a\php-spx\php-spx\build\ee0377d3\src\php_spx.c : fatal error C1083: Cannot open compiler generated file: 'D:\a\php-spx\php-spx\build\ee0377d3\x64\Release\src\php_spx.obj': No such file or directory

https://github.com/NoiseByNorthwest/php-spx/actions/runs/11263855256/job/31322677812

@NoiseByNorthwest NoiseByNorthwest force-pushed the windows-support branch 2 times, most recently from d651e72 to 7c4520e Compare October 20, 2024 16:34
@cmb69
Copy link

cmb69 commented Oct 20, 2024

I've applied your patch, with a slight variation around PATH_MAX management, and I got this error:

Sorry, I still had no time to look closer into this, but I do not understand why there is a src\ in x64\Release\src\php_spx.obj. The .obj files are supposed to be placed in x64\Release, and they are in my local build. Is that something that php/php-windows-builder does?

@NoiseByNorthwest
Copy link
Owner Author

Sorry, I still had no time to look closer into this

Don't worry, and thank you again for your help.

I do not understand why there is a src\ in x64\Release\src\php_spx.obj. The .obj files are supposed to be placed in x64\Release, and they are in my local build. Is that something that php/php-windows-builder does?

I don't know either, I will do some tests with other php-windows-builder's versions, and look at the doc and other extensions using it.

NoiseByNorthwest added a commit that referenced this pull request Nov 29, 2024
This patch is not a complete support of windows. Its goal is to
port to master branch right now the current changes made to src/ to
support windows.

See here: #263
@NoiseByNorthwest
Copy link
Owner Author

@DanielRuf I'm pausing the development of this PR until the future web UI version is released or sufficiently advanced.

The current status of this PR is that it is stuck on build issues at CI level. I'm not surprised as this is the kind of difficulty I had anticipated.
Once build issues are fixed, it could take only 1-2 weeks to reach a "working on windows" status. And then few other weeks for fixing windows-related issues with the help of beta testers.

I've also already merged most of the diff required for windows support in a separate branch (see #279) in order to minimize conflicts between master and this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants