Skip to content

fix(kompile): map linked NormalSym functions to monoItemFn(noBody)#953

Draft
Stevengre wants to merge 7 commits intomasterfrom
jh/fix-normalsym-mapping
Draft

fix(kompile): map linked NormalSym functions to monoItemFn(noBody)#953
Stevengre wants to merge 7 commits intomasterfrom
jh/fix-normalsym-mapping

Conversation

@Stevengre
Copy link
Contributor

@Stevengre Stevengre commented Feb 28, 2026

Summary

Synthesize monoItemFn(symbol(...), defId(...), noBody) equations for linked NormalSym functions that have no local body in the SMIR items collection.

Context

When compiling multi-crate Rust programs, external crate functions are present in SMIR's function_symbols as NormalSym entries but do not appear in the items list (since they have no local MIR body). The kompile.py function table generator only iterated over items, so these linked functions had no generated monoItemFn equation. At call resolution time, lookupFunction(Ty) fell back to "** UNKNOWN FUNCTION **", causing execution to get stuck.

This is analogous to how miri handles extern functions — they are recognized as valid call targets even without a local body.

Without this fix, calling any external crate function produces:

lookupFunction(42) => monoItemFn(symbol("** UNKNOWN FUNCTION **"), ...)
-- execution gets stuck, no body to enter

With this fix, linked NormalSym functions are mapped to monoItemFn(..., noBody), allowing call resolution to recognize them as valid (bodyless) function targets.

Test plan

  • No dedicated test (exercised by all multi-crate SMIR tests)
  • make test-integration regression

Linked NormalSym functions (external crate functions present in SMIR but
without a local body) had no generated monoItemFn equation, falling back
to "** UNKNOWN FUNCTION **". This synthesizes monoItemFn(symbol(...),
defId(...), noBody) for all such symbols, ensuring downstream call
resolution can find them.
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