Linker: an external's global initializer is parsed before the tier gate, producing a misleading error for position-independent builds
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reading collect_global and compare its handling with the role-based handling of inference.spec_funcs and inference.hspecs; trace where external-module globals and tables are consumed. Reproduce with an external module whose global initializer uses global.get, then verify it reaches the import check and reports that the external module imports its environment without inspecting the initializer.
索引モデルが issue の本文から書いたものです。
説明
Problem
collect_global runs on external modules during parse — before tier classification and before the non-function-import check. It accepts only i32.const/i64.const initializers and hard-errors otherwise.
Since the global/table gate now keys on use rather than declaration, an external's globals are dropped by construction: the merged output emits the main module's globals only, and a closure that reads a global is still Tier C. So for an external, parsing the initializer expression is work whose only observable output is an error message about a global the merge never emits.
That message is actively misleading on the path users are advised toward. RequiresRelocatableBuild tells them to "build the external module with a relocatable/position-independent toolchain"; doing so produces a global.get-based (PIC) initializer, and the link then fails with:
unsupported WASM construct for static merge: unsupported global initializer for the
static merge: GlobalGet { global_index: 0 } (only i32.const/i64.const are modeled)
The near-identical shape without a global of its own reports the accurate, actionable error instead:
external module providing `sum` imports its environment
Same root cause, two different errors, and the misleading one lands on the shape the advice steers users to.
Proposal
Make collect_global role-aware, mirroring the existing role-based handling of the inference.spec_funcs / inference.hspecs custom sections: for an external module, retain nothing (or a kind-only record) and never inspect the initializer expression. The PIC case then falls through to the import check and reports "imports its environment", which is accurate.
This is strictly less code than today, and it makes "an external's globals are inert" structural rather than incidental.
Notes
- The reachable surface is narrower than it looks: a float global is caught by the feature gate first,
ref.null/ref.funcinitializers need reference types (excluded), and extended-const is excluded.global.getof an imported global is essentially the only reachable case — which is exactly the PIC case above. - Do not widen the modeled initializer set. Nothing consumes an external's global initializer.
- After the use-vs-declaration change, an external's parsed
tableshas no production reader at all and itsglobalsare write-only apart from this parse failure; worth a look while here.
Found during a review of the tier declaration-vs-use change in #363.
Refs: #363, #420.
- 主要言語
- Rust
- スター
- 25
- フォーク
- 17
- 平均マージ
- 21時間 35分
- マージ済み PR(30日)
- 34
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Inferara/inference のほかの issue
-
`exists`/`unique` spec functions refuse an explicit `-> ()` where an omitted return type is acceptedオープンbug codegen
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
codegen documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug rocq-translation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug parser syntax
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Inferara/inference#395 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
Inferara/inference の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
farion1231/cc-switch#8829 ·
メンテナーはふだん 1 日以内に返信
-
Validate CI command vectors before indexing Cargo subcommands対応中かも @amandeavor が今日担当しました。 オープンbug ci good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
longbridge/gpui-kit#3677 ·
メンテナーはふだん 1 日以内に返信
-
E-pr-welcome
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
seanmonstar/reqwest#3121 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
ilya-zlobintsev/LACT#1235 ·
メンテナーはふだん 1 日以内に返信