Skip to content

Conversation

@JakubOnderka
Copy link
Owner

@JakubOnderka JakubOnderka commented Jun 8, 2025

Summary by CodeRabbit

  • New Features

    • Added automated scripts for setting up, building, and testing PHP extensions on Windows environments.
    • Introduced a new continuous integration workflow for Windows, supporting multiple PHP versions, Visual Studio versions, and configuration options.
  • Chores

    • Updated the installed header file for the simdjson extension.
  • Bug Fixes

    • Improved compiler compatibility by adjusting intrinsic header inclusions and function implementations for different compilers and architectures.
    • Enhanced runtime detection of AVX2 CPU support for better compatibility across environments.

@coderabbitai
Copy link

coderabbitai bot commented Jun 8, 2025

Walkthrough

This update introduces a comprehensive Windows CI/CD setup for building and testing a PHP extension. It adds PowerShell scripts for installing dependencies, building the extension, and running tests. A new GitHub Actions workflow orchestrates these scripts across a matrix of PHP and Visual Studio versions. Minor source and configuration updates improve compiler compatibility, code portability, and runtime CPU feature detection.

Changes

File(s) Change Summary
.github/workflows/build.ps1 New PowerShell script for building PHP extensions, handling environment setup and DLL management.
.github/workflows/install.ps1 New PowerShell script to automate PHP SDK, PHP binaries, dependencies, and APCu setup on Windows.
.github/workflows/test.ps1 New PowerShell script to set up environment and run PHP tests with error handling.
.github/workflows/windows.yml New GitHub Actions workflow for Windows CI, running builds/tests across a matrix of configurations.
config.w32 Added new source files and updated installed header from simdjson_bindings_defs.h to simdjson_decoder_defs.h.
src/simdjson_avx2.h Adjusted intrinsic header includes for MSVC compatibility (<intrin.h> vs <x86intrin.h>); conditional TARGET_AVX2 definition.
src/simdjson_vector8.h Added _trailing_zeroes function for cross-compiler trailing zero bit count; replaced direct calls.
src/simdjson_encoder.cpp Enhanced simdjson_avx2_supported() with runtime AVX2 detection fallback using CPUID intrinsics.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Runner (Windows)
    participant install.ps1
    participant build.ps1
    participant test.ps1

    GitHub Actions->>Runner (Windows): Start job (matrix config)
    Runner (Windows)->>install.ps1: Run install.ps1
    install.ps1->>Runner (Windows): Setup PHP SDK, binaries, deps, APCu
    Runner (Windows)->>build.ps1: Run build.ps1
    build.ps1->>Runner (Windows): Build PHP extension, copy DLL, configure php.ini
    Runner (Windows)->>test.ps1: Run test.ps1
    test.ps1->>Runner (Windows): Run PHP tests, report result
Loading

Poem

🐇
On Windows I hop, with scripts anew,
Installing, building, and testing too.
With PowerShell magic and YAML delight,
PHP extensions compile just right.
Matrixes spin, DLLs appear—
CI/CD cheer is finally here!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18691e2 and aba6c99.

📒 Files selected for processing (1)
  • src/simdjson_avx2.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/simdjson_avx2.h
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ci (8.4, nts, vs17)
  • GitHub Check: ci (8.4, ts, vs17)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JakubOnderka JakubOnderka force-pushed the build-windows branch 3 times, most recently from 285527a to b120cfd Compare June 8, 2025 12:30
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

🧹 Nitpick comments (8)
.github/workflows/test.ps1 (1)

5-9: Consider adding output capture for better debugging.

While the current error handling is good, consider capturing the test output to a variable or log file for better debugging when tests fail in CI.

-$env:TEST_PHP_EXECUTABLE = "C:\php\bin\php.exe"
-& $env:TEST_PHP_EXECUTABLE 'run-tests.php' --color --show-diff tests
-if (-not $?) {
-    throw "testing failed with errorlevel $LastExitCode"
-}
+$env:TEST_PHP_EXECUTABLE = "C:\php\bin\php.exe"
+$output = & $env:TEST_PHP_EXECUTABLE 'run-tests.php' --color --show-diff tests 2>&1
+if (-not $?) {
+    Write-Host "Test output: $output"
+    throw "testing failed with errorlevel $LastExitCode"
+}
.github/workflows/install.ps1 (4)

44-44: Fix typo in error message.

There's a typo in the download error message.

-        echo "Downlaod: https://windows.php.net/downloads/releases/archives/$bname"
+        echo "Download: https://windows.php.net/downloads/releases/archives/$bname"

85-86: Clarify the APCu version exclusion logic.

The condition excludes PHP 8.2 and 8.3 from APCu installation, but the reasoning isn't clear. Consider adding a comment explaining why these versions are excluded.

-# PECL apuc
-if (('' -ne $env:PECL_APCU) -and ('8.2' -ne $env:PHP_VER) -and ('8.3' -ne $env:PHP_VER)) {
+# PECL APCu - excluded for PHP 8.2 and 8.3 due to compatibility issues
+if (('' -ne $env:PECL_APCU) -and ('8.2' -ne $env:PHP_VER) -and ('8.3' -ne $env:PHP_VER)) {

87-87: Consider parameterizing the APCu version.

The APCu version is hardcoded. Consider making it configurable through an environment variable for easier updates.

-    $apcu_version = '5.1.21'
+    $apcu_version = if ($env:APCU_VERSION) { $env:APCU_VERSION } else { '5.1.21' }

110-124: Consider using a loop for APCu header file moves.

The repetitive Move-Item commands for APCu header files could be simplified using a loop for better maintainability.

-    Move-Item "C:\php\apcu-$apcu_version\php_apc.h" 'C:\php\devel\include\ext\apcu\php_apc.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc.h" 'C:\php\devel\include\ext\apcu\apc.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_api.h" 'C:\php\devel\include\ext\apcu\apc_api.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_cache.h" 'C:\php\devel\include\ext\apcu\apc_cache.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_globals.h" 'C:\php\devel\include\ext\apcu\apc_globals.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_iterator.h" 'C:\php\devel\include\ext\apcu\apc_iterator.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_lock.h" 'C:\php\devel\include\ext\apcu\apc_lock.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_mutex.h" 'C:\php\devel\include\ext\apcu\apc_mutex.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_sma.h" 'C:\php\devel\include\ext\apcu\apc_sma.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_serializer.h" 'C:\php\devel\include\ext\apcu\apc_serializer.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_stack.h" 'C:\php\devel\include\ext\apcu\apc_stack.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_windows_srwlock_kernel.h" 'C:\php\devel\include\ext\apcu\apc_windows_srwlock_kernel.h'
-    Move-Item "C:\php\apcu-$apcu_version\apc_arginfo.h" 'C:\php\devel\include\ext\apcu\apc_arginfo.h'
-    Move-Item "C:\php\apcu-$apcu_version\php_apc_legacy_arginfo.h" 'C:\php\devel\include\ext\apcu\php_apc_legacy_arginfo.h'
+    $apcu_headers = @(
+        'php_apc.h', 'apc.h', 'apc_api.h', 'apc_cache.h', 'apc_globals.h',
+        'apc_iterator.h', 'apc_lock.h', 'apc_mutex.h', 'apc_sma.h',
+        'apc_serializer.h', 'apc_stack.h', 'apc_windows_srwlock_kernel.h',
+        'apc_arginfo.h', 'php_apc_legacy_arginfo.h'
+    )
+    foreach ($header in $apcu_headers) {
+        Move-Item "C:\php\apcu-$apcu_version\$header" "C:\php\devel\include\ext\apcu\$header"
+    }
.github/workflows/windows.yml (3)

3-7: Add pull_request trigger and branch filters.

Currently, CI runs on every push and on published releases. To validate incoming PRs and avoid running on all branch pushes, consider:

  • Adding a pull_request: trigger (e.g., branches: [main]).
  • Restricting push: to specific branches (main, release/*, etc.).

58-62: Ensure tags are fetched in checkout.

You're triggering on release, but the default checkout is shallow (no tags). Add fetch-depth: 0:

- uses: actions/checkout@v4
  with:
    persist-credentials: false
    fetch-depth: 0

71-82: Use consistent path separators and consider a setup action.

Prefer forward slashes or quoted backslashes to avoid YAML escape issues:

-run: .\.github\workflows\install.ps1
+run: ./.github/workflows/install.ps1

Also, you could simplify maintenance by using an established action (e.g. shivammathur/setup-php) instead of custom install scripts.

🛑 Comments failed to post (4)
.github/workflows/test.ps1 (1)

3-3: 💡 Verification agent

🧩 Analysis chain

Verify PATH directories match the installation script.

The hardcoded PATH directories should align with the structure created by the install.ps1 script. Ensure consistency across the workflow scripts.


🏁 Script executed:

#!/bin/bash
# Description: Check PATH consistency between test.ps1 and install.ps1
# Expected: The directories in PATH should match those created by install.ps1

# Check what directories are referenced in the PATH in test.ps1
rg "env:PATH.*=.*" .github/workflows/test.ps1

# Check what directories are created in install.ps1
rg "C:\\\\php\\\\(devel|bin|deps)" .github/workflows/install.ps1

Length of output: 2160


Align PATH entries in test.ps1 with install.ps1

The test.ps1 workflow currently prepends C:\php\deps\bin, but the install script only creates C:\php\deps. Update the PATH entry for consistency:

• File: .github/workflows/test.ps1
Line 3

- $env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps\bin;$env:PATH"
+ $env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps;$env:PATH"
🤖 Prompt for AI Agents
In .github/workflows/test.ps1 at line 3, the PATH environment variable includes
"C:\php\deps\bin" which does not match the directory structure created by
install.ps1 that only creates "C:\php\deps". Update the PATH entry by replacing
"C:\php\deps\bin" with "C:\php\deps" to ensure consistency between the test and
install scripts.
.github/workflows/build.ps1 (1)

5-13: 💡 Verification agent

🧩 Analysis chain

Investigate the build failure and improve debugging.

The pipeline shows "building failed with errorlevel 2". Consider adding more verbose output to help diagnose build issues.

-$task = New-Item 'task.bat' -Force
-Add-Content $task 'call phpize 2>&1'
-Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1"
-Add-Content $task 'nmake /nologo 2>&1'
-Add-Content $task 'exit %errorlevel%'
-& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task
-if (-not $?) {
-    throw "building failed with errorlevel $LastExitCode"
-}
+$task = New-Item 'task.bat' -Force
+Add-Content $task '@echo off'
+Add-Content $task 'echo Running phpize...'
+Add-Content $task 'call phpize 2>&1'
+Add-Content $task 'if errorlevel 1 (echo phpize failed with errorlevel %errorlevel% & exit /b %errorlevel%)'
+Add-Content $task 'echo Running configure...'
+Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1"
+Add-Content $task 'if errorlevel 1 (echo configure failed with errorlevel %errorlevel% & exit /b %errorlevel%)'
+Add-Content $task 'echo Running nmake...'
+Add-Content $task 'nmake /nologo 2>&1'
+Add-Content $task 'exit %errorlevel%'
+Write-Host "Executing build with: C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat"
+& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task
+if (-not $?) {
+    Write-Host "Build task.bat contents:"
+    Get-Content $task
+    throw "building failed with errorlevel $LastExitCode"
+}

🏁 Script executed:

#!/bin/bash
# Description: Check for potential build configuration issues
# Expected: Identify common causes of build failures

# Check if configure script expects specific parameters
rg "configure.*enable.*simdjson" --type bat --type cmd

# Look for build configuration files that might affect the build
fd "config.w32|config.m4" -x cat {}

# Check for any build dependencies mentioned in the codebase
rg "(dependency|require|need)" config.w32

Length of output: 2620


Improve Windows CI build script with detailed logging and error handling

To diagnose the “errorlevel 2” failure more effectively, enhance .github/workflows/build.ps1 so that each step in task.bat is echoed, failures are caught immediately, and the full task contents are printed on error. This will surface whether phpize, configure or nmake is the culprit.

• File: .github/workflows/build.ps1
• Section: lines 5–13 (task.bat generation and execution)

-$task = New-Item 'task.bat' -Force
-Add-Content $task 'call phpize 2>&1'
-Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1"
-Add-Content $task 'nmake /nologo 2>&1'
-Add-Content $task 'exit %errorlevel%'
-& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task
-if (-not $?) {
-    throw "building failed with errorlevel $LastExitCode"
-}
+$task = New-Item 'task.bat' -Force
+Add-Content $task '@echo off'
+Add-Content $task 'echo === Running phpize ==='
+Add-Content $task 'call phpize 2>&1'
+Add-Content $task 'if errorlevel 1 (echo phpize failed with exit code %errorlevel% & exit /b %errorlevel%)'
+
+Add-Content $task 'echo === Running configure ==='
+Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1"
+Add-Content $task 'if errorlevel 1 (echo configure failed with exit code %errorlevel% & exit /b %errorlevel%)'
+
+Add-Content $task 'echo === Running nmake ==='
+Add-Content $task 'nmake /nologo 2>&1'
+Add-Content $task 'exit %errorlevel%'
+
+Write-Host "Invoking PHP SDK initialization script:"
+Write-Host "  C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat -t $task"
+& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task
+if (-not $?) {
+    Write-Host "=== task.bat contents on failure ==="
+    Get-Content $task | Write-Host
+    throw "Build failed with exit code $LastExitCode"
+}

These changes will immediately pinpoint which phase fails and preserve the full log for review.

🧰 Tools
🪛 GitHub Actions: Windows

[error] 12-12: Build script threw exception: building failed with errorlevel 2.

🤖 Prompt for AI Agents
In .github/workflows/build.ps1 around lines 5 to 13, enhance the task.bat script
by adding commands to echo each step before execution to provide verbose output.
Modify the script to immediately exit on any failure within task.bat to catch
errors early. After running the task, if it fails, output the full contents of
task.bat and the captured logs to help identify whether phpize, configure, or
nmake caused the error. This will improve debugging by making the build process
and failure points more transparent.
.github/workflows/windows.yml (2)

8-12: ⚠️ Potential issue

Guard PHP_EXT_VERSION for non-release events.

PHP_EXT_VERSION uses github.event.release.tag_name, which is undefined on plain pushes. Either:

  • Scope it under a release–only job.
  • Provide a fallback (e.g. ${{ github.ref_name }} or empty string).
🤖 Prompt for AI Agents
In .github/workflows/windows.yml around lines 8 to 12, the environment variable
PHP_EXT_VERSION is set to github.event.release.tag_name, which is undefined for
non-release events like plain pushes. To fix this, modify the workflow to either
run this job only on release events or provide a fallback value for
PHP_EXT_VERSION using an expression like github.ref_name or an empty string to
avoid errors during non-release triggers.

48-48: 🛠️ Refactor suggestion

Use a ternary for runs-on.

GitHub expressions support condition ? trueValue : falseValue but not JS-style &&/|| for value selection. Update to:

runs-on: ${{ matrix.vs == 'vs17' ? 'windows-2022' : 'windows-2019' }}
🤖 Prompt for AI Agents
In .github/workflows/windows.yml at line 48, the runs-on expression incorrectly
uses JavaScript-style && and || operators for conditional value selection, which
GitHub Actions does not support. Replace the expression with a ternary operator
using the syntax: matrix.vs == 'vs17' ? 'windows-2022' : 'windows-2019' to
correctly select the runner based on the matrix.vs value.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/windows.yml (1)

17-22: Consider enabling additional PHP versions or updating the matrix excludes.

Currently only PHP 8.3 is enabled, but the matrix excludes (lines 30-39) reference commented-out versions, causing actionlint warnings.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 285527a and d39a1d0.

📒 Files selected for processing (7)
  • .github/workflows/build.ps1 (1 hunks)
  • .github/workflows/install.ps1 (1 hunks)
  • .github/workflows/test.ps1 (1 hunks)
  • .github/workflows/windows.yml (1 hunks)
  • config.w32 (1 hunks)
  • src/simdjson_avx2.h (1 hunks)
  • src/simdjson_vector8.h (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/simdjson_avx2.h
  • .github/workflows/test.ps1
🚧 Files skipped from review as they are similar to previous changes (3)
  • config.w32
  • .github/workflows/install.ps1
  • .github/workflows/build.ps1
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/windows.yml

30-30: value "8.4" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)


34-34: value "8.2" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)


36-36: value "8.1" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)


38-38: value "8.0" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)

🔇 Additional comments (3)
src/simdjson_vector8.h (2)

26-36: LGTM! Excellent cross-platform compatibility improvement.

The _trailing_zeroes function properly abstracts the platform-specific implementations for counting trailing zeros, enabling Windows MSVC support while maintaining compatibility with other compilers.


73-75: Clean migration to the abstracted function.

The replacement of direct __builtin_ctzll calls with _trailing_zeroes maintains the same functionality while providing cross-platform compatibility.

.github/workflows/windows.yml (1)

41-76: Well-structured Windows CI workflow.

The workflow configuration is comprehensive with appropriate caching, environment setup, and build steps for Windows development with Visual Studio.

Comment on lines +30 to +39
- php: '8.4'
vs: vs16
- php: '8.3'
vs: vs17
- php: '8.2'
vs: vs17
- php: '8.1'
vs: vs17
- php: '8.0'
vs: vs17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove matrix excludes for non-existent PHP versions.

The exclude entries reference PHP versions (8.4, 8.2, 8.1, 8.0) that are not currently included in the matrix, causing static analysis warnings.

Either uncomment the PHP versions in the matrix or remove these exclude entries:

-        exclude:
-          - php: '8.4'
-            vs: vs16
-          - php: '8.3'
-            vs: vs17
-          - php: '8.2'
-            vs: vs17
-          - php: '8.1'
-            vs: vs17
-          - php: '8.0'
-            vs: vs17
+        exclude:
+          - php: '8.3'
+            vs: vs17
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- php: '8.4'
vs: vs16
- php: '8.3'
vs: vs17
- php: '8.2'
vs: vs17
- php: '8.1'
vs: vs17
- php: '8.0'
vs: vs17
exclude:
- php: '8.3'
vs: vs17
🧰 Tools
🪛 actionlint (1.7.7)

30-30: value "8.4" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)


34-34: value "8.2" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)


36-36: value "8.1" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)


38-38: value "8.0" in "exclude" does not match in matrix "php" combinations. possible values are "8.3"

(matrix)

🤖 Prompt for AI Agents
In .github/workflows/windows.yml around lines 30 to 39, the matrix excludes
reference PHP versions 8.4, 8.2, 8.1, and 8.0 which are not present in the
matrix, causing static analysis warnings. To fix this, either uncomment and
include these PHP versions in the matrix or remove the corresponding exclude
entries that mention these versions to keep the matrix consistent and avoid
warnings.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/windows.yml (1)

29-39: Remove matrix excludes for non-existent PHP versions

Exclude entries for PHP 8.3–8.0 don’t match the php matrix and will cause actionlint warnings. Please remove these entries:

-          - php: '8.3'
-            vs: vs17
-          - php: '8.2'
-            vs: vs17
-          - php: '8.1'
-            vs: vs17
-          - php: '8.0'
-            vs: vs17
🧰 Tools
🪛 actionlint (1.7.7)

32-32: value "8.3" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


34-34: value "8.2" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


36-36: value "8.1" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


38-38: value "8.0" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)

🧹 Nitpick comments (3)
.github/workflows/windows.yml (3)

3-7: Specify branch filters for push triggers

Currently the push event triggers on all branches, which may lead to unnecessary workflow runs. Consider restricting it to main or release branches:

on:
  push:
    branches:
      - main
      - release/*
  release:
    types: [published]

17-22: Clean up commented-out PHP versions

The commented matrix entries for PHP 8.3–8.0 add noise. If these versions aren’t planned imminently, remove these lines; otherwise, un-comment and include them in the matrix:

-        #  - '8.3'
-        #  - '8.2'
-        #  - '8.1'
-        #  - '8.0'

63-69: Prefer forward slashes in script paths

Using forward slashes improves readability and consistency across platforms:

-      - name: Install build command
-        run: .\.github\workflows\install.ps1
+      - name: Install build command
+        run: ./.github/workflows/install.ps1
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d39a1d0 and a841603.

📒 Files selected for processing (2)
  • .github/workflows/windows.yml (1 hunks)
  • src/simdjson_avx2.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/simdjson_avx2.h
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/windows.yml

32-32: value "8.3" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


34-34: value "8.2" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


36-36: value "8.1" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


38-38: value "8.0" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)

🔇 Additional comments (2)
.github/workflows/windows.yml (2)

29-32: Verify the PHP 8.4 + vs16 exclusion is intentional

By excluding the php: '8.4' + vs: vs16 combination, all VS2019 builds for PHP 8.4 will be skipped, leaving only VS2022. Confirm this is deliberate, or remove the exclusion to include VS16 coverage.

🧰 Tools
🪛 actionlint (1.7.7)

32-32: value "8.3" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


1-74: Overall workflow setup looks solid

The matrix strategy, caching, and step sequence for checkout/install/build/test are well-structured.

🧰 Tools
🪛 actionlint (1.7.7)

32-32: value "8.3" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


34-34: value "8.2" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


36-36: value "8.1" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)


38-38: value "8.0" in "exclude" does not match in matrix "php" combinations. possible values are "8.4"

(matrix)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a841603 and 18691e2.

📒 Files selected for processing (2)
  • src/simdjson_encoder.cpp (1 hunks)
  • src/simdjson_vector8.h (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/simdjson_vector8.h
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ci (8.4, nts, vs17)
  • GitHub Check: ci (8.4, ts, vs17)
🔇 Additional comments (1)
src/simdjson_encoder.cpp (1)

533-542:

❌ Incorrect review comment

Verify CPUID intrinsics availability and add missing headers.

The fallback implementation uses __cpuid and __cpuidex intrinsics, but these require appropriate headers and are compiler-specific. The logic itself is correct for detecting AVX2 support.

Run the following script to check if the necessary headers are included:

The CPUID detection logic is correct, but ensure that:

  1. #include <intrin.h> is included for MSVC
  2. Alternative implementations exist for GCC/Clang if needed
  3. The function is properly tested across different compilers

🏁 Script executed:

#!/bin/bash
# Description: Check for CPUID intrinsic headers and usage patterns in the codebase
# Expected: Find include statements for intrin.h, immintrin.h, or cpuid.h

echo "Checking for CPUID-related headers:"
rg -i "include.*(?:intrin|cpuid|immintrin)\.h" --type cpp

echo -e "\nChecking for other CPUID usage patterns:"
rg "__cpuid|__cpuidex|_cpuid" --type cpp -A 2 -B 2

Length of output: 15091


🏁 Script executed:

#!/bin/bash
# Inspect header includes in src/simdjson_encoder.cpp to verify CPUID intrinsic headers
echo "Header includes in src/simdjson_encoder.cpp:"
rg -n "^#include" src/simdjson_encoder.cpp

Length of output: 694


🏁 Script executed:

#!/bin/bash
# Check for CPUID fallback macros and intrinsics in compatibility header
echo "Searching for GCC CPUID macros in simdjson_compatibility.h:"
rg -n "HAVE_GCC_GET_CPUID|USE_GCC_GET_CPUID" src/simdjson_compatibility.h

echo -e "\nSearching for __cpuid definitions in simdjson_compatibility.h:"
rg -n "__cpuid" src/simdjson_compatibility.h

Length of output: 390


No Missing CPUID Headers – Already Included Transitively

The AVX2 detection in src/simdjson_encoder.cpp is covered by existing includes:

  • simdjson_avx2.h brings in <intrin.h> (MSVC) and <x86intrin.h> (GCC/Clang).
  • simdjson.h also includes <cpuid.h>.
  • GCC/Clang support for __cpuid/__cpuidex is provided via <x86intrin.h>.

No additional headers or alternate fallbacks are needed; the current intrinsics logic and testing across compilers remains valid as-is.

Likely an incorrect or invalid review comment.

Comment on lines +529 to +531
#ifdef __builtin_cpu_supports
return __builtin_cpu_supports("avx2"); // check support in runtime
#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the conditional compilation check for __builtin_cpu_supports.

The current check #ifdef __builtin_cpu_supports will not work as expected because __builtin_cpu_supports is a GCC builtin function, not a preprocessor macro. This condition will likely always be false.

Consider using a compiler-specific check instead:

-#ifdef __builtin_cpu_supports
+#if defined(__GNUC__) && !defined(__clang__) || (defined(__clang__) && __has_builtin(__builtin_cpu_supports))
     return __builtin_cpu_supports("avx2"); // check support in runtime
 #endif

Or use feature detection:

-#ifdef __builtin_cpu_supports
+#if __has_builtin(__builtin_cpu_supports)
     return __builtin_cpu_supports("avx2"); // check support in runtime
 #endif
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#ifdef __builtin_cpu_supports
return __builtin_cpu_supports("avx2"); // check support in runtime
#endif
#if defined(__GNUC__) && !defined(__clang__) || (defined(__clang__) && __has_builtin(__builtin_cpu_supports))
return __builtin_cpu_supports("avx2"); // check support in runtime
#endif
🤖 Prompt for AI Agents
In src/simdjson_encoder.cpp around lines 529 to 531, the conditional compilation
check using #ifdef __builtin_cpu_supports is incorrect because
__builtin_cpu_supports is a GCC builtin function, not a macro. Replace this
check with a compiler-specific macro such as #if defined(__GNUC__) &&
!defined(__clang__) to ensure the code compiles only when using GCC, or use
feature detection macros like __AVX2__ to conditionally compile the AVX2 support
check. Adjust the preprocessor directives accordingly to correctly detect
compiler support before calling __builtin_cpu_supports.

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.

2 participants