Skip to content

php-in-php: VmGzStreamNative — pure PHP gz* stream I/O without libz FFI (#1492, ext/zlib/zlib.c) #8936

Description

@PurHur

Category

php-in-php | stdlib

Problem

ext/standard/VmGzStreamNative.php opens compress.zlib:// streams via libz FFI (gzopen, gzread, gzwrite, gzclose). Bootstrap and self-host paths already have pure-PHP zlib encode/decode (VmZlibNative, ext/zstd-style migration #8837); gz stream wrappers should follow the same PHP-in-PHP strategy.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
grep -c "FFI" ext/standard/VmGzStreamNative.php
php bin/vm.php test/repro-maintainer/gzcompress_native_only.php 2>/dev/null || true'

Add test/repro-maintainer/gz_stream_php_in_php_probe.php:

<?php
$path = sys_get_temp_dir() . '/phpc_gz_probe_' . getmypid() . '.gz';
$zp = gzopen($path, 'wb9');
gzwrite($zp, 'hello');
gzclose($zp);
$zr = gzopen($path, 'rb');
echo gzread($zr, 100), "\n";
gzclose($zr);
unlink($path);
Runtime Expected
Zend hello
VM today works via libz FFI

Done target: same output with no libz FFI in VmGzStreamNative.

Scope

Layer Path
PHP New ext/standard/VmGzStreamPure.php or extend VmZlibNative with stream handle table
VM ext/standard/gzopen.php, gzread.php, VmFs.php gz placeholder adoption
JIT lib/JIT/Builtin/GzStreamIoJit.php — share core with VM
Tests test/unit/VmZlibNativeTest.php, compliance gz stream PHPT

Done when (php-src-strict)

  • VmGzStreamNative FFI removed; gz stream repro passes on VM
  • Runtime-shrink unit test documents C/FFI symbols deleted
  • make north-star5-verify-fast green after self-host spine touches gz paths

Related

#6168 · #8837 · #8868 · #1492

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions