new test main with code directly (fixes)
This commit is contained in:
@@ -132,3 +132,4 @@ Foco: eliminar os dois `partial` remanescentes na matriz backend antes de mover
|
||||
|
||||
1. `PR-07.1-optimize-irvm-span-source-hook-preservation.md`
|
||||
2. `PR-07.2-pbs-callsite-category-no-textual-heuristics-regression.md`
|
||||
3. `PR-07.3-irvm-entrypoint-export-emission-for-runtime-loader.md`
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
# PR-07.3 - IRVM Entrypoint Export Emission for Runtime Loader Compatibility
|
||||
|
||||
## Briefing
|
||||
|
||||
Hoje um cartridge pode compilar com `entrypoint: "frame"` no `manifest.json` e `pub fn frame()` no `mod.barrel`, mas ainda falhar em runtime com `EntrypointNotFound`.
|
||||
|
||||
A causa observada e que o `program.pbx` pode ser emitido sem secao `exports` (section kind `4`), enquanto o loader resolve entrypoint nominal usando `program.exports`.
|
||||
|
||||
## Motivation
|
||||
|
||||
### Dor atual que esta PR resolve
|
||||
|
||||
1. Build aparentemente valido, mas falha de bootstrap em runtime.
|
||||
2. Divergencia entre contrato de manifesto (`entrypoint` nominal) e artefato PBX emitido.
|
||||
3. Falta de evidencia automatizada para evitar regressao de exports no caminho `IRBackend -> IRVM -> Bytecode`.
|
||||
|
||||
## Target
|
||||
|
||||
Corrigir o pipeline backend para sempre emitir export nominal do entrypoint no PBX de preload, garantindo compatibilidade com o loader quando o `manifest.json` declara entrypoint por nome.
|
||||
|
||||
## Dependencies
|
||||
|
||||
Prerequisitos diretos:
|
||||
|
||||
1. `PR-05.3` (politica deterministica de entrypoint no indice `0`).
|
||||
2. `PR-05.4` (coerencia unica entre IRVM e EmissionPlan).
|
||||
|
||||
## Scope
|
||||
|
||||
1. `LowerToIRVMService` deve preencher `EmissionPlan.exports` com o simbolo do entrypoint apontando para `func_idx = 0`.
|
||||
2. Adicionar regressao dedicada para garantir que `coherentEmissionPlan()` preserva export do entrypoint.
|
||||
3. Validar serializacao PBX com secao `exports` presente quando houver entrypoint nominal.
|
||||
4. Cobrir cenario de integracao onde `manifest.entrypoint = "frame"` inicializa VM sem `EntrypointNotFound`.
|
||||
|
||||
## Non-Goals
|
||||
|
||||
1. Nao exportar toda a superficie de funcoes executaveis neste passo.
|
||||
2. Nao alterar formato binario PBX alem da presenca correta da secao `exports`.
|
||||
3. Nao mudar semantica de resolucao por indice numerico de entrypoint.
|
||||
|
||||
## Method
|
||||
|
||||
### O que deve ser feito explicitamente
|
||||
|
||||
1. No `LowerToIRVMService`, construir `BytecodeEmitter.EmissionPlan` com `exports` contendo, no minimo, `Export(entryPointCallableName, 0)`.
|
||||
2. Garantir determinismo do export do entrypoint a partir da mesma politica que fixa `func_id = 0`.
|
||||
3. Adicionar teste unitario em `LowerToIRVMServiceTest` para verificar export nominal do entrypoint no plano coerente.
|
||||
4. Adicionar teste de emissao/link para verificar secao `exports` no modulo serializado.
|
||||
5. Adicionar teste de integracao runtime-backed para falhar se regressar para `EntrypointNotFound` em cartridge com entrypoint nominal valido.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
1. Build de projeto PBS com entrypoint `frame` gera PBX com secao `exports`.
|
||||
2. O simbolo `frame` aponta para `func_idx = 0` no artefato emitido.
|
||||
3. Execucao de cartridge com `manifest.entrypoint = "frame"` nao falha por `EntrypointNotFound` quando o programa contem o entrypoint admitido.
|
||||
4. Rebuilds equivalentes produzem mapping de export deterministico.
|
||||
|
||||
## Tests
|
||||
|
||||
1. Novos testes de backend:
|
||||
- `:prometeu-compiler:prometeu-build-pipeline:test`
|
||||
2. Reexecucao de compatibilidade runtime-backed:
|
||||
- `:prometeu-compiler:prometeu-build-pipeline:test --tests *Runtime*`
|
||||
3. Smoke local recomendado:
|
||||
- `./runtime/prometeu build .`
|
||||
- `./runtime/prometeu run cartridge`
|
||||
|
||||
## Affected Documents
|
||||
|
||||
1. `docs/general/specs/15. Bytecode and PBX Mapping Specification.md`
|
||||
2. `docs/general/specs/20. IRBackend to IRVM Lowering Specification.md`
|
||||
3. `docs/pbs/specs/7. Cartridge Manifest and Runtime Capabilities Specification.md`
|
||||
4. `docs/general/specs/22. Backend Spec-to-Test Conformance Matrix.md`
|
||||
|
||||
## Open Questions
|
||||
|
||||
1. Em evolucao futura, devemos exportar apenas o entrypoint ou tambem funcoes explicitamente marcadas para linking externo?
|
||||
@@ -78,6 +78,7 @@ For each admitted source unit and callable in the current lowering slice, `IRBac
|
||||
4. source attribution anchor (`file + span`) for diagnostics and traceability,
|
||||
5. source-observable parse intent for statement/expression structure (including precedence/associativity outcome already fixed by AST shape).
|
||||
6. deterministic `requiredCapabilities` derived from admitted host-binding metadata for packer/runtime-manifest assistance.
|
||||
7. frontend-declared executable entrypoint callable name from `FrontendSpec` (`entryPointCallableName`) for backend handoff.
|
||||
|
||||
Lowering must not collapse source categories in a way that erases required declaration/callable identity needed by downstream diagnostics or conformance assertions.
|
||||
|
||||
@@ -194,3 +195,13 @@ It does not replace:
|
||||
1. `docs/general/specs/20. IRBackend to IRVM Lowering Specification.md`,
|
||||
2. `docs/general/specs/21. IRVM Optimization Pipeline Specification.md`,
|
||||
3. or `docs/general/specs/15. Bytecode and PBX Mapping Specification.md`.
|
||||
|
||||
### 12.7 FrontendSpec Entry Point Obligation
|
||||
|
||||
For executable language frontends, `FrontendSpec` must declare one canonical entrypoint callable name (`entryPointCallableName`).
|
||||
|
||||
At `IRBackend` emission time:
|
||||
|
||||
1. frontend must copy this declaration into `IRBackend.entryPointCallableName`,
|
||||
2. value must be non-blank and deterministic for the same language/spec version,
|
||||
3. and backend stages must treat this field as authoritative for entrypoint selection instead of hardcoded language-agnostic names.
|
||||
|
||||
@@ -19,7 +19,8 @@ This document is the authority for how the compiler discovers and loads:
|
||||
|
||||
- ordinary project modules,
|
||||
- reserved stdlib modules such as `@sdk:gfx`,
|
||||
- and compile-time-only host-binding metadata attached to those reserved modules.
|
||||
- compile-time reserved metadata attached to those reserved modules,
|
||||
- and interface-only service facades that wrap host surfaces for source ergonomics.
|
||||
|
||||
This document does not define runtime load behavior.
|
||||
PBX host-binding emission and loader-side syscall resolution are defined by the Host ABI Binding and Loader Resolution Specification.
|
||||
@@ -445,7 +446,7 @@ The current PBS design direction is:
|
||||
6. The root project selects the effective stdlib line for the whole build.
|
||||
7. Dependency projects with a higher stdlib requirement than the root are rejected.
|
||||
8. Stdlib modules are loaded as PBS-like interface modules, not as ordinary dependencies.
|
||||
9. Interface modules are compile-time-only and do not emit executable bytecode.
|
||||
9. Interface modules are compile-time-only in packaging terms: they may carry declarative service facades with method bodies for source-level API ergonomics, but they still do not emit executable bytecode as standalone modules.
|
||||
10. `declare host` remains reserved to stdlib/toolchain interface modules.
|
||||
11. Reserved attributes such as `[Host(...)]` are compile-time metadata, not runtime objects.
|
||||
12. The compiler consumes `Host` metadata to produce runtime-facing host-binding artifacts defined elsewhere.
|
||||
|
||||
@@ -63,7 +63,7 @@ The current manifest shape relevant to this document is:
|
||||
"title": "Example",
|
||||
"app_version": "1.0.0",
|
||||
"app_mode": "game",
|
||||
"entrypoint": "main",
|
||||
"entrypoint": "frame",
|
||||
"capabilities": ["gfx", "input"],
|
||||
"asset_table": [],
|
||||
"preload": []
|
||||
@@ -75,6 +75,7 @@ Rules:
|
||||
- `magic` identifies a Prometeu cartridge manifest,
|
||||
- `cartridge_version` identifies the cartridge manifest format line,
|
||||
- `entrypoint` identifies the runtime entrypoint,
|
||||
- for PBS v1, `entrypoint` should align with frontend-declared callable (`frame`),
|
||||
- `capabilities` declares the cartridge's requested runtime capabilities,
|
||||
- `asset_table` and `preload` remain separate concerns.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user