Route hosted fs/time/rand exe builds through the capable direct backend#118
Open
WalterGropius wants to merge 2 commits into
Open
Route hosted fs/time/rand exe builds through the capable direct backend#118WalterGropius wants to merge 2 commits into
WalterGropius wants to merge 2 commits into
Conversation
The bare direct-exe path rejected any program touching std.fs/std.time/ std.rand with CGEN004 because self_host_subset_compatible() blocks all host capabilities, even though the ELF64 x86-64 emitter lowers those operations as inline syscalls and produces a self-contained static executable. Permit the default direct-exe path for hosted programs when the selected emitter can lower them; emitters without that lowering still report CGEN004 at emit time, keeping unsupported targets honest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Assert std.fs programs build a self-contained ELF64 executable (no generated C, no manual cc) instead of the prior CGEN004 fallback, reusing the existing runnable-target gating. Document the direct-backend behavior for hosted fs/time/rand in the CLI reference. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@WalterGropius is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zero run/zero build --emit exefor hostedstd.fs/std.time/std.randprograms rejected withCGEN004even on direct emitters that fully lower those operations.cc, no generated C).CGEN004at emit time, so unsupported targets stay honest.Source
Addresses P0-3. Reproduction confirmed against main @ 5b91e7f (host darwin-arm64).
Before this change, on the unmodified compiler:
zero build --emit exe --target linux-musl-x64 conformance/native/pass/std-fs.0→CGEN004: direct backend does not support target 'linux-musl-x64' for --emit exezero build --emit obj --target linux-musl-x64 conformance/native/pass/std-fs.0→ succeeds (1944-byte ELF64 object; the ELF64 emitter lowers allstd.fsoperations as inline syscalls).Root cause: the exe path's
default_direct_exegate callsself_host_subset_compatible(), which returns false whenever any host capability (fs/time/rand/net/proc/web) is used.ir_needs_zero_runtime_object()only recognizes JSON/HTTP, so fs/time/rand programs never reach the runtime-link plan either and fall through toCGEN004, despite the ELF64 exe emitter being fully capable of producing a self-contained static binary for them.Changes
native/zero-c/src/main.c: adddirect_exe_emitter_handles_hosted_runtime()/direct_exe_supports_hosted_program(); use them in thedefault_direct_exedecision at the build dispatch and the parallel target-readiness diagnostic. Gated tozero-elf64-exe(the only emitter with inline-syscall fs/time/rand lowering). Updated theCGEN004zero explainrationale.conformance/run.mjs: addassertHostedDirectExeand registerstd-fs.0,std-fs-bytes.0,std-fs-fallible.0; asserts a self-contained ELF64 executable (generatedCBytes:0, validET_EXECx86-64) and runs it on linux-x64 hosts via the existingcanRunLinuxMuslX64gating. Append-only.docs-site/articles/cli-reference.md: document direct-backend behavior for hostedstd.fs/std.time/std.randin the Run section.Conformance
conformance/native/pass/std-fs.0,conformance/native/pass/std-fs-bytes.0,conformance/native/pass/std-fs-fallible.0(registered via newassertHostedDirectExe).ZERO_NATIVE_TEST_ALLOW_LOCAL=1 pnpm run conformance:local→ green (conformance ok,provenance guardrails ok).ZERO_NATIVE_TEST_ALLOW_LOCAL=1 pnpm run command-contracts:local→ green (command contract snapshots ok).ZERO_NATIVE_TEST_ALLOW_LOCAL=1 pnpm run native:test:local→ fails at a pre-existing, environment-only point: line 133 builds the JSON programstd-json-duplicate-keys.0forlinux-musl-x64, which uses the unrelated runtime-link plan and requireszig(not installed on this host). Verified identical failure at the same line on unmodifiedmain; not introduced by this change. Sandbox variant unavailable here (VERCEL_OIDC_TOKENnot present).Regression checks: darwin-arm64 host
std.fsstill correctlyCGEN004(Mach-O AArch64 has no fs lowering);hello.0host run,std-args.0exe, andstd-http-fetch.0runtime-link run all unchanged.Proposed CHANGELOG line
std.fs/std.time/std.randprograms build as self-contained direct executables on backends that lower them (ELF64 x86-64), instead of failing withCGEN004.🤖 Generated with Claude Code