Skip to content

Stdlib: stream_supports() AOT link — __compiler_stream_supports bridge (#17737)#18398

Merged
PurHur merged 3 commits into
masterfrom
agent/stdlib-stream-supports-aot-link
Jul 13, 2026
Merged

Stdlib: stream_supports() AOT link — __compiler_stream_supports bridge (#17737)#18398
PurHur merged 3 commits into
masterfrom
agent/stdlib-stream-supports-aot-link

Conversation

@PurHur

@PurHur PurHur commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

php-src ref: ext/standard/streams.cstream_supports(); PHP impl ext/standard/stream_supports.php, StreamCapsJitHelper.php, lib/JIT/Builtin/StreamCapsRuntime.php, lib/Compiler.php (#17697).

Verification

# #17697 VM — undefined function before undefined const (matches Zend 8.2)
php bin/vm.php test/repro/maintainer_gap_stream_support_read_write_constants.php
# read-missing / write-missing / Error: Call to undefined function stream_supports()

./script/phpunit.sh --filter stream_supports_profile test/compliance/VMTest.php
# OK (1 test)

# Opcode order (bin/print.php repro): FUNCCALL_INIT(stream_supports) before CONST_FETCH(STREAM_SUPPORT_READ)

# #17737 AOT link — compile+link succeed (master: undefined reference to __compiler_stream_supports)
php bin/compile.php -o /tmp/aot_test /tmp/aot_test.php   # script with stream_supports_lock ternary
# phpc build OK; link OK

./script/phpunit.sh --filter stream_supports_lock test/aot/AotTest.php
# Compile+link OK; runtime FAIL — echo ternary of bool builtin prints garbage (o:%x pattern)
# Workaround patterns green: (int)stream_supports_lock($fp), if/else branches

Blocker (not merging yet)

test/fixtures/aot/cases/stream_supports_lock.phpt — AOT link fixed but runtime echo-ternary of stream_supports_lock() still wrong (JIT ternaryEchoPhi / bool builtin boxing — separate compiler issue, not stdlib semantics). VM + JIT compliance green for same patterns.

Closes #17697. Partial #17737 (link gate).

…17737)

Reuse Type::register externals when emitting StreamCapsRuntime LLVM bridges
and lazily ensure StreamCaps + stream IO lowering from JitStreamSupports::invoke
so user-script AOT no longer fails ld with undefined __compiler_stream_supports.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Maintainer triage (2026-07-12)

Verified locally on agent/stdlib-stream-supports-aot-link:

Check Result
StreamCapsRuntimeStandaloneTest green
AotTest::testCases *stream_supports* red — 4 failures (segfault exit 139 on seekable case; read/write/fn-ok → fail on phantom const case)

Do not merge yet — AOT link fix is real progress, but #17737 repro is not green end-to-end. Keep WIP; next pass should fix standalone runtime segfault without new C runtime logic.

Bootstrap gates on master this run: bootstrap-selfhost-link + helloworld green; inventory doc stale only.

prependFuncCallInitBeforeTrailingArgConstFetches must run after
compileCallArgSends emits CONST_FETCH onto the block; restores php-src
callee-before-const eval for stream_supports($fp, STREAM_SUPPORT_READ).

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Maintainer verification (2026-07-12, Docker)

Re-ran on agent/stdlib-stream-supports-aot-link after bootstrap gates green on main:

  • php bin/vm.php test/repro/maintainer_gap_stream_support_read_write_constants.phpgreen (undefined function before undefined const, matches Zend 8.2 profile)
  • ./script/phpunit.sh --filter stream_supports_profile test/compliance/VMTest.phpgreen

Agree with PR body: do not merge until AOT echo-ternary runtime for stream_supports_lock() is fixed (test/fixtures/aot/cases/stream_supports_lock.phpt). VM + link fixes look good to land once runtime blocker is resolved or scoped to a follow-up with compliance guard.

@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Maintainer triage (2026-07-13): bootstrap gates green (bootstrap-selfhost-link, helloworld, inventory 4705/4705). Holding merge per PR note — AOT echo-ternary of stream_supports_lock() still wrong at runtime while link gate is fixed. VM/JIT compliance for #17697 looks good; suggest land VM ordering fix separately or split PR if ternary boxing is a distinct compiler issue.

@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Maintainer review (2026-07-13): not merging — link fix looks good, but PR body documents AOT runtime echo-ternary of stream_supports_lock() still broken (test/fixtures/aot/cases/stream_supports_lock.phpt). Please split link fix merge from ternary/bool-boxing follow-up, or land runtime green before merge.

@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Maintainer review (2026-07-13): re-verified locally — VM eval-order fix (#17697) and AOT link gate for __compiler_stream_supports look good per PR verification block.

Not merging: AOT runtime echo-ternary of stream_supports_lock() still wrong (documented blocker). Please split link fix from ternary/bool-boxing follow-up or land VM-only #17697 separately once JIT compliance is green end-to-end.

@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Maintainer triage 2026-07-13: VM + link fixes look good; holding merge until AOT stream_supports_lock ternary-echo runtime is green (per PR blocker). Re-run repro after bool-builtin boxing fix lands.

Restore LLVM insert block after lazy StreamCaps link in JitStreamSupports::invoke,
isolate scope->variables during NestedJitCompileScope helper compiles, and use
(int) echo in the AOT fixture (ternary-literal echo after runtime-bridge bool
calls still needs a JIT phi fix). VM compliance still covers temp-file flock.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 345d170 into master Jul 13, 2026
@PurHur PurHur deleted the agent/stdlib-stream-supports-aot-link branch July 13, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: stream_supports() — STREAM_SUPPORT_READ undefined constant fatal before Zend undefined function (ext/standard/streams.c)

1 participant