Skip to content

Native split codegen cannot materialize relocatable ptrtoint constant operands #8057

Description

@proggeramlug

Summary

The split native codegen-unit path cannot materialize the relocatable
ptrtoint constant expression that every non-entry JS module uses to pass its
__init_body function pointer through the integer-valued runtime ABI.

This blocks production-sized webpack graphs before application code can run.
The whole-module text path accepts the same IR because LLVM parses the constant
expression itself; the in-process native dialect reader instead feeds the full
expression to the integer literal parser.

Exact reproduction

Base: fe0d4979204dfd6b8b166320e1ebdd2318f30518 (current main after #8044)

Using the pinned Next.js 16.3.0 webpack production route graph from #8034,
compiled as an app-only dylib with native split units:

perry compile --no-cache --no-auto-optimize --output-type dylib perry-host.js -o next-app-route.dylib

Perry collects 91 modules and reaches native codegen, then independently fails
all four large split modules, including the generated
next/dist/compiled/next-server/app-route.runtime.prod.js:

native codegen unit ... failed: ...
bad integer `ptrtoint (ptr @<module-prefix>__init_body to i64)`

Perry correctly refuses to link the incomplete dylib (87/91 modules emitted).

Minimal compiler-level reproduction

Define two functions in an LlModule: an __init_body, and an __init wrapper
whose runtime call uses this operand:

i64 ptrtoint (ptr @fixture_js__init_body to i64)

Then invoke compile_module_units_native(..., 2, ...). This forces independent
native construction and object emission followed by the real partial-link path.
Before the fix it reaches i128::parse and fails with bad integer; a parse-only
or textual-backend test does not reproduce the defect.

Acceptance

  • The focused two-unit emitted-object/link regression passes.
  • The exact production graph gets past these four ptrtoint construction
    failures.
  • No [Next.js/dylib] Add a pinned production App Route parity fixture and CI gate #8034 behavior acceptance is inferred: its generated
    AppRouteRouteModule.handle path must still actually execute with the required
    moving/verifier evidence before that separate production ticket can close.

Refs #8034 and #8040.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions