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

オープン 初心者向け
#14,981 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust, typescript
領域
backend, compilers

調査の方向性

crates/perry-codegen/src/module.rsを読み、特に1316行目あたりのLlModule::into_codegen_unit_textsを確認し、1895行目あたりにあるもう一方のユニットパートレンダラーと比較してください。module/inline_copies.rsでpart.copiesがどのように設定されるかを確認してください。再現手順とコマンドはissueにあります。テキストレンダラーにavailable_externallyのコピーが含まれ、in-process LLVMパスで再現ケースがコンパイルできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Rust
スター
4.9k
フォーク
166
平均マージ
4時間 54分
マージ済み PR(30日)
909

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PerryTS/perry のほかの issue

PerryTS/perry の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。