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 5 commits into
base: master
Choose a base branch
from
Open

Windows support #263

wants to merge 5 commits 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
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

@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.

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