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
39 changes: 39 additions & 0 deletions .github/workflows/release-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,45 @@ jobs:
uses: "./.github/workflows/wasix-pr.yaml"
needs: version-check

create-libphp-release:
runs-on: ubuntu-latest
needs:
- build-and-test
- version-check
permissions:
contents: write
steps:
- name: Download libphp artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts

- name: Package libphp artifacts
run: |
TAG_NAME=${{github.ref_name}}
VERSION_NUMBER=${TAG_NAME#dev-}

# Package 32-bit libphp
cd release-artifacts/libphp-wasix-32
tar -czf ../libphp-wasix-32-${VERSION_NUMBER}.tar.gz *
cd ../..

# Package 64-bit libphp
cd release-artifacts/libphp-wasix-64
tar -czf ../libphp-wasix-64-${VERSION_NUMBER}.tar.gz *
cd ../..

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
release-artifacts/libphp-wasix-32-*.tar.gz
release-artifacts/libphp-wasix-64-*.tar.gz
draft: false
prerelease: true
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}

release:
runs-on: ubuntu-latest
needs:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,45 @@ jobs:
uses: "./.github/workflows/wasix-pr.yaml"
needs: version-check

create-libphp-release:
runs-on: ubuntu-latest
needs:
- build-and-test
- version-check
permissions:
contents: write
steps:
- name: Download libphp artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts

- name: Package libphp artifacts
run: |
TAG_NAME=${{github.ref_name}}
VERSION_NUMBER=${TAG_NAME#dev-}

# Package 32-bit libphp
cd release-artifacts/libphp-wasix-32
tar -czf ../libphp-wasix-32-${VERSION_NUMBER}.tar.gz *
cd ../..

# Package 64-bit libphp
cd release-artifacts/libphp-wasix-64
tar -czf ../libphp-wasix-64-${VERSION_NUMBER}.tar.gz *
cd ../..

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
release-artifacts/libphp-wasix-32-*.tar.gz
release-artifacts/libphp-wasix-64-*.tar.gz
draft: false
prerelease: true
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}

release:
runs-on: ubuntu-latest
needs:
Expand Down
74 changes: 72 additions & 2 deletions .github/workflows/wasix-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
sudo cp binaryen-version_123/bin/* /usr/bin/

- name: Install wasixcc
uses: wasix-org/wasixcc@main
uses: wasix-org/wasixcc@0.4.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
sysroot-tag: v2026-02-16.1
Expand Down Expand Up @@ -69,10 +69,10 @@ jobs:

- name: Build
run: |
export SYSROOT=$(pwd)/sysroot/wasix-sysroot-eh/sysroot
export PHP_WASIX_DEPS=$(pwd)/php-wasix-deps
cd php
bash wasix-configure-eh-${{ matrix.variant }}.sh || { cat config.log; exit -1; }
bash wasix-build-eh.sh

- name: Setup Wasmer
uses: wasmerio/setup-wasmer@v3.1
Expand All @@ -92,3 +92,73 @@ jobs:
with:
name: php-wasix-${{ matrix.variant }}
path: php/sapi/cli/php.wasm

build-libphp:
name: Build libphp
runs-on: ubuntu-latest
strategy:
matrix:
variant: ["32", "64"]
steps:
- name: Check out
uses: actions/checkout@v3
with:
submodules: "recursive"
path: php

- name: Check out php-wasix-deps
uses: actions/checkout@v3
with:
repository: wasix-org/php-wasix-deps
submodules: "recursive"
path: php-wasix-deps

- name: OS Setup (Ubuntu)
run: |
sudo apt-get update
sudo apt-get install -y build-essential wabt re2c curl xz-utils tar
npm i -g pnpm concurrently

wget https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-linux.tar.gz
tar -xzf binaryen-version_123-x86_64-linux.tar.gz
sudo cp binaryen-version_123/bin/* /usr/bin/

- name: Install wasixcc
uses: wasix-org/wasixcc@0.4.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
sysroot-tag: v2026-02-16.1
version: v0.3.0

- name: Tool Versions
run: |
echo wasixcc
wasixcc -v
echo '####################'
echo wasixar
wasixar -V
echo '####################'
echo wasixnm
wasixnm -V
echo '####################'
echo wasixranlib
wasixranlib -V
echo '####################'
echo wasm-opt
wasm-opt --version
echo '####################'
echo wasm-strip
wasm-strip --version

- name: Build
run: |
export PHP_WASIX_DEPS=$(pwd)/php-wasix-deps
cd php
bash wasix-configure-libphp-${{ matrix.variant }}.sh || { cat config.log; exit -1; }
bash wasix-build-libphp.sh

- name: Archive build
uses: actions/upload-artifact@v4
with:
name: libphp-wasix-${{ matrix.variant }}
path: php/install
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ php.wasm
# Standard object files generated by Visual Studio
*.obj

# Install dir
/install

# ------------------------------------------------------------------------------
# Tests
# ------------------------------------------------------------------------------
Expand Down
33 changes: 20 additions & 13 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "zend_accelerator_util_funcs.h"
#include "zend_accelerator_hash.h"
#include "zend_file_cache.h"
#include "zend_atomic.h"
#include "ext/pcre/php_pcre.h"
#include "ext/standard/md5.h"
#include "ext/hash/php_hash.h"
Expand Down Expand Up @@ -143,6 +144,12 @@ static void preload_restart(void);
# define INCREMENT(v) InterlockedIncrement64(&ZCSG(v))
# define DECREMENT(v) InterlockedDecrement64(&ZCSG(v))
# define LOCKVAL(v) (ZCSG(v))
#elif defined(__wasi__)
static uint32_t accel_wasi_mem_usage = 0;
static uint32_t accel_wasi_restart_in = 0;
# define INCREMENT(v) __atomic_add_fetch(&accel_wasi_##v, 1, __ATOMIC_SEQ_CST)
# define DECREMENT(v) __atomic_sub_fetch(&accel_wasi_##v, 1, __ATOMIC_SEQ_CST)
# define LOCKVAL(v) __atomic_load_n(&accel_wasi_##v, __ATOMIC_SEQ_CST)
#endif

#define ZCG_KEY_LEN (MAXPATHLEN * 8)
Expand Down Expand Up @@ -266,7 +273,7 @@ static ZEND_INI_MH(accel_include_path_on_modify)

static inline void accel_restart_enter(void)
{
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
INCREMENT(restart_in);
#elif !defined(__wasi__)
struct flock restart_in_progress;
Expand All @@ -285,7 +292,7 @@ static inline void accel_restart_enter(void)

static inline void accel_restart_leave(void)
{
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
ZCSG(restart_in_progress) = false;
DECREMENT(restart_in);
#elif !defined(__wasi__)
Expand All @@ -306,7 +313,7 @@ static inline void accel_restart_leave(void)
static inline int accel_restart_is_active(void)
{
if (ZCSG(restart_in_progress)) {
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
return LOCKVAL(restart_in) != 0;
#elif !defined(__wasi__)
struct flock restart_check;
Expand Down Expand Up @@ -334,7 +341,7 @@ static inline int accel_restart_is_active(void)
/* Creates a read lock for SHM access */
static inline zend_result accel_activate_add(void)
{
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
SHM_UNPROTECT();
INCREMENT(mem_usage);
SHM_PROTECT();
Expand All @@ -357,7 +364,7 @@ static inline zend_result accel_activate_add(void)
/* Releases a lock for SHM access */
static inline void accel_deactivate_sub(void)
{
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
if (ZCG(counted)) {
SHM_UNPROTECT();
DECREMENT(mem_usage);
Expand All @@ -380,7 +387,7 @@ static inline void accel_deactivate_sub(void)

static inline void accel_unlock_all(void)
{
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
accel_deactivate_sub();
#elif !defined(__wasi__)
if (lock_file == -1) {
Expand Down Expand Up @@ -892,7 +899,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)

static inline bool accel_is_inactive(void)
{
#ifdef ZEND_WIN32
#if defined(ZEND_WIN32) || defined(__wasi__)
/* on Windows, we don't need kill_all_lockers() because SAPIs
that work on Windows don't manage child processes (and we
can't do anything about hanging threads anyway); therefore
Expand Down Expand Up @@ -2823,6 +2830,7 @@ static inline zend_result accel_find_sapi(void)
"fuzzer",
"frankenphp",
"ngx-php",
"phpix",
NULL
};
const char **sapi_name;
Expand Down Expand Up @@ -2921,6 +2929,10 @@ static zend_result zend_accel_init_shm(void)
ZCSG(start_time) = zend_accel_get_time();
ZCSG(last_restart_time) = 0;
ZCSG(restart_in_progress) = false;
#ifdef __wasi__
__atomic_store_n(&accel_wasi_mem_usage, 0, __ATOMIC_SEQ_CST);
__atomic_store_n(&accel_wasi_restart_in, 0, __ATOMIC_SEQ_CST);
#endif

for (i = 0; i < -HT_MIN_MASK; i++) {
ZCSG(uninitialized_bucket)[i] = HT_INVALID_IDX;
Expand All @@ -2942,7 +2954,7 @@ void accel_globals_ctor(zend_accel_globals *accel_globals)
}

#ifdef ZTS
static void accel_globals_dtor(zend_accel_globals *accel_globals)
void accel_globals_dtor(zend_accel_globals *accel_globals)
{
zend_string_free(accel_globals->key);
}
Expand Down Expand Up @@ -3118,11 +3130,6 @@ static void accel_move_code_to_huge_pages(void)

int accel_startup(zend_extension *extension)
{
#ifdef ZTS
accel_globals_id = ts_allocate_id(&accel_globals_id, sizeof(zend_accel_globals), (ts_allocate_ctor) accel_globals_ctor, (ts_allocate_dtor) accel_globals_dtor);
#else
#endif

#ifdef HAVE_JIT
zend_jit_init();
#endif
Expand Down
3 changes: 3 additions & 0 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str);
uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name);

void accel_globals_ctor(zend_accel_globals *accel_globals);
#ifdef ZTS
void accel_globals_dtor(zend_accel_globals *accel_globals);
#endif

END_EXTERN_C()

Expand Down
6 changes: 5 additions & 1 deletion ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ static ZEND_MINIT_FUNCTION(zend_accelerator)

// Run the ctor before registering the INI entries, as that will
// read and set the values
accel_globals_ctor(&accel_globals);
#ifdef ZTS
accel_globals_id = ts_allocate_id(&accel_globals_id, sizeof(zend_accel_globals), (ts_allocate_ctor) accel_globals_ctor, (ts_allocate_dtor) accel_globals_dtor);
#else
accel_globals_ctor(&accel_globals);
#endif

REGISTER_INI_ENTRIES();

Expand Down
12 changes: 9 additions & 3 deletions ext/opcache/zend_file_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@ static int zend_file_cache_flock(int fd, int op)
#elif defined(HAVE_FLOCK)
# define zend_file_cache_flock flock
#else
# define LOCK_SH 0
# define LOCK_EX 1
# define LOCK_UN 2
# ifndef LOCK_SH
# define LOCK_SH 0
# endif
# ifndef LOCK_EX
# define LOCK_EX 1
# endif
# ifndef LOCK_UN
# define LOCK_UN 2
# endif
static int zend_file_cache_flock(int fd, int type)
{
return 0;
Expand Down
Loading
Loading