Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7a8a7ed
:wrench: add libpdfium static build (ubuntu-only)
sebO-S Oct 16, 2026
9523599
add temp push trigger
sebO-S Oct 16, 2026
cbee2b0
add tools folder + build script
sebO-S Oct 16, 2026
f928cec
add missing gitignore entry
sebO-S Oct 16, 2026
ecf3ca8
fix missing script + add retry to Ci
sebO-S Oct 16, 2026
73b6d5b
update script
sebO-S Oct 16, 2026
f7ead5d
fix install script for stati build
sebO-S Oct 19, 2026
a9be931
fix issues
sebO-S Oct 19, 2026
5d5b135
bump deps
sebO-S Oct 19, 2026
8c04c15
fix
sebO-S Oct 19, 2026
cd003e2
fix stale build + add logging + limit parallel
sebO-S Oct 19, 2026
a921d83
edit job-order + add static tests
sebO-S Oct 19, 2026
ca0a969
fix wf
sebO-S Oct 19, 2026
8cf90c1
add mandatory push trigger to run job once
sebO-S Oct 19, 2026
5de4a56
fix versions
sebO-S Oct 19, 2026
d973ca2
build macos & musl
sebO-S Oct 19, 2026
a2230fe
use local musl toolchain + fix python script for macOS
sebO-S Oct 19, 2026
548c459
update tests + fix retry loop
sebO-S Oct 19, 2026
651f29c
retrocompat justfile
sebO-S Oct 19, 2026
c29d5ad
fix entire static linking logic + clean build script
sebO-S Oct 19, 2026
16b6132
fix linking
sebO-S Oct 19, 2026
98abe9a
try add windows
sebO-S Oct 19, 2026
a7c3c66
switch to bash for windows CI
sebO-S Oct 20, 2026
fc6bcf8
debug, show output
sebO-S Oct 20, 2026
e99283b
debug, show output
sebO-S Oct 20, 2026
3863857
fix script
sebO-S Oct 20, 2026
10fa238
fix windows build gain
sebO-S Oct 20, 2026
bd6a491
fix typo
sebO-S Oct 20, 2026
3b1f683
more monkeypatching
sebO-S Oct 20, 2026
d369197
add debug dump for windows
sebO-S Oct 20, 2026
0b06ed9
debug win again
sebO-S Oct 20, 2026
f96baaf
trigger only on last job
sebO-S Oct 20, 2026
1fd54fc
fix diagnosis steps
sebO-S Oct 20, 2026
479890c
fix windows?
sebO-S Oct 20, 2026
42a2c46
more fixes for windows build + testing
sebO-S Oct 20, 2026
17a0f80
don't clone in build
sebO-S Oct 20, 2026
780a0aa
run tests
sebO-S Oct 20, 2026
247a4ea
fiddle with windows build again
sebO-S Oct 20, 2026
175e074
fix... again
sebO-S Oct 20, 2026
30c4d9b
fix script etc.
sebO-S Oct 20, 2026
8588798
fix
sebO-S Oct 20, 2026
b95afae
fix link.exe
sebO-S Oct 20, 2026
3c807c5
fix script
sebO-S Oct 21, 2026
af785f0
fix accidentally removed line
sebO-S Oct 21, 2026
f59acf3
fix patch
sebO-S Oct 21, 2026
62e1621
fix typo in script
sebO-S Oct 21, 2026
3eca580
fix build
sebO-S Oct 21, 2026
baec6c1
fix tests
sebO-S Oct 21, 2026
fcd5baa
fix naming error
sebO-S Oct 21, 2026
0a141c2
rebuild static always
sebO-S Oct 21, 2026
e8183cc
clean a bit of stale code
sebO-S Oct 21, 2026
6c4e653
add checksums
sebO-S Oct 21, 2026
003ce19
cleanup most incomprehensible code
sebO-S Oct 21, 2026
9f3ec10
fix sha check for windows
sebO-S Oct 21, 2026
8717364
add two target builds
sebO-S Oct 22, 2026
6b15574
last edits?
sebO-S Oct 22, 2026
4049fb3
Refactor target configuration for Windows platform
sebO-S Oct 22, 2026
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
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ rustflags = [
"-C", "link-arg=dynamic_lookup",
]

[target.'cfg(all(target_os = "windows", target_env = "msvc"))']
# A static PDFium leaves its Windows API imports to the final link, including pdfium-render's
# own DLL link, which core/build.rs can't reach. Unused import libraries cost nothing.
rustflags = ["-l", "dylib=gdi32", "-l", "dylib=user32", "-l", "dylib=advapi32"]

# pdfium's renderer is not thread-safe; run all tests sequentially to avoid
# heap corruption (SIGABRT) when multiple tests exercise pdfium concurrently.
[env]
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/_php-binding-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ jobs:
uses: actions/cache@v6
with:
path: core/.pdfium_cache
key: pdfium-${{ runner.os }}-${{ hashFiles('core/build.rs') }}
restore-keys: |
pdfium-${{ runner.os }}-
# Keyed on the release itself, with no fallback: an older release must never be restored.
key: pdfium-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('core/pdfium-release') }}

- uses: extractions/setup-just@v4

Expand Down
202 changes: 202 additions & 0 deletions .github/workflows/_php-static-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: PHP binding tests (static lib build)

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
php-binding-tests:
name: Test static PHP binding (${{ matrix.platform.pdfium_target }}, PHP ${{ matrix.php }} ${{ matrix.thread_safety }})
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- { runner: ubuntu-latest, pdfium_target: linux-x64-glibc }
- { runner: ubuntu-24.04-arm, pdfium_target: linux-arm64-glibc }
- { runner: macos-latest, pdfium_target: mac-arm64 }
- { runner: macos-15-intel, pdfium_target: mac-x64 }
php: [ "8.1", "8.2", "8.3", "8.4", "8.5" ]
thread_safety: [ "zts", "nts" ]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Download static PDFium
env:
GH_TOKEN: ${{ github.token }}
run: |
bash tools/pdfium-static/download.sh ${{ matrix.platform.pdfium_target }} "$RUNNER_TEMP/pdfium-static"
echo "PDFIUM_STATIC_LIB_PATH=$RUNNER_TEMP/pdfium-static" >> "$GITHUB_ENV"

- uses: extractions/setup-just@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@1.99.0

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: php-static-${{ matrix.platform.pdfium_target }}-php${{ matrix.php }}-${{ matrix.thread_safety }}

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
env:
phpts: ${{ matrix.thread_safety }}

- name: Build and test (static PDFium)
run: just php test-static

- name: Check the extension doesn't load PDFium dynamically (macOS)
if: runner.os == 'macOS'
run: |
deps="$(otool -L target/release/libbernard_ledit_php.dylib)"
echo "$deps"
if grep -qi pdfium <<< "$deps"; then
echo "::error::The extension links PDFium dynamically"
exit 1
fi

# The extension must load on the oldest glibc the static PDFium was built against.
- name: Check the extension doesn't load PDFium dynamically and runs on glibc 2.35 (Linux)
if: runner.os == 'Linux'
run: |
ext=target/release/libbernard_ledit_php.so
deps="$(ldd "$ext")"
echo "$deps"
if grep -qi pdfium <<< "$deps"; then
echo "::error::The extension links PDFium dynamically"
exit 1
fi
newest_glibc="$(objdump -T "$ext" | grep -oE 'GLIBC_[0-9]+(\.[0-9]+)*' | sed 's/GLIBC_//' | sort -Vu | tail -n 1)"
echo "Newest glibc symbol version required: $newest_glibc"
if [ "$(printf '%s\n' "$newest_glibc" 2.35 | sort -V | tail -n 1)" != 2.35 ]; then
echo "::error::The extension requires glibc $newest_glibc, newer than 2.35"
exit 1
fi

# Alpine runs through `docker run` rather than a job container: GitHub can't run JavaScript
# actions inside Alpine containers on arm64 runners.
php-binding-tests-musl:
name: Test static PHP binding (${{ matrix.platform.pdfium_target }}, PHP ${{ matrix.php }} ${{ matrix.thread_safety }})
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- { runner: ubuntu-latest, pdfium_target: linux-x64-musl }
- { runner: ubuntu-24.04-arm, pdfium_target: linux-arm64-musl }
php: [ "8.1", "8.2", "8.3", "8.4", "8.5" ]
thread_safety: [ "zts", "nts" ]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Download static PDFium
env:
GH_TOKEN: ${{ github.token }}
run: bash tools/pdfium-static/download.sh ${{ matrix.platform.pdfium_target }} .pdfium-static

# Rust links the C runtime statically on musl by default, which a PHP extension must not do.
- name: Build and test in Alpine
env:
IMAGE: php:${{ matrix.php }}-${{ matrix.thread_safety == 'zts' && 'zts' || 'cli' }}-alpine
run: |
docker run --rm -v "$PWD:/w" -w /w \
-e PDFIUM_STATIC_LIB_PATH=/w/.pdfium-static \
-e RUSTFLAGS="-C target-feature=-crt-static" \
"$IMAGE" sh -euc '
apk add --no-cache bash git curl unzip build-base cmake nasm clang-dev linux-headers just rustup libstdc++
rustup-init -y --default-toolchain none --profile minimal
. "$HOME/.cargo/env"
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
just php test-static
deps="$(ldd target/release/libbernard_ledit_php.so 2>/dev/null || true)"
echo "$deps"
if echo "$deps" | grep -qi pdfium; then
echo "The extension links PDFium dynamically" >&2
exit 1
fi
'

php-binding-tests-windows:
name: Test static PHP binding (${{ matrix.pdfium_target }}, PHP ${{ matrix.php }} ${{ matrix.thread_safety }})
runs-on: windows-latest
env:
# ext-php-rs needs nightly on Windows (vectorcall ABI); this overrides rust-toolchain.toml.
RUSTUP_TOOLCHAIN: nightly
strategy:
fail-fast: false
matrix:
php: [ "8.1", "8.2", "8.3", "8.4", "8.5" ]
thread_safety: [ "zts", "nts" ]
# The extension must link with the MSVC toolset its PHP version was built with.
include:
- { php: "8.1", msvc: "14.29", pdfium_target: win-x64-v142 }
- { php: "8.2", msvc: "14.29", pdfium_target: win-x64-v142 }
- { php: "8.3", msvc: "14.29", pdfium_target: win-x64-v142 }
- { php: "8.4", msvc: "14.44", pdfium_target: win-x64-v143 }
- { php: "8.5", msvc: "14.44", pdfium_target: win-x64-v143 }
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Download static PDFium
env:
GH_TOKEN: ${{ github.token }}
run: |
bash tools/pdfium-static/download.sh ${{ matrix.pdfium_target }} "$RUNNER_TEMP/pdfium-static"
echo "PDFIUM_STATIC_LIB_PATH=$RUNNER_TEMP/pdfium-static" >> "$GITHUB_ENV"

- uses: extractions/setup-just@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: php-static-${{ matrix.pdfium_target }}-php${{ matrix.php }}-${{ matrix.thread_safety }}

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
env:
phpts: ${{ matrix.thread_safety }}

- name: Pin the MSVC toolset of the PHP build
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
toolset: ${{ matrix.msvc }}

# Git Bash puts its GNU link.exe ahead of MSVC's on PATH, where Rust looks up the linker.
- name: Remove Git's GNU link.exe
run: rm -f "/c/Program Files/Git/usr/bin/link.exe"

- name: Build and test (static PDFium)
run: just php test-static

- name: Check the extension doesn't load PDFium dynamically
run: |
imports="$("/c/Program Files/LLVM/bin/llvm-readobj.exe" --coff-imports target/release/bernard_ledit_php.dll | grep -i '^ *Name:' || true)"
echo "$imports"
if grep -qi pdfium <<< "$imports"; then
echo "::error::The extension links PDFium dynamically"
exit 1
fi
Loading
Loading