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

rustc-dev component recently became a lot bigger #103538

Closed
RalfJung opened this issue Oct 25, 2022 · 7 comments · Fixed by #105609
Closed

rustc-dev component recently became a lot bigger #103538

RalfJung opened this issue Oct 25, 2022 · 7 comments · Fixed by #105609
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@RalfJung
Copy link
Member

RalfJung commented Oct 25, 2022

I need to download the rustc-dev component quite a lot for Miri development, and noticed that it recently became a lot bigger.

For b1ab3b7, it was 125MB in size.
Now, at 85d089b, it is 205MB in size.

Is that an expected regression? Is there a way to avoid this almost doubling of the size?

@Mark-Simulacrum Mark-Simulacrum added this to the 1.66.0 milestone Oct 25, 2022
@Mark-Simulacrum Mark-Simulacrum added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 25, 2022
@Mark-Simulacrum
Copy link
Member

cc @Kobzol @bjorn3, suspected to be due to #101403

@bjorn3
Copy link
Member

bjorn3 commented Oct 25, 2022

It looks like we include both llvm bitcode and object code rather than including only llvm bitcode in the rlibs for some reason.

@ehuss
Copy link
Contributor

ehuss commented Oct 25, 2022

To avoid the object code, it needs to use -Clinker-plugin-lto. However, what needs object code vs bitcode can be quite complex, so it may not be as simple as just overriding more flags.

@bjorn3
Copy link
Member

bjorn3 commented Oct 25, 2022

To avoid the object code, it needs to use -Clinker-plugin-lto.

I though passing -Clto would be enough to disable object code generation, but it seems not.

In any case one way to solve this issue I think would be to ship .rmeta files instead of .rlib files in rustc-dev. All users of rustc-dev should be linking against librustc_driver.so anyway to avoid duplicate symbols when being loaded by rustc or when loading a codegen backend linked against librustc_driver.so. Shipping .rmeta files should even reduce the size of the rustc-dev component to below what it was before #101403 landed.

@RalfJung
Copy link
Member Author

RalfJung commented Nov 4, 2022

@bjorn3 how would tools like Miri even do that (link against the .so file based on .rmeta files)? And do these .rmeta files even exist on our dist builders or would they have to be generated?

@bjorn3
Copy link
Member

bjorn3 commented Nov 4, 2022

Miri links agains librustc_driver.so already. In fact there are no .rlib or .rmeta files generated for rustc_driver as it's crate type is set to dylib. The .rmeta files are already generated as they are used for build pipelining (since a couple of months or so it is no longer possible to disable build pipelining in cargo). All that is necessary is to replace the rule that copies .rlib files to rustc-dev with one copying .rmeta files. Possibly with an assertion that there exists a .rmeta file for every .rlib file that would have been copied previously. Rustc should then automatically pick up the .rmeta files from the sysroot instead of .rlib files and should only error if librustc_driver.so isn't linked in. The error is probably not very helpful though, so maybe we should add a special case for sysroot crates suggesting rustc_driver to be added as dependency.

@bjorn3
Copy link
Member

bjorn3 commented Dec 13, 2022

Opened #105609 to fix this.

@bors bors closed this as completed in 3b1c8a9 Jan 3, 2023
RalfJung pushed a commit to RalfJung/miri that referenced this issue Jan 3, 2023
Only include metadata for non-dynamic libraries in rustc-dev

The actual object code should be linked from librustc_driver.so, which is still included in rustc-dev. This saves on download time and disk usage.

Fixes rust-lang/rust#103538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants