Different file sizes for program compiled with 'rustc' and 'rustc +stage1'

Hello there.
I have a Rust compiler (version 1.68.2) installed. Recently I also build the Rust compiler from source (version 1.70.0-dev) using the command ./x.py build library.

Now when I compile a simple Rust program with rustc, and then compile the same program using my build compiler with rustc +stage1, the two executables vary significantly in file size and amount of included functions.
When compiling with rustc +stage1 and using a disassembler, it shows that it contains 1456 functions, as opposed to 652 functions when using rustc.

I know that the stage1 compiler is not the full rustc build, and that one can build a stage2 compiler wich is considered the full rustc build. Now my question is, can I expect to produce executables that are close to rustc compiled executables (in file size and included functions) just by using the stage2 compiler? Or is there something else to consider?

One significant difference is that the distributed compiler is built with a single codegen unit (CGU), but the default for a local build leaves it to rustc defaults. This is the same for stage1 and "full" later-stage builds. You can set codegen-units-std = 1 in your config.toml to get closer to the distributed builds, even for stage1.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.