bug: --target windows: stack-map rewriter refuses COFF alias symbol records (`.def`/`.scl`/`.endef`) after .llvm_stackmaps for $pshape method aliases
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust, typescript
調査の方向性
crates/perry-codegen/src/gc_map.rsから始めて、COFFシンボルレコードを処理する場所としてissueが挙げているis_zero_width_directiveを読みます。既存のディレクティブ処理とスタックマップ書き換えのテストを確認し、提供されたTypeScriptの例とWindowsのコンパイルコマンドで再現します。指定されたCOFFディレクティブで解析エラーが発生しなくなり、スタックマップの書き換えでGCルートが引き続き保持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
On --target windows (COFF), a class whose method's $pshape clone has the same body as the ordinary method fails to compile. The error is "unrecognised directive .def inside the stack-map block".
What happens: inprocess/equivalent_shape_bodies.rs replaces the $pshape clone with an external LLVM alias of the method. On COFF, LLVM prints the alias's symbol record after .llvm_stackmaps:
.globl <sym>
.def <sym>;
.scl 2;
.type 32;
.endef
<sym> = <method>
The compact stack-map rewriter in crates/perry-codegen/src/gc_map.rs accepts .type and sym = expr, but not .def / .scl / .endef, so it refuses the module. This is the COFF counterpart of the Mach-O .alt_entry alias case (#12736).
Reproduction
coff_pshape_alias.ts:
// A method whose `$pshape` capability body equals the ordinary body becomes
// an LLVM alias after optimization. On COFF its symbol record
// (`.def`/`.scl`/`.type`/`.endef`) prints after the stack map; the
// Windows-target compile regression assembles this module.
export class Img {
private template = false;
setTemplateImage(option: boolean): void {
this.template = option;
}
isTemplateImage(): boolean {
return this.template;
}
}
const image = new Img();
image.setTemplateImage(true);
console.log(image.isTemplateImage());
perry compile coff_pshape_alias.ts --target windows --no-link -o c.o
perry: this module emits an LLVM stack map that the compact-map rewriter could not parse, so its GC roots would be invisible to the collector (the runtime reads only the compact section). Refusing to emit a binary that would lose roots silently.
reason: line 5440: unrecognised directive `.def` inside the stack-map block (`.def perry_method_coff_pshape_alias_ts__Img__setTemplateImage$pshape;`). [...] Add it to `directive_width` (with its width) or to `is_zero_width_directive`.
No special settings are needed. It fails the same way with the default settings, with PERRY_LL_OPT_LEVEL=0, with PERRY_LLVM_INPROCESS=1, and with both.
Suggested fix
Treat .def, .scl, .endef (and .safeseh) as zero-width in is_zero_width_directive. They only build COFF symbol-table records and emit no section bytes, so they can be carried through verbatim, as .type already is.
Environment
- PerryTS/perry main 86988bec62 (pristine, current head). Linux host build (
cargo build --release -p perry --no-default-features --features dev-cliplus the runtime/stdlib static archives), cross-compiling with--target windows. - Linux x86_64, Ubuntu 24.04.
- 主要言語
- Rust
- スター
- 4.9k
- フォーク
- 166
- 平均マージ
- 4時間 54分
- マージ済み PR(30日)
- 909
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PerryTS/perry のほかの issue
-
area:compiler effort:S impact:med type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area:runtime-gc effort:S impact:low platform:linux type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
PerryTS/perry#14789 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
area:compiler effort:S impact:med type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 56/100
メンテナーはふだん 1 日以内に返信
-
area:runtime-gc effort:L impact:med type:perf
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
<input type="number"> misses text-entry leaf sizing in layout対応中かも @GoCoder7 が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
DioxusLabs/blitz#1675 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
metasequoiaime/msime#11666 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
camunda/orchestration-cluster-api-rust#179 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
bug drawings help wanted ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
userFRM/egui-charts#3479 ·
メンテナーはふだん 1 日以内に返信