Why do the same files in the same window system compile to different sizes?

rustc:cargo 1.75.0 (1d8b05cdd 2023-11-20)

The result I compiled on a computer with a CPU of 5600x is 9m, but the result I compiled on an i5-1155G7 computer is 4m, and the running speed of 9m is greater than that of 4m.

Each CPU has it's own instruction set architecture (ISA) which means that not only are the compiler outputs differently sized and different speeds, but also, if you inspected each binary they would appear totally different because they are each composed of different assembly instructions, logic, and routines.

So are their operating efficiencies the same?

I'd be surprised if the final output used the native CPU target by default, but there are other possible environmental influences like which native library versions and linker tool chain is installed, even if there's no config changes. Hard to tell what specifically, and harder to fix - "reproducible builds" is the search term to find out more about this issue.

I'm surprised the difference is that much though!

If you're running on different CPUs, you shouldn't be surprised if the run time is different, though.

1 Like

No, in fact even the same CPU model may provide different efficiencies as is the case with certain product lines.

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.