Conversation
Modern rustc (1.75+) emits extended metadata per dependency line in
`rustc -Z ls=root` output:
N libname[-hash] hash HASH host_hash ... kind ... public
Crates built without a content hash suffix (e.g. crc_fast, a
build-script artifact) appear as:
N crc_fast hash 05bce6... host_hash None kind Unconditional public
parse_rustc_z_ls used splitn(2, ' ') which yields libstring as the
entire trailing metadata ("crc_fast hash 05bce6... host_hash ...").
The subsequent rsplitn(2, '-') finds no '-' and libname becomes the
whole string, so it never matches the bare "crc_fast" parsed from
rmeta filenames during crate_link_paths scanning.
The unmatched dep is silently skipped, its rmeta is not packaged for
the dist worker, and the worker fails with E0463: can't find crate
for `crc_fast`.
Fix: take only the first whitespace-delimited token of libstring
before the existing rsplitn('-') logic runs, so crates with and
without a -HASH suffix both resolve to the bare crate name.
Signed-off-by: KK <pandeykamal13526@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
The fix and regression coverage address the reported dependency-packaging failure with no unresolved review issues.
Pull request overview
This pull request fixes parsing of Rust dependencies without -HASH suffixes, ensuring required metadata is packaged for distributed builds.
Changes:
- Parses only the first crate-name token.
- Adds regression coverage for hashed and unhashed dependencies.
File summaries
| File | Description |
|---|---|
src/compiler/rust.rs |
Fixes dependency parsing and adds focused tests. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #2847 +/- ##
==========================================
- Coverage 76.14% 67.69% -8.46%
==========================================
Files 72 72
Lines 39807 38627 -1180
==========================================
- Hits 30313 26147 -4166
- Misses 9494 12480 +2986 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The RustInputsPackager scans crate_link_paths for dependency rmeta and rlib files, extracting the crate name from each filename via rsplitn(2, '-'). This assumes every file has a -<metadata-hash> suffix. When a file has no hash (e.g. libcrc_fast.rmeta produced by a crate with crate-type = ["lib", "cdylib", "staticlib"]), rsplitn yields a single element and the code hits continue, skipping the file entirely. The file is never packaged and sent to the dist worker, which then fails with E0463: can't find crate for crc_fast. Extract the crate-name-and-extension logic into a testable helper, crate_name_and_ext_from_lib_path, that uses file_stem() to strip the extension before rsplitn, then falls back to the whole stem as the libname when no - separator is found. Signed-off-by: KK <pandeykamal13526@gmail.com>
|
Superseded by #2850 which consolidates all fixes onto a single branch. |
Summary
Fixes #2846
parse_rustc_z_lsmisparses dependency lines fromrustc -Z ls=rootwhen a crate appears without a-${HASH}suffix. The malformed dependency name never matches duringcrate_link_pathsscanning, so the dep's rmeta is not packaged for the distributed worker, and the worker fails with:Root cause
Modern rustc emits extended metadata per dependency line:
Line 2 (
crc_fast) has no-${HASH}suffix; line 3 (crc-8c7d...) does.parse_rustc_z_lsdoesline.splitn(2, ' ')which splits on the first space, solibstringbecomes the entire trailing metadata ("crc_fast hash 05bce6... host_hash None kind Unconditional public"). The subsequentrsplitn(2, '-')finds no-andlibnamebecomes the whole string.When
RustInputsPackagerscans-Lpaths, it parses each rmeta filename (e.g.libcrc_fast-c6657c97868f5464.rmeta) and extracts"crc_fast", butdep_crate_namescontains the broken"crc_fast hash 05bce6..."— no match. The rmeta is silently skipped, not sent to the worker, and rustc on the worker fails withE0463.The fix
Take only the first whitespace-delimited token of
libstringbefore the existingrsplitn('-')logic runs, so crates with and without a-${HASH}suffix both resolve to the bare crate name:This preserves the existing behavior for deps with a
-${HASH}suffix (rsplitn('-')still splitsstd-453218b5e9634890→std).Test
Added
test_parse_rustc_z_ls_modern_no_hash_suffixwhich feeds the parser a modern-Z lsoutput containing both a no-suffix dep (crc_fast) and a suffix dep (crc-8c7d...), and asserts each resolves to the bare crate name. This test fails on the unfixed parser (thecrc_fastentry becomes the entire metadata string) and passes with the fix.Checklist
test_parse_rustc_z_ls_pre_1_55andtest_parse_rustc_z_ls_post_1_55still pass (old format deps also take the first token correctly)