From 47d3fcef2441dd44ec3d15865c6866c61934181c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Feb 2026 11:50:09 +0000 Subject: [PATCH 1/3] Add Windows build workflow for pull requests and pushes Extract the Windows DLL build matrix from release.yml into a standalone workflow that runs on push/PR when ext/ files change. This catches Windows build breakages early instead of only at release time. https://claude.ai/code/session_01KtCQUuRcfQxhRd8esNdkrM --- .github/workflows/windows-build.yml | 84 +++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/windows-build.yml diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml new file mode 100644 index 0000000..cc917b4 --- /dev/null +++ b/.github/workflows/windows-build.yml @@ -0,0 +1,84 @@ +name: Windows Build + +on: + push: + branches: ['**'] + paths: + - 'ext/**' + - '.github/workflows/windows-build.yml' + pull_request: + branches: ['**'] + paths: + - 'ext/**' + - '.github/workflows/windows-build.yml' + +jobs: + build-windows: + name: Windows - PHP ${{ matrix.php }} ${{ matrix.ts }} ${{ matrix.arch }} + runs-on: windows-${{ matrix.os }} + defaults: + run: + shell: cmd + strategy: + fail-fast: false + matrix: + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + arch: [x64] + ts: [nts, ts] + os: ['2022'] + include: + # PHP 7.4-8.3 use VS16, PHP 8.4 uses VS17. + # windows-2022 runners have both toolsets. + - php: '7.4' + vs: vs16 + - php: '8.0' + vs: vs16 + - php: '8.1' + vs: vs16 + - php: '8.2' + vs: vs16 + - php: '8.3' + vs: vs16 + - php: '8.4' + vs: vs17 + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP SDK + id: setup + uses: php/setup-php-sdk@v0.12 + with: + version: ${{ matrix.php }} + arch: ${{ matrix.arch }} + ts: ${{ matrix.ts }} + + - name: Enable MSVC Developer Command Prompt + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + toolset: ${{ steps.setup.outputs.toolset }} + + - name: phpize + working-directory: ext\mariadb_profiler + run: phpize + + - name: configure + working-directory: ext\mariadb_profiler + run: configure --enable-mariadb_profiler --with-prefix=%INSTALL_DIR% + + - name: nmake + working-directory: ext\mariadb_profiler + run: nmake + + - name: Verify DLL exists + shell: pwsh + run: | + $dll = Get-ChildItem -Path ext\mariadb_profiler -Recurse -Filter "php_mariadb_profiler.dll" | + Select-Object -First 1 + if (-not $dll) { + Write-Error "php_mariadb_profiler.dll not found" + exit 1 + } + Write-Host "Built DLL: $($dll.FullName)" + Write-Host "Size: $([math]::Round($dll.Length / 1KB, 1)) KB" From c3c72e49b48f22e4c8de4e65e291cde9bf43bc1d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Feb 2026 11:56:17 +0000 Subject: [PATCH 2/3] Fix Windows build: replace _dosmaperr with own impl, drop PHP 7.4 - Replace _dosmaperr() calls with profiler_dosmaperr(), a self-contained inline function. PHP's _dosmaperr is internal and not exported from the PHP DLL, causing LNK2019 unresolved external symbol errors on all PHP versions (8.0-8.4). - Remove PHP 7.4 from Windows build matrices in both windows-build.yml and release.yml. The php/setup-php-sdk action cannot find a suitable toolset for PHP 7.4 on windows-2022 runners. https://claude.ai/code/session_01KtCQUuRcfQxhRd8esNdkrM --- .github/workflows/release.yml | 7 +++--- .github/workflows/windows-build.yml | 7 +++--- .../php_mariadb_profiler_compat.h | 25 +++++++++++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef86d55..bb47d6b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,15 +69,14 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['8.0', '8.1', '8.2', '8.3', '8.4'] arch: [x64] ts: [nts, ts] os: ['2022'] include: - # PHP 7.4-8.3 use VS16, PHP 8.4 uses VS17. + # PHP 8.0-8.3 use VS16, PHP 8.4 uses VS17. # windows-2022 runners have both toolsets. - - php: '7.4' - vs: vs16 + # PHP 7.4 is excluded: no suitable toolset on windows-2022. - php: '8.0' vs: vs16 - php: '8.1' diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index cc917b4..7240465 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -22,15 +22,14 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['8.0', '8.1', '8.2', '8.3', '8.4'] arch: [x64] ts: [nts, ts] os: ['2022'] include: - # PHP 7.4-8.3 use VS16, PHP 8.4 uses VS17. + # PHP 8.0-8.3 use VS16, PHP 8.4 uses VS17. # windows-2022 runners have both toolsets. - - php: '7.4' - vs: vs16 + # PHP 7.4 is excluded: no suitable toolset on windows-2022. - php: '8.0' vs: vs16 - php: '8.1' diff --git a/ext/mariadb_profiler/php_mariadb_profiler_compat.h b/ext/mariadb_profiler/php_mariadb_profiler_compat.h index 35aa96d..bcc8bb9 100644 --- a/ext/mariadb_profiler/php_mariadb_profiler_compat.h +++ b/ext/mariadb_profiler/php_mariadb_profiler_compat.h @@ -242,6 +242,27 @@ static inline struct tm *profiler_localtime_r(const time_t *timep, struct tm *re # define LOCK_UN 8 # endif +/* + * Map a Windows error code to errno. + * PHP's internal _dosmaperr() is not exported for use by extensions, + * so we provide our own minimal mapping for the error codes we handle. + */ +static inline void profiler_dosmaperr(unsigned long winerr) +{ + switch (winerr) { + case ERROR_ACCESS_DENIED: errno = EACCES; break; + case ERROR_INVALID_HANDLE: errno = EBADF; break; + case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; + case ERROR_LOCK_VIOLATION: errno = EACCES; break; + case ERROR_SHARING_VIOLATION: errno = EACCES; break; + case ERROR_FILE_NOT_FOUND: errno = ENOENT; break; + case ERROR_PATH_NOT_FOUND: errno = ENOENT; break; + case ERROR_ALREADY_EXISTS: errno = EEXIST; break; + case ERROR_FILE_EXISTS: errno = EEXIST; break; + default: errno = EINVAL; break; + } +} + static inline int profiler_flock(int fd, int operation) { HANDLE h = (HANDLE)_get_osfhandle(fd); @@ -257,7 +278,7 @@ static inline int profiler_flock(int fd, int operation) if (UnlockFileEx(h, 0, MAXDWORD, MAXDWORD, &ov)) { return 0; } - _dosmaperr(GetLastError()); + profiler_dosmaperr(GetLastError()); return -1; } @@ -275,7 +296,7 @@ static inline int profiler_flock(int fd, int operation) if ((operation & LOCK_NB) && lasterr == ERROR_LOCK_VIOLATION) { errno = EWOULDBLOCK; } else { - _dosmaperr(lasterr); + profiler_dosmaperr(lasterr); } } return -1; From 36cabc70dd7e9ba23a8d6eed8444220fb8507273 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Feb 2026 12:04:35 +0000 Subject: [PATCH 3/3] Restore PHP 7.4 Windows builds with VC15 (v141) toolset install PHP 7.4 requires the VC15 toolset (MSVC 14.1x) which is not pre-installed on windows-2022 runners. Add a conditional step to install Microsoft.VisualStudio.Component.VC.v141.x86.x64 via vs_installer before running php/setup-php-sdk. Applies to both windows-build.yml (PR/push) and release.yml. https://claude.ai/code/session_01KtCQUuRcfQxhRd8esNdkrM --- .github/workflows/release.yml | 23 ++++++++++++++++++++--- .github/workflows/windows-build.yml | 23 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bb47d6b..8bb165e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,14 +69,17 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] arch: [x64] ts: [nts, ts] os: ['2022'] include: + # PHP 7.4 requires VC15 (v141 toolset, MSVC 14.1x). # PHP 8.0-8.3 use VS16, PHP 8.4 uses VS17. - # windows-2022 runners have both toolsets. - # PHP 7.4 is excluded: no suitable toolset on windows-2022. + # windows-2022 runners have vs16/vs17 but NOT vc15, + # so we install the v141 component for PHP 7.4. + - php: '7.4' + vs: vs16 - php: '8.0' vs: vs16 - php: '8.1' @@ -91,6 +94,20 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install VC15 (v141) toolset for PHP 7.4 + if: matrix.php == '7.4' + shell: pwsh + run: | + Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" + $installPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" + $component = "Microsoft.VisualStudio.Component.VC.v141.x86.x64" + $args = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$installPath`"", + '--add', $component, '--quiet', '--norestart', '--nocache') + $process = Start-Process -FilePath cmd.exe -ArgumentList $args -Wait -PassThru -WindowStyle Hidden + if ($process.ExitCode -ne 0) { + Write-Warning "vs_installer exited with code $($process.ExitCode)" + } + - name: Setup PHP SDK id: setup uses: php/setup-php-sdk@v0.12 diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 7240465..021c59c 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -22,14 +22,17 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] arch: [x64] ts: [nts, ts] os: ['2022'] include: + # PHP 7.4 requires VC15 (v141 toolset, MSVC 14.1x). # PHP 8.0-8.3 use VS16, PHP 8.4 uses VS17. - # windows-2022 runners have both toolsets. - # PHP 7.4 is excluded: no suitable toolset on windows-2022. + # windows-2022 runners have vs16/vs17 but NOT vc15, + # so we install the v141 component for PHP 7.4. + - php: '7.4' + vs: vs16 - php: '8.0' vs: vs16 - php: '8.1' @@ -44,6 +47,20 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install VC15 (v141) toolset for PHP 7.4 + if: matrix.php == '7.4' + shell: pwsh + run: | + Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" + $installPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" + $component = "Microsoft.VisualStudio.Component.VC.v141.x86.x64" + $args = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$installPath`"", + '--add', $component, '--quiet', '--norestart', '--nocache') + $process = Start-Process -FilePath cmd.exe -ArgumentList $args -Wait -PassThru -WindowStyle Hidden + if ($process.ExitCode -ne 0) { + Write-Warning "vs_installer exited with code $($process.ExitCode)" + } + - name: Setup PHP SDK id: setup uses: php/setup-php-sdk@v0.12