Skip to content

"rustc_metadata::locator no metadata found: no .rustc section" warnings during compilation #90525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
farmaazon opened this issue Nov 3, 2021 · 1 comment · Fixed by #90544
Assignees
Labels
C-bug Category: This is a bug.

Comments

@farmaazon
Copy link

When compiling our project, many warnings regarding "no .rustc section" are printed.

To reproduce, please check out https://github.com/farmaazon/bug-repro , go to src/rust directory and run cargo build.
You should see some warning similar to

WARN rustc_metadata::locator no metadata found: no `.rustc` section in '<path-to-repo>/src/rust/target/debug/deps/libenso_shortcuts_examples.so'

As far as I checked, the warnings are not displayed when building crates separately.

Meta

rustc --version --verbose:

rustc 1.58.0-nightly (c390d69a6 2021-10-28)
binary: rustc
commit-hash: c390d69a615f095208ac94841f3310268521b2ee
commit-date: 2021-10-28
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0

The repository contains rust-toolchain file.

@farmaazon farmaazon added the C-bug Category: This is a bug. label Nov 3, 2021
@farmaazon farmaazon changed the title Many "rustc_metadata::locator no metadata found: no .rustc section" warnings during compiling Many "rustc_metadata::locator no metadata found: no .rustc section" warnings during com,pilation Nov 3, 2021
@farmaazon farmaazon changed the title Many "rustc_metadata::locator no metadata found: no .rustc section" warnings during com,pilation "rustc_metadata::locator no metadata found: no .rustc section" warnings during compilation Nov 3, 2021
@ehuss
Copy link
Contributor

ehuss commented Nov 3, 2021

Here is a reduced reproduction:

echo 'pub fn foo() {}' > foo_a_b.rs
echo 'pub use foo_a_b::foo;' > foo_a.rs
echo 'pub use foo_a::foo;' > foo.rs
echo 'fn main() { foo::foo(); }' > main.rs
rustc foo_a_b.rs --edition=2018 --crate-type=cdylib,rlib
rustc foo_a.rs --edition=2018 --crate-type=rlib --extern foo_a_b=./libfoo_a_b.rlib
rustc foo.rs --edition=2018 --crate-type=rlib --extern foo_a=./libfoo_a.rlib -L .
rustc main.rs --edition=2018 --extern foo=./libfoo.rlib -L .

When the crate loader needs to load foo_a_b, it scans for any potential candidates, and it picks up the cdylib (because it might possibly be a rust dylib). However, cdylibs don't have metadata.

There is more discussion of this at #89795 (comment). I did a workaround for that particular issue, but I think I agree that the warn! log is too aggressive. I'll post a patch soon to propose to demote it.

@ehuss ehuss self-assigned this Nov 3, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 4, 2021
…henkov

Demote metadata load warning to "info".

There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means).

If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully rust-lang#88368 will improve that error message).

If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details.

There is more discussion of this particular warning at rust-lang#89795 (comment).

Fixes rust-lang#90525
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 4, 2021
…henkov

Demote metadata load warning to "info".

There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means).

If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully rust-lang#88368 will improve that error message).

If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details.

There is more discussion of this particular warning at rust-lang#89795 (comment).

Fixes rust-lang#90525
@bors bors closed this as completed in 6964ec2 Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants