Skip to content

C backend lacks LLVM-backend parity for several intrinsic families (dyn dispatch, MultiIndex, get_disjoint, SlotMap, VecRange) #301

Closed

Description

@ehartford

Summary

The C backend (--emit-c) loudly bails on five intrinsic families that the LLVM backend supports. Programs using them compile and run on LLVM but cannot be emitted to C. There is no tracking issue for this parity gap, so this issue consolidates it.

Unsupported in the C backend (src/CCodegen.w, emit_builtin_call_term)

4705  dyn trait method dispatch
4709  MultiIndex intrinsics
4739  Vec.get_disjoint (needs tuple-valued VecSlot lowering)
4743  SlotMap intrinsics
4747  VecRange intrinsics

Each calls self.fail("C backend does not yet support ...") — correct (loud, not a silent fallback), but it means these constructs are LLVM-only.

Newly relevant: length-method narrowing

While implementing §18.6 collection length methods (#282), len32/len64/ulen32 were added for every collection. For Vec/HashMap/str/array the C backend emits the narrowing correctly. For SlotMap and VecRange, the new SLOTMAP_LEN32/64/ULEN32 and VECRANGE_LEN32/64/ULEN32 intrinsics map to the catch-all CcBuiltin.SLOTMAP / CcBuiltin.VECRANGE, which hit the loud-fail above. So SlotMap.len32() / VecRange.len32() work on LLVM but fail to emit C — same gap, just widened.

Acceptance criteria

  • Implement C-backend lowering for these families (or a documented subset), reaching parity with the LLVM backend, or explicitly scope which families are intentionally LLVM-only and document that.
  • For SlotMap/VecRange specifically, route the *_LEN32/64/ULEN32 intrinsics through the same narrowing helper (CCodegen.emit_len_result) once base SlotMap/VecRange support lands.

Notes

Env: with v0.13.1-g7104bb5d7, darwin-aarch64.

Activity

  1. added
    bug
    on May 30, 2026
  2. ehartford commented on May 31, 2026

    @ehartford
    ContributorAuthor

    --emit-c is for is bootstrapping. in bootstrapping scenario - the user has external LLVM available. bootstrapping is the one time we use external LLVM instead of our own compiled LLVM - and that's just for the first seed. The second seed will use the normal release process - in which we compile the embedded llvm and libclang ourselves.
    in summary - I am not certain we need to

  3. ehartford commented on May 31, 2026

    @ehartford
    ContributorAuthor

    Resolved as LLVM-only by design (the acceptance criteria's documented-scope alternative), not by implementing parity — in b094475.

    Analysis. The C backend (--emit-c) exists for exactly one job: the no-LLVM bootstrap (emit-c-fixpoint emits the whole compiler to C, builds it with cc, and verifies the C-built compiler re-emits byte-identical C). It only has to emit the compiler's own source. User programs always go through the LLVM backend (the release binary embeds its own LLVM/libclang), so they never route through --emit-c.

    The five families here — dyn dispatch, MultiIndex, Vec.get_disjoint, SlotMap, VecRange (and the §18.6 *_LEN32/64/ULEN32 variants, which are just the same base gap widened) — are not used by the compiler internally (verified: no &dyn-typed values, no SlotMap/VecRange fields in src/; emit-c-fixpoint round-trips the full compiler). So they can never block the bootstrap. And user programs that use them compile fine on LLVM. The gap is unreachable by any real path.

    The one genuine exposure — the compiler later adopting one of these internally — is already guarded: make emit-c-fixpoint fails loudly and points at it the moment the compiler stops being C-emittable.

    Done:

    make build + make fixpoint + make test green. The only emit-C gaps worth fixing are ones the compiler's own source hits (surfacing as emit-c-fixpoint failures); #300 is a separate, real such gap.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions