Skip to content
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

--emit=metadata emitting empty .rmeta file #67293

Open
0dvictor opened this issue Dec 14, 2019 · 7 comments
Open

--emit=metadata emitting empty .rmeta file #67293

0dvictor opened this issue Dec 14, 2019 · 7 comments
Labels
A-metadata Area: Crate metadata T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@0dvictor
Copy link
Contributor

At present, rustc --emit=metadata foo.rs generates an empty rmeta file named libfoo.rmeta. The logic behind is that rmeta is not needed for certain crate types. However, I feel we should still save it to a file when user explicitly requested it by --emit=metadata, especially the metadata is always available in memory regardless of output crate types.

@0dvictor 0dvictor changed the title --emit metadata emitting empty .rmeta file --emit=metadata emitting empty .rmeta file Dec 14, 2019
@jonas-schievink jonas-schievink added A-metadata Area: Crate metadata C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 14, 2019
@ehuss
Copy link
Contributor

ehuss commented Dec 14, 2019

I would be cautious with this, as it could be a noticeable increase in disk usage for some projects. Rust already uses too much disk space. There should probably be a stronger reason than "it seems like it should".

@bjorn3
Copy link
Member

bjorn3 commented Dec 14, 2019

Emitting an empty .rmeta file makes sense, as the metadata is what is needed to use it with --extern/extern crate. For executables, cdylibs and staticlibs that is impossible, so no metadata is needed in those cases.

@jonas-schievink jonas-schievink removed the C-bug Category: This is a bug. label Dec 14, 2019
@0dvictor
Copy link
Contributor Author

There should probably be a stronger reason than "it seems like it should".

Definitely. IMO, user's explicit request should be honored; therefore, in this case, the explicit request is ---emit=metadata.

On the other side, I agree with @bjorn3 's point that the metadata is not needed for certain crate types; however, under this scenario, I feel rustc should print an error or warning message instead of silently generating an empty file.

@0dvictor
Copy link
Contributor Author

it could be a noticeable increase in disk usage for some projects

Does it mean these projects request --emit=metadata with crate types that do not need metadata? If it does, is there any obstacles or restrictions that these project cannot remove --emit=metadata from the arguments?

@bjorn3
Copy link
Member

bjorn3 commented Dec 16, 2019

Does cargo check use --emit=metadata for executables?

@ehuss
Copy link
Contributor

ehuss commented Dec 16, 2019

Does it mean these projects request --emit=metadata with crate types that do not need metadata?

Yes. this is how cargo check works.

@jyn514
Copy link
Member

jyn514 commented May 24, 2023

Why is cargo passing --emit=metadata for these crate types? It knows already that it's not passing crate-type=lib, it can omit the metadata flag in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants