Skip to content

D30 R4c: a runtime function is safe by declaration; the migrator writes no unsafe around a runtime call; corpora re-promoted - #2504

Merged
ehartford merged 6 commits into
mainfrom
r4c
Oct 21, 2026
Merged

ehartford merged 6 commits into
mainfrom
r4c

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

D30 R4c: a runtime function is safe by declaration. Three commits: the migrator stops wrapping a runtime helper call in unsafe and the four corpora re-promote without the 85 wrappers (D112 reason 3); the Sema transition branch that counted such a call as an unsafe operation is retired (a vacuous block is refused); docs. Completes R4a–R4c of the D30 plan.

Gate and battery: posted below.

Eric Hartford added 6 commits October 20, 2026 17:21
… re-promoted without the wrappers

The shim reaches with_alloc, with_memcpy, with_clz, … through the runtime
interface (`use rt.rt_core`, step 3), where each is a safe `pub fn`: an
`unsafe { with_alloc(...) }` is a block with no unsafe operation. The
migrator no longer wraps a runtime helper call (the variadic pair stays
wrapped: it writes through its list); the four corpora are re-promoted
(D112 reason 3) — 85 wrappers gone across c_algorithms, zlib, pcre2 and
tommyds, nothing else changed. c-migrator-basic-tests green.
…branch is retired (R4c)

The branch counted any with_*/rt_*/wl_* call inside `unsafe` as an unsafe
operation so a block written for the extern world stayed honest. With the
runtime a definition in every unit and the corpora free of the migrator's
wrappers (previous commit), the declaration decides: an `unsafe` block
whose only content is a call of a safe runtime function is vacuous and
refused. R4a–R4c of the D30 plan are complete.
…dules unwrapped

The battery found two things the measurement over src/main.w could not: a
`c_import` translation declares the runtime helpers as externs of its own
unit (raw c_import functions), so `with_alloc_zeroed` there still needs the
wrapper — the migrator keeps it outside the shared-defs std zone, exactly as
for the modeled libc names; and std.collections' hash_index, sorted_list,
trie and binary_heap (reached by stdlib-complexity and the behavior tests,
not by the compiler) carried fifteen vacuous `unsafe { with_… }` blocks,
now unwrapped. stage1 checks all four clean.
…d.collections unwrapped; one raw dereference keeps its own block

A generic body is checked at instantiation, so `with check` of the module
alone missed seven more blocks that stdlib-complexity reached: the
allocation `unsafe { with_alloc(...) } as *mut Slot` form, unwrapped with
balanced braces. The one block that also dereferenced a raw pointer
(sorted_list's insert) keeps an `unsafe` around that dereference alone.
stdlib-complexity, the three behavior fixtures and the drop audit green
under the release.
`with migrate` output compiles with the prelude, where the runtime's safe
definition resolves with_alloc whatever package the output lands in — the
three migrate fixtures that write a header into a package (lib/eng,
lib/probe) were refused for a vacuous wrapper. A `c_import` expansion has
no prelude and declares the helpers as externs of its own unit, so there
the wrapper stays. The corpus stamps follow the migrator generation; no
module changed. The three fixtures, c-migrator-basic-tests and
deep-debug-tool-tests green.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on 7b2493a (292 s, this Mac, seed nightly-20261020-local-2): gate (116 s), uat, battery-checks. Corpora re-promoted without their 85 unsafe { with_* } wrappers; stdlib-complexity, the migrate fixtures, c-migrator-basic-tests, deep-debug-tool-tests and the drop audit green along the way.

@ehartford
ehartford marked this pull request as ready for review October 21, 2026 01:09
@ehartford
ehartford merged commit 3d4c846 into main Oct 21, 2026
@ehartford
ehartford deleted the r4c branch October 21, 2026 01:09
ehartford added a commit that referenced this pull request Oct 21, 2026
…eclared it (R4c) (#2505)

`:release-checks` on main after #2504 was red in c-migrator-core-tests:
direct_runtime_memory_calls declares `extern void with_memset(...)` in the C
source itself, so the call took the user-extern path and kept its wrapper —
vacuous, since in `with migrate` output the name is the runtime's safe
definition whoever declared it. The decision moves to the one entry point
(ci_migrate_call_requires_unsafe_wrapper); the corpus stamps follow the
migrator generation, no module changed. c-migrator-core-tests and
c-migrator-basic-tests green.

Co-authored-by: Eric Hartford <[email protected]>
@ehartford ehartford mentioned this pull request Oct 21, 2026
ehartford added a commit that referenced this pull request Oct 21, 2026
…#2508)

The first seeds built after the D30 step 4 flip (#2500) and R4c (#2504):
the runtime bundle is their only link path. darwin on the laptop, linux-
x86_64 on eric-5090, windows-x86_64 on win10, linux-aarch64 in the arm64
container (asset copied from out/release/bin/with, #2494), each from a
stage2 == stage3 fixpoint; windows-aarch64 is cross seed run 39537985417
(D137). Workflow pins rewritten by tools/bump_seed_pins.w.

Co-authored-by: Eric Hartford <[email protected]>
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.

1 participant