Skip to content

lint.c: extract the 6 FREESTANDING blocks into a whole-TU-gated lint_host.c (the #741/#812 pattern) #813

Description

@InauguralPhysicist

Follow-up to #741, whose builtins.c half landed in #812lint.c still carries 6 EIGENSCRIPT_FREESTANDING blocks gating ~950 lines, and they should get the same whole-TU treatment now that src/builtins_host.c establishes the pattern in-tree.

The blocks (current main)

Lines Size What
~144–186 41L g_builtin_name_env + the E003 binding-base machinery
~850–1442 591L the --api surface index (eigs_api_dump + its lib scan over scandir)
~3164–3591 426L check_undefined_names (scope-aware name-resolution lint, #404)
~3601–3606 4L its call-site carve-out
~3726–3804 77L host arm of the lint file driver
~3827–3941 113L freestanding arm (dual-implementation eigs_lint_file)

Shape

Unlike the builtins.c case these are not "builtin groups behind a registration seam" — they're lint subsystems plus one dual-arm entry point. The extraction is a lint_host.c (or similar) following builtins_host.c's recipe:

  1. Whole TU behind #if !EIGENSCRIPT_FREESTANDING, with the #else arm holding the same linkable stubs the current freestanding arms provide (the ~113L freestanding eigs_lint_file variant moves there).
  2. Statics shared between moved and staying code get promoted with a declaration in an internal header — in build: host-only builtins move to one whole-TU-gated builtins_host.c (#741) #812 that was replay_blocks/g_argc/g_argv; here expect the binding-base env and whatever the lint driver shares.
  3. TU lists to update (all five, or the link breaks in a different harness than the one you tested): Makefile SOURCES, tools/freestanding_check.sh, tools/freestanding_smoke.sh, tools/embed_stack_soak.sh, web/build.sh.
  4. Planted-fault validation in both directions (see build: host-only builtins move to one whole-TU-gated builtins_host.c (#741) #812's Testing section): a host-TU symbol referenced from portable code must fail freestanding_check.sh stage 1 by name; a direct libc call from portable code must still fail by import.

Definition of done

  • lint.c's FREESTANDING block count drops to ~0 (dual-behavior carve-outs may legitimately stay, as in builtins.c).
  • Full suite release + ASan/UBSan detect_leaks=1 green, leak tally 0.
  • Both freestanding_check.sh stages green with allowlist/HAL-roots untouched; freestanding_smoke.sh green.
  • Both planted faults demonstrated and reverted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions