Skip to content

feat(ext): add ext-luasandbox and lua51 library - #1321

Open
atdt wants to merge 1 commit into
crazywhalecc:v3from
atdt:ext-luasandbox
Open

atdt wants to merge 1 commit into
crazywhalecc:v3from
atdt:ext-luasandbox

Conversation

@atdt

@atdt atdt commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #1319.

Adds the Lua 5.1 static library (lua51) and the ext-luasandbox PHP extension for Linux and Darwin:

  • config/pkg/lib/lua51.yml & src/Package/Library/lua51.php: fetches Lua 5.1 via filelist, builds liblua5.1.a with -DLUA_USE_POSIX (avoiding dlopen/-ldl on static Linux musl and deprecated dyld on macOS), and installs include/lua5.1/ and lua5.1.pc. Named lua51 with liblua5.1.a so a future Lua 5.4+ package can coexist without collisions.
  • config/pkg/ext/ext-luasandbox.yml & src/Package/Extension/luasandbox.php: enables ext-luasandbox (arg-type: with, depending on lua51) and patches config.m4 before buildconf for in-tree static builds (m4_include([m4/pkg.m4]) and PHP_ADD_MAKEFILE_FRAGMENT).
  • src/globals/ext-tests/luasandbox.php: smoke test exercising LuaSandbox memory limit and Lua execution.

Source note: ext-luasandbox.yml currently uses type: git (rev: master) because the latest tagged release (4.1.4) predates configure-time POSIX timer detection for macOS (8171f57e) and --with-luasandbox (6bbba545). Once Wikimedia tags the next release (T446458), we can switch this to ghtagtar or pie.

Testing:

  • Verified spc build:php-cli luasandbox (PHP 8.5.13) on macOS arm64 and Linux x86_64 musl (ZigToolchain), including ext-tests/luasandbox.php.
  • Verified LuaSandbox's full .phpt suite (26/26 passed, including timer.phpt and profiler.phpt) and setCPULimit() runtime enforcement on Linux x86_64 musl.

Checklist before merging

  • If you modified *.php or *.yml, run them locally to ensure your changes are valid:
    • composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:lint-config

Add the Lua 5.1 static library package (`lua51`, installing
`liblua5.1.a`, `include/lua5.1/`, and `lua5.1.pc`) and the
`ext-luasandbox` PHP extension package for Linux and Darwin, along with
a smoke test. Builds Lua with `-DLUA_USE_POSIX` and patches `config.m4`
for in-tree static PHP builds.

@henderkes henderkes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, but have you tested that this works? I tried once with Scribunto and it complained that lua 5.1 had to be installed on the system even if the extension was present. But that was a while ago and I didn't really investigate...

@crazywhalecc crazywhalecc added need-test This PR has not been tested yet, cannot merge now test/tier2 Trigger Tier 2 environment build test labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

StaticPHP Test Bot

Detected: Extensions: luasandbox | Libraries: lua51 | Targets: none
Active labels: test/tier2
Available labels: need-test (gate), test/linux test/windows test/macos (platform), test/tier2 (extra arch), test/php-83 test/php-84 test/php-86 (PHP version), sapi/frankenphp (extra FrankenPHP SAPI build)
Config: Linux x86_64 + Windows x86_64 + macOS arm64 + Linux aarch64 (Tier2) + macOS x86_64 (Tier2) | PHP 8.5 NTS

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-test This PR has not been tested yet, cannot merge now test/tier2 Trigger Tier 2 environment build test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v3] Add ext-luasandbox and lua 5.1 library

3 participants