`cargo rustd build` cannot load a large real-world workspace: unsupported starlark `TypeId` and async-block coroutine layout, plus a stub binary is left behind

Aperta
#13 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à
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start by reading the workspace loading and function compilation paths in rustd, then reproduce with the reported cargo rustd build commands and the codex-execpolicy and codex-state dependencies. Investigate the unsupported TypeId downcast and async-block coroutine layout errors, plus where Cargo’s linked stub is left at target/debug/<bin> after loading fails. Done means these workspace builds handle the reported cases or fail before leaving a stub, with a clear diagnostic.

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

Descrizione

Summary

On a large workspace (openai/codex, codex-rs, 100+ members) cargo rustd build fails for every package whose dependency graph reaches codex-execpolicy or codex-state, with two different unsupported-function errors. Because cargo rustd never hands a build back to cargo, one unsupported function anywhere in the graph fails the whole build. In the same run it takes ~2x as long as plain cargo build before failing.

Two separate reports in one issue because both are the same failure mode (a workspace function the daemon cannot compile) and both were found in one debugging session.

Environment

  • Linux x86-64 (Arch, kernel 7.1.8), 32 CPUs
  • rustc 1.99.0 (b940084d7 2026-09-28), rust-src installed, pinned by codex-rs/rust-toolchain.toml
  • rustd from the nightly release, version 0.0.0-450f2b0-18e06e791bebb82b (cargo rustd status)
  • Install: curl -fsSL https://dioxuslabs.github.io/rustd/install.sh | sh (reported "there is no numbered release yet; downloading nightly")
  • Workspace: openai/codex, commit 485ce624522f00afffd861b8e214cb4bd7d23c77, dev profile, workspace version 0.163.0

Reproduction

From codex-rs/:

cargo rustd build -p codex-file-search   # succeeds, control case
cargo rustd build -p codex-apply-patch   # exit 101
export RUSTD_CACHE=off
export RUSTD_SPLICE=0
cargo rustd build -p codex-tui           # exit 101, same error as above
cargo rustd build -p codex-cli           # exit 101 after ~181 s

The three local edits that existed in tui/, ansi-escape/ and utils/string/ at the time do not touch the crates named in either error; the first failure reproduces on a clean checkout.

Actual result 1: TypeId of a starlark type

cargo rustd build -p codex-apply-patch and -p codex-tui:

   Compiling codex-tui v0.163.0 (<checkout>/codex-rs/tui)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 21.68s
error: the daemon could not load the workspace (exit status: 1: Error: `codex_execpolicy[3e2586be27ddd17b]::parser::POLICY_BUILTINS_STATICS::build::__starlark_invoke_outer` is not compiled by rustd: unsupported: callee `check_required`: callee `unpack_named_param`: callee `ok_or_else`: callee `{closure}`: callee `error`: callee `new_value`: callee `into`: callee `from`: callee `construct_from_std`: callee `object_downcast`: unsupported: `TypeId` of `IncorrectParameterTypeNamedWithExpected`, neither hashed (at ``) nor named by a rustc symbol)

The crate is codex-rs/execpolicy, which uses starlark (object_downcast / TypeId-keyed downcasts).

Actual result 2: layout of an async block

cargo rustd build -p codex-cli:

    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.39s
error: the daemon could not load the workspace (exit status: 1: Error: `<codex_state[12511b18aa50ca97]::runtime::reclamation::SqliteReclamationWorker>::spawn` is not compiled by rustd: frontend: layout of Coroutine(InternedCoroutineId(InternedCoroutineId { key: ClosureKey { owner: DefWithBodyId(FunctionId(FunctionId(236b9b))), nth: 2, kind: Coroutine { kind: Async, source: Block } } }), [(), (), (), (), (Sender<()>, SqliteConfig, Receiver<()>)]): Unknown)

The daemon worker log (/run/user/<uid>/rustd/spares/0/log) for that run:

spare: 21 crates in 1.7s
spare: workspace added in 1.7s
load workspace: 1.7s
symbols: 476233 in 2.9s
resolve: 1161 crates in 15.0s
store: 82212 functions found, 74135 compiled and added
entries: 4844 found, 139140 added, 0 as stored, 0 not as stored, 0 instances and 560 requests without a stable name
not kept: [("unlisted function of the checkout", 560)]
not found: [("no entry", 139700), ("an entry that calls what cannot be used", 3793), ("an entry linked against what the program lacks", 618)]
Error: `<codex_state[12511b18aa50ca97]>::runtime::reclamation::SqliteReclamationWorker>::spawn` is not compiled by rustd: frontend: layout of Coroutine(... kind: Coroutine { kind: Async, source: Block }): Unknown

So 74,135 functions compile and are added to the store, and the run dies on one async block in codex-state/src/runtime/reclamation.rs (a tokio::spawned async block capturing Sender<()>, SqliteConfig, Receiver<()>).

Timings (dev profile, warm target dir, same local edits)

Command Wall time Result
cargo build -p codex-cli, nothing changed 0.38 s ok
cargo build -p codex-cli, after edits in 3 crates 92.8 s ok
cargo rustd build -p codex-cli, same edits 181.5 s exit 101, no binary

cargo rustd build -p codex-file-search (small binary, no execpolicy/codex-state in its graph): first build 9 s, no-change rebuild 32 ms, build after a one-line edit 83 ms, and the resulting ./target/debug/codex-file-search --help works. So the mechanics work; the two unsupported constructs are what stop this workspace.

Second problem: a failed build leaves a stub binary at the real output path

When the daemon fails to load the workspace, cargo has already linked its plan's stub (the "source with no code in it" that only names the linked crates), and it stays at target/debug/<bin>:

$ ls -l target/debug/codex
-rwxr-xr-x 3 <user> <user> 80226008 ... target/debug/codex
$ ./target/debug/codex --version
(no output)  rc=133        # SIGTRAP

Same for target/debug/codex-tui and target/debug/apply_patch in earlier runs. A plain cargo build -p codex-cli afterwards rewrites the real binary (verified: codex-cli 0.163.0), but until then anything that runs the binary — an editor, a test script, an agent — runs a stub that traps. It would help if a failed daemon load removed or did not write the cargo-linked program, or if the client printed the path it left behind.

Expected result

Any of these would make the workspace usable:

  1. TypeId downcasts in a callee chain supported, or the construct treated as passthrough (cargo/rustc compiles that function's crate) instead of failing the whole build.
  2. Async-block coroutine layout supported, or the same passthrough for a function whose layout is Unknown.
  3. If neither, the failing package could be named up front before the 3 minutes are spent.

Notes

  • Both failures are unsupported at workspace load, not a compile error of the edited code, and they are independent: fixing execpolicy alone would still leave codex-cli failing on codex-state.
  • The failure reach is wide here: codex-execpolicy is a dependency of much of the workspace, so codex-apply-patch, codex-tui and codex-cli all fail on it.
  • The daemon's worker held ~6.8 GB RSS for this workspace; target/rustd/ grew to 770 MB and ~/.cache/rustd to 1.2 GB across a handful of runs.
  • Happy to re-run with RUSTD_* values, a smaller package set, or a branch if that helps.
Lingua principale
Rust
Stelle
248
Fork
13
Merge medio
7h 52m
PR unite (30g)
5

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 DioxusLabs/rustd

Tutte le issue di DioxusLabs/rustd

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.