makepad run: provided plain types with a String field are demoted to opaque (Relax lays String out 8 bytes larger), so a bound program parks on ScriptLoc::new before its first frame

オープン
#1,393 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
backend, compilers

調査の方向性

Start by reading the provided type layout check and plain type handling in the Relax loader, then inspect ScriptLoc in platform/script/src/vm.rs around line 574 and the #[relax_api(plain)] behavior. Reproduce with makepad run using provided crates and compare the reported Rust and Relax layouts for String or Vec fields. Done means establishing the intended layout rule and making a bound program reach its first frame without those plain types being demoted unexpectedly.

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

説明

With the loader's provided crates bound (makepad run, sources matching the loader's build), a program parks at startup on

compile error in makepad_script::vm::ScriptLoc::new: platform/script/src/vm.rs:574:1: a field of `ScriptLoc` (`file: String`) is reached from JIT-compiled code (a field access, a pattern or a trait impl's body), but `ScriptLoc` lives in a provided crate (built by rustc into the loader) and that field's bytes are rustc's alone …

ScriptLoc is #[relax_api(plain)] ("caller-owned source location, all methods stay on the constructing side"), so JIT code is meant to build and read it. What demotes it to opaque is the layout check: at startup the loader prints 35 lines of the form

makepad: provided type makepad_script::literal::LiteralEdit: rustc lays it out in 32 bytes (align 8, field offsets [24, 28, 0]), makepad run in 40 (align 8, [24, 28, 0]): opaque, used through the crate's fns only
makepad: provided type makepad_script::shader_reflection::DrawShaderDescIo: rustc lays it out in 88 bytes …, makepad run in 104 …: opaque, used through the crate's fns only

every plain type with a String or Vec field is 8 bytes larger under Relax than under rustc, so every such type becomes opaque, and then (a) JIT code that builds one by literal is refused, and (b) marking its constructor #[relax_api] does not help, because the op returns the now-opaque plain type by value and does not bind. The program never reaches its first frame; only the bare relax runner (no provided crates) runs it.

Seen with: work 60abec8ba (+ our #1383 #1391 #1392 locally), macOS 15 arm64, a shell of 382 crates; the loader's own calculator does not reach any plain type with a String field before its first frame, so it does not show it. Our side of the boundary is clean per makepad check --boundary makepad-script (0 violations), after moving to ScriptVm::injected_global, cast_to_string, ScriptHeap::arr_view and ScriptMod::new; two ops we had to mark ourselves are in the fork (traits::register_type_inner, ScriptLoc::new).

Questions: is the String/Vec layout difference expected (Relax's own std), and if so should plain types with such fields be laid out by rustc's rule when the crate is provided, or should ScriptLoc and friends be handle with their reads as ops?

🤖 Generated with Claude Code

主要言語
Rust
スター
7.2k
フォーク
408
平均マージ
10時間 19分
マージ済み PR(30日)
33

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

makepad/makepad のほかの issue

makepad/makepad の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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