Description
Since #89634, rustc has been spewing this warning:
WARN rustc_metadata::locator no metadata found: failed to mmap rmeta metadata: '/home/eric/Proj/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_ast-83f5770a611ead91.rmeta'
This happens particularly when using -L
to load a sysroot crate, and using --emit metadata
. This can happen with x.py check
(using latest master as stage0 rustc), though I imagine it can happen in other scenarios. x.py check
uses cargo's --all-targets
which ends up including tests in the checks.
Reproduction:
touch shared.rs
rustc shared.rs --crate-type=dylib
rustc shared.rs --test --emit=metadata
echo "extern crate shared;" > a.rs
rustc a.rs --crate-type=rlib -L .
The cause of this particular error is that memmap2 0.2.1
returns an error it attempts to mmap a file of 0 length (though IIRC, the behavior is platform-specific). .rmeta
files produced for binaries (such as with --test
) have 0 length (#67293).
Possible Solutions
- Update memmap2 to 0.5.0, which does not return an error for 0 sized files. However, the rest of the crate loading code would need to be updated, as it then generates an error since the file is missing the metadata header.
- Skip rmeta files that are empty in crate loading.
- Downgrade that
warn!
toinfo!
ordebug!
Meta
rustc --version --verbose
:
rustc 1.57.0-nightly (41dfaaa3c 2021-10-10)
binary: rustc
commit-hash: 41dfaaa3c66759395835b3af59b22f4f22175dc8
commit-date: 2021-10-10
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0