Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions .github/workflows/windows-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Windows shared SDK + extension catalog
run-name: "Windows shared SDK for PHP ${{ inputs.php_version || 'pinned set (PR check)' }}"

# Packages the Windows *shared* PHP SDK (php8ts.dll + php8ts.lib +
# php8embed.lib + headers + the official extension DLLs) and the Windows Xdebug
# catalog entry for one PHP release. See tools/windows-shared/package.ps1 for
# the full rationale; the short version:
#
# The default Windows SDK (build.yml, platform windows-x86_64) is a static spc
# --build-embed, and a binary that links PHP statically has no php8ts.dll for
# extension DLLs to import the engine from, so it cannot load php_xdebug.dll
# or any other PHP extension. This lane repackages the official
# windows.php.net ZTS build of the same release instead of compiling PHP, so
# the official extension DLLs and xdebug.org's Xdebug DLLs are ABI-matched to
# the engine by construction.
#
# Separate workflow on purpose: build.yml's Windows legs and extensions.yml's
# Linux catalog stay untouched. Nothing here is compiled, so it runs on
# GitHub-hosted windows-latest rather than the self-hosted ephemerd fleet.
#
# Publishing (workflow_dispatch from main only) ADDS assets to existing
# releases with `gh release upload --clobber`, which never edits a release's
# title or body:
# v<ver> php-sdk-<ver>-windows-x86_64-shared.tar.gz
# ext-<ver> ephpm-ext-<ver>-windows-x86_64.tar.gz
# A missing release is created as a plain release with a short note.
#
# A pull request touching this lane builds and smoke-tests the pinned set
# below without publishing anything.

on:
workflow_dispatch:
inputs:
php_version:
description: "PHP version (GA x.y.z, e.g. 8.5.7). Must be a windows.php.net release."
required: true
type: string
xdebug_version:
description: "Xdebug release (xdebug.org Windows DLL; its sha256 must be in tools/windows-shared/checksums.txt)"
required: false
type: string
default: "3.5.3"
pull_request:
paths:
- ".github/workflows/windows-shared.yml"
- "tools/windows-shared/**"

permissions:
contents: read

jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.m.outputs.matrix }}
steps:
- id: m
env:
PHP_VERSION: ${{ inputs.php_version }}
XDEBUG_VERSION: ${{ inputs.xdebug_version }}
run: |
if [ -n "$PHP_VERSION" ]; then
# Both values end up in the matrix JSON and are expanded into
# the pwsh step below, so only accept plain version strings.
XDEBUG_VERSION="${XDEBUG_VERSION:-3.5.3}"
if ! [[ "$PHP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::php_version '$PHP_VERSION' must be a GA x.y.z version"; exit 1
fi
if ! [[ "$XDEBUG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-zA-Z0-9]+)?$ ]]; then
echo "::error::xdebug_version '$XDEBUG_VERSION' is not an Xdebug release version"; exit 1
fi
echo "matrix=[{\"php\":\"$PHP_VERSION\",\"xdebug\":\"$XDEBUG_VERSION\"}]" >> "$GITHUB_OUTPUT"
else
# PR check: the versions ephpm's xtask pins today (pinned
# checksums path) - keep in step with checksums.txt.
echo 'matrix=[{"php":"8.3.33","xdebug":"3.5.3"},{"php":"8.4.23","xdebug":"3.5.3"},{"php":"8.5.7","xdebug":"3.5.3"}]' >> "$GITHUB_OUTPUT"
fi

package:
name: Package (PHP ${{ matrix.php }})
needs: setup
runs-on: windows-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.setup.outputs.matrix) }}
steps:
- uses: actions/checkout@v4

- name: Package shared SDK + Xdebug catalog
shell: pwsh
run: |
./tools/windows-shared/package.ps1 `
-PhpVersion '${{ matrix.php }}' `
-XdebugVersion '${{ matrix.xdebug }}' `
-OutDir "$env:RUNNER_TEMP/out" `
-WorkDir "$env:RUNNER_TEMP/work"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-shared-${{ matrix.php }}
path: ${{ runner.temp }}/out/*.tar.gz
if-no-files-found: error

publish:
name: Publish
needs: package
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true

- name: Attach to v<ver> and ext-<ver>
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PHP_VERSION: ${{ inputs.php_version }}
run: |
set -eu
ls -lh artifacts/
sdk="artifacts/php-sdk-${PHP_VERSION}-windows-x86_64-shared.tar.gz"
ext="artifacts/ephpm-ext-${PHP_VERSION}-windows-x86_64.tar.gz"
test -f "$sdk" && test -f "$ext"

ensure_release() {
if ! gh release view "$1" > /dev/null 2>&1; then
gh release create "$1" --title "$2" --notes "$3"
fi
}
ensure_release "v${PHP_VERSION}" "PHP ${PHP_VERSION}" \
"PHP ${PHP_VERSION} SDK. Windows shared-engine SDK attached by windows-shared.yml."
ensure_release "ext-${PHP_VERSION}" "PHP ${PHP_VERSION} ZTS extensions" \
"PHP ${PHP_VERSION} ZTS extensions. Windows Xdebug attached by windows-shared.yml."

gh release upload "v${PHP_VERSION}" "$sdk" --clobber
gh release upload "ext-${PHP_VERSION}" "$ext" --clobber
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Built with [static-php-cli](https://github.com/crazywhalecc/static-php-cli) —
| Linux x86_64 (glibc, **NTS**, shared embed) | `-linux-x86_64-gnu-nts-shared` | `lib/libphp.so` (dependencies linked in) + headers, non-thread-safe |
| Linux aarch64 (glibc, **NTS**, shared embed) | `-linux-aarch64-gnu-nts-shared` | `lib/libphp.so` (dependencies linked in) + headers, non-thread-safe |
| Windows x86_64 (**experimental**, clang-cl + TAILCALL VM) | `-windows-x86_64-clang` | `lib/php8embed.lib` + dep `.lib`s + headers, ZTS |
| Windows x86_64 (**shared engine**, official build) | `-windows-x86_64-shared` | `bin/php8ts.dll` + `lib/php8ts.lib` + `lib/php8embed.lib` + headers + official `bin/ext/php_*.dll`, ZTS |

The glibc floor is 2.28 (built on AlmaLinux 8 with `gcc-toolset-13`), so a consumer binary linked against these runs on RHEL/Alma 8, Ubuntu 20.04+, Debian 10+, Amazon Linux 2023 and Fedora 40+.

Expand Down Expand Up @@ -95,6 +96,58 @@ change PHP upstream does not test on macOS. Until then: **use macOS PHP 8.5 for
CPU-bound workloads.** The build logs the selected VM kind (macOS "Record Zend
VM kind" step) and warns when a pre-8.5 macOS SDK lands on CALL.

### Windows shared-engine SDK (`-windows-x86_64-shared`)

The default Windows SDK links PHP statically, and a static PHP cannot load
extension DLLs: `php_xdebug.dll` and every other PHP extension import the
engine from `php8ts.dll`, which a static build does not have. The `-shared`
tarball is the alternative for consumers that need to load extensions (Xdebug
first of all).

It is **not compiled here**. `.github/workflows/windows-shared.yml` runs
`tools/windows-shared/package.ps1`, which repackages the official
windows.php.net ZTS x64 build of the same release (the zip already contains a
small static `php8embed.lib` whose objects import the engine through
`php8ts.lib`; the matching devel pack carries `php8ts.lib` and the headers).
Using the official engine means the official extension DLLs and xdebug.org's
Xdebug DLLs are ABI-matched to it by construction. Every download is
sha256-verified against `tools/windows-shared/checksums.txt` or the live
windows.php.net checksum list, and the lane refuses to package unless a smoke
test — the official `php.exe` run from a directory holding only the packaged
`bin/` payload — loads every extension of the static SDK's set plus Xdebug.

```
include/php/ headers (devel pack)
lib/php8embed.lib embed SAPI, static, imports the engine
lib/php8ts.lib import library for php8ts.dll
bin/php8ts.dll the engine: ship it next to the consuming .exe
bin/*.dll engine + extension dependency DLLs (OpenSSL, ICU, ...)
bin/ext/php_*.dll official shared extensions
ephpm-sdk.json php_version, php_api_no, zts, crt, and `preload`
LICENSE-PHP.txt, readme-redist-bins.txt, sbom/
```

Extensions the static SDK compiles in but the official build ships as DLLs
(`mbstring`, `openssl`, `curl`, `intl`, `pdo_mysql`, ... and `opcache` on 8.3
and 8.4) are listed, in a dependency-safe load order, under `preload` in
`ephpm-sdk.json`; a consumer loads them at startup to get the same extension
set as the static SDK. The VS toolset is the one windows.php.net uses for the
minor (`vs16` for 8.3, `vs17` for 8.4+), recorded as `crt`.

The same run publishes `ephpm-ext-<ver>-windows-x86_64.tar.gz` to the
`ext-<ver>` release: `php_xdebug.dll` plus a `manifest.json` in the Linux
catalog's schema (with `"libc": "msvc"`, `"os": "windows"`).

```bash
gh workflow run windows-shared.yml -f php_version=8.5.7
```

Older releases move to windows.php.net's `archives/`, which publishes no
checksum list — pin their hashes in `checksums.txt` (the script prints the
hash to pin when one is missing). A new Xdebug version needs its three
`php_xdebug-<ver>-<minor>-ts-<vs>-x86_64.dll` hashes from xdebug.org added
there too.

## Tarball layout

```
Expand All @@ -112,7 +165,7 @@ THIRD-PARTY-NOTICES.txt
Assets are named:

```
php-sdk-{php_version}-{os}-{arch}[-gnu][-nts[-shared]][-clang].tar.gz
php-sdk-{php_version}-{os}-{arch}[-gnu][-nts[-shared]][-clang|-shared].tar.gz
```

### `bin/php-config`
Expand Down Expand Up @@ -148,7 +201,7 @@ Windows drops the Unix-only entries (`pcntl`, `posix`, `sysv*`), plus `gmp`, `pg

`ffi` is not in the shared extension set on purpose. static-php-cli's `ext-ffi` passes `--enable-zend-signals`, and extension arguments land after the target arguments on the configure line, so it would override the `--disable-zend-signals` that spc emits for ZTS builds — silently changing signal behavior in the SDK ePHPm links. NTS builds emit no `--disable-zend-signals`, so `ffi` rides along there.

Loadable **shared** ZTS extensions (`igbinary`, `msgpack`, `apcu`, `redis`, `mongodb`) are a separate artifact built by `.github/workflows/extensions.yml` and published under `ext-<version>` tags. That catalog is ZTS-only by design: Debian and Sury publish no ZTS builds, which is the gap it fills. There is no NTS catalog.
Loadable **shared** ZTS extensions (`igbinary`, `msgpack`, `apcu`, `redis`, `mongodb`) are a separate artifact built by `.github/workflows/extensions.yml` and published under `ext-<version>` tags. That catalog is ZTS-only by design: Debian and Sury publish no ZTS builds, which is the gap it fills. There is no NTS catalog. Windows has a catalog entry for Xdebug only (`ephpm-ext-<ver>-windows-x86_64.tar.gz`, from `windows-shared.yml`); it loads only into a binary linked against the `-windows-x86_64-shared` SDK.

## Building

Expand Down Expand Up @@ -242,3 +295,5 @@ then builds with `PHP_SDK_PATH=php-sdk cargo build --release`.
The MIT license in this repository covers the workflows and scripts here. It does **not** cover the contents of the published tarballs: those are an aggregate of PHP (PHP License 3.01 / Zend Engine License 2.00) and roughly twenty upstream libraries, each under its own terms — including a bundled `libstdc++.a` carrying the GCC Runtime Library Exception.

Every tarball ships a `THIRD-PARTY-NOTICES.txt` listing the components, their SPDX identifiers, and where to get the full license texts. Read it before redistributing anything built from this SDK.

The `-windows-x86_64-shared` tarball is the exception: it is the official windows.php.net binary distribution repackaged unmodified, so it carries that distribution's own notices instead — `LICENSE-PHP.txt` (PHP's `license.txt`), `readme-redist-bins.txt` (the bundled third-party DLLs and their licenses) and the upstream SBOM under `sbom/`. Xdebug (`ephpm-ext-<ver>-windows-x86_64.tar.gz`) is under the Xdebug License.
31 changes: 31 additions & 0 deletions tools/windows-shared/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Trusted sha256 pins for tools/windows-shared/package.ps1, in sha256sum
# format ("<hex> *<file name>"). Consulted before the live
# windows.php.net/downloads/releases/sha256sum.txt, which only lists the
# CURRENT patch release of each minor: older releases move to
# releases/archives/, which publishes no checksum list, so building an older
# pinned release needs its hashes here.
#
# Provenance:
# - php_xdebug-*.dll: copied from the SHA256 values published on
# https://xdebug.org/download (cross-checked against the downloaded files).
# - php-*-Win32-*.zip / php-devel-pack-*: hashed from the windows.php.net
# archives on 2026-10-10 (no upstream list exists for archived releases).
# A release that is still current is covered by the live list and needs
# no entry here; pin it before it is archived if it must stay buildable.

# Xdebug 3.5.3 (ZTS, x64)
c178f05068a6f0cef4a37eaca6003a56120004bf4ac20db6ff20f6f1ce0b439e *php_xdebug-3.5.3-8.3-ts-vs16-x86_64.dll
b9c79caec87f2b289df4b7bfa64b64f01c97956c9ac7ddb936302b79aec65cda *php_xdebug-3.5.3-8.4-ts-vs17-x86_64.dll
c75623ba050ddef734ba28a957e92df9ce5b8dfdb1a0569e5071bd6b68a12292 *php_xdebug-3.5.3-8.5-ts-vs17-x86_64.dll

# PHP 8.3.33 (vs16)
b089e370ff99eb7038b0d22617dec2f3a1d0e93ca26b11fd218f2f5b60422271 *php-8.3.33-Win32-vs16-x64.zip
d58cedfa76b74b49f88ee54d25426700a27dad76dbad4732440cf28ca8267a7c *php-devel-pack-8.3.33-Win32-vs16-x64.zip

# PHP 8.4.23 (vs17)
6cb93c23c5e87237881f2b3d8b93fdd70ff04a4a32bc16c9cf846aeb17f518dc *php-8.4.23-Win32-vs17-x64.zip
f2774e1534586769b90ad5550d4c1658f522bcca8d711a231d5d19abeaa7d25b *php-devel-pack-8.4.23-Win32-vs17-x64.zip

# PHP 8.5.7 (vs17)
0e8a7a368de950408e1df5d34a5a9deb3817e434007f28f310e6674354ed8d06 *php-8.5.7-Win32-vs17-x64.zip
e59d547f68d42b08051f597d63df27781dc39b92163439b1267f5a7d753f64e4 *php-devel-pack-8.5.7-Win32-vs17-x64.zip
Loading
Loading