bug: text codegen-unit path (into_codegen_unit_texts) drops available_externally copies: "use of undefined value" with PERRY_CODEGEN_UNITS + PERRY_LLVM_INPROCESS

Aperta Adatta ai principianti
#14,981 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, typescript
Ambito
backend, compilers

Direzione di ricerca

Leggi crates/perry-codegen/src/module.rs, in particolare LlModule::into_codegen_unit_texts intorno alla riga 1316, e confrontalo con l’altro renderer delle parti dell’unità intorno alla riga 1895. Controlla come viene popolato part.copies in module/inline_copies.rs; la riproduzione e il comando sono nell’issue. Il lavoro è completato quando il renderer di testo include le copie available_externally e la riproduzione compila con il percorso LLVM in-process.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:compiler effort:S impact:med type:bug

Summary

With split codegen units on the text unit path, a module whose functions call each other fails to compile. The text path is used when native units are off: PERRY_LLVM_INPROCESS=1, --debug-symbols, and fallback diagnostics. The error is:

perry_llvm_<hash>.ll:562:21: error: use of undefined value '@perry_checked_number_remainder'

Cause (from the code at 86988bec62): LlModule::into_codegen_unit_texts (crates/perry-codegen/src/module.rs, around line 1316) renders only part.pre, part.funcs and part.post. It drops part.copies, the available_externally cross-unit inline copies (module/inline_copies.rs). Those copies are counted as defined in their unit (defined.extend(copies...), around line 1756), so no declare is emitted for them either, and the callee is undefined in the unit's IR. The other renderer of unit parts, around line 1895, does emit part.copies. Expected: into_codegen_unit_texts renders part.copies the same way.

Reproduction

split_unit_copies.ts:

function r0(a: number, b: number) { return (a * 3 + b) % 7; }
function r1(a: number, b: number) { return (a * 4 + b) % 9; }
function r2(a: number, b: number) { return (a * 5 + b) % 11; }
function r3(a: number, b: number) { return (a * 6 + b) % 13; }
function r4(a: number, b: number) { return (a * 7 + b) % 15; }
function r5(a: number, b: number) { return (a * 8 + b) % 17; }
function r6(a: number, b: number) { return (a * 9 + b) % 19; }
function r7(a: number, b: number) { return (a * 10 + b) % 21; }
const fns = [r0, r1, r2, r3, r4, r5, r6, r7];
let t = 0;
for (let i = 0; i < 8; i++) for (let j = 1; j < 20; j++) t += fns[i](i * 7 + j, j);
console.log(t);
PERRY_CODEGEN_UNITS=4 PERRY_LLVM_INPROCESS=1 perry compile split_unit_copies.ts --no-link -o b.o   # fails as above
PERRY_CODEGEN_UNITS=4 perry compile split_unit_copies.ts -o b && ./b                                # native units: prints 986
node split_unit_copies.ts                                                                         # 986

Environment

  • PerryTS/perry main 86988bec62 (pristine, current head), and 08c74942f1. Linux host build (cargo build --release -p perry --no-default-features --features dev-cli plus the runtime/stdlib static archives).
  • Linux x86_64, 32 threads, Ubuntu 24.04.
Lingua principale
Rust
Stelle
4.9k
Fork
166
Merge medio
4h 54m
PR unite (30g)
909

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PerryTS/perry

Tutte le issue di PerryTS/perry

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.