11@ echo off
2+ setlocal EnableDelayedExpansion
23
34if /i " %GITHUB_ACTIONS% " neq " True" (
45 echo for CI only
@@ -13,100 +14,43 @@ set PHP_BUILD_DIR=C:\obj\Release_TS
1314echo Build directory: %PHP_BUILD_DIR%
1415echo .
1516echo Checking if php.exe exists:
16- if exist %PHP_BUILD_DIR% \php.exe (
17+ if exist " %PHP_BUILD_DIR% \php.exe" (
1718 echo FOUND: php.exe
1819) else (
1920 echo ERROR: php.exe not found!
2021 exit /b 1
2122)
2223
23- echo .
24- echo Checking if php8ts.dll exists:
25- if exist %PHP_BUILD_DIR% \php8ts.dll (
26- echo FOUND: php8ts.dll
27- ) else (
28- echo ERROR: php8ts.dll not found!
29- echo Looking for any PHP DLLs:
30- dir %PHP_BUILD_DIR% \*.dll | findstr php
31- echo Looking in obj directory:
32- dir C:\obj\*.dll 2 > NUL | findstr php
33- exit /b 1
34- )
35-
3624echo .
3725echo Copying deps DLLs like official PHP does...
3826set DEPS_DIR = C:\build-cache\deps-master-vs17-x64
39- echo Deps directory: %DEPS_DIR%
40- echo Available DLLs in deps:
41- dir %DEPS_DIR% \bin\*.dll | findstr " vcruntime\|php"
42-
43- echo Copying all deps DLLs to build directory...
44- copy /-y %DEPS_DIR% \bin\*.dll %PHP_BUILD_DIR% \
45- echo Copy completed.
46-
47- echo .
48- echo Checking if vcruntime140.dll is now present:
49- if exist %PHP_BUILD_DIR% \vcruntime140.dll (
50- echo SUCCESS: vcruntime140.dll found in build directory
51- ) else (
52- echo WARNING: vcruntime140.dll still missing, trying system copy...
53- copy " C:\Windows\System32\vcruntime140.dll" %PHP_BUILD_DIR% \ > NUL 2 >& 1
54- )
27+ copy /-y %DEPS_DIR% \bin\*.dll %PHP_BUILD_DIR% \*
5528
5629echo .
5730echo Testing PHP executable...
5831cd /d %PHP_BUILD_DIR%
5932
6033echo Enabling Loader Snaps for detailed DLL loading diagnostics...
61- set LDR_CNTRL_DEBUG_DLL_LOADS = 1
62- set LOADER_DEBUG = 1
34+ gflags /i php.exe +sls > nul
6335
64- echo Running PHP with Loader Snaps enabled...
65- php.exe --version
66- set PHP_EXIT_CODE = %errorlevel%
36+ echo Running PHP under cdb with Loader Snaps...
6737
68- if %PHP_EXIT_CODE% neq 0 (
38+ echo Checking for missing DLL errors:
39+ cdb -c " g;qd" php.exe --version 2^ > ^ &1 ^
40+ | findstr /i " LDR: Error .*unable to load"
41+
42+ echo Getting full output and exit code:
43+ for /f " tokens=*" %%L in ('
44+ cdb -c " g;qd" php.exe --version 2^ > ^ &1
45+ ') do (
46+ echo %%L
47+ if " %%L " == " Exit code" set " PHP_LINE = %%L "
48+ )
49+ for %%i in (%PHP_LINE% ) do set " PHP_EXIT_CODE = %%i "
50+
51+ echo Exit code = %PHP_EXIT_CODE%
52+ if not " %PHP_EXIT_CODE% " == " 0" (
6953 echo ERROR: PHP failed to start (exit code: %PHP_EXIT_CODE% )
70-
71- echo .
72- echo === Detailed Diagnostics ===
73-
74- echo Checking dependencies:
75- dumpbin /dependents php.exe | findstr " \.dll"
76-
77- echo .
78- echo Checking which DLLs are actually present:
79- for %%i in (php8ts.dll VCRUNTIME140.dll) do (
80- if exist %%i (
81- echo FOUND: %%i
82- ) else (
83- echo MISSING: %%i
84- )
85- )
86-
87- echo .
88- echo Using WHERE command to find missing DLLs:
89- where php8ts.dll 2 > NUL || echo " php8ts.dll not in PATH"
90- where VCRUNTIME140.dll 2 > NUL || echo " VCRUNTIME140.dll not in PATH"
91-
92- echo .
93- echo Checking Windows Event Log for application errors:
94- powershell -Command " Get-WinEvent -FilterHashtable @{LogName='Application'; Level=2; StartTime=(Get-Date).AddMinutes(-1)} -MaxEvents 2 -ErrorAction SilentlyContinue | ForEach-Object { Write-Host ('Time: ' + $_.TimeCreated + ' - ID: ' + $_.Id + ' - Message: ' + $_.Message.Substring(0, [Math]::Min(200, $_.Message.Length))) }"
95-
96- echo .
97- echo === Detailed DLL Analysis ===
98-
99- echo Using PowerShell to find exact missing DLLs:
100- powershell -Command " $proc = Start-Process -FilePath '%CD% \php.exe' -ArgumentList '--version' -Wait -PassThru -WindowStyle Hidden -ErrorAction SilentlyContinue; if ($proc.ExitCode -ne 0) { Write-Host 'Process failed with exit code:' $proc.ExitCode }"
101-
102- echo .
103- echo Checking with SFC style scan:
104- powershell -Command " try { Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class Kernel32 { [DllImport(\" kernel32.dll\" )] public static extern IntPtr LoadLibrary(string lpFileName); [DllImport(\" kernel32.dll\" )] public static extern uint GetLastError(); }'; $handle = [Kernel32]::LoadLibrary('%CD% \php.exe'); if ($handle -eq [IntPtr]::Zero) { $error = [Kernel32]::GetLastError(); Write-Host 'LoadLibrary failed with error code:' $error; switch($error) { 126 { Write-Host 'ERROR 126: The specified module could not be found (missing DLL)' }; 127 { Write-Host 'ERROR 127: The specified procedure could not be found' }; 193 { Write-Host 'ERROR 193: Not a valid Win32 application' }; default { Write-Host 'Unknown error code' } } } else { Write-Host 'LoadLibrary succeeded' } } catch { Write-Host 'Exception:' $_.Exception.Message }"
105-
106- echo .
107- echo Trying dependency walker style check:
108- powershell -Command " Get-ChildItem '%CD% ' -Filter '*.dll' | ForEach-Object { try { [System.Reflection.Assembly]::LoadFile($_.FullName) | Out-Null; Write-Host 'OK:' $_.Name } catch { Write-Host 'FAIL:' $_.Name '-' $_.Exception.Message } }"
109-
11054 exit /b 1
11155)
11256
@@ -131,6 +75,10 @@ if exist ..\ext\async\tests (
13175)
13276
13377set TEST_EXIT_CODE = %errorlevel%
78+
79+ rem Disable Loader Snaps
80+ gflags /i php.exe -sls > nul
81+
13482echo .
13583echo Tests completed with exit code: %TEST_EXIT_CODE%
13684exit /b %TEST_EXIT_CODE%
0 commit comments