mojo
mojo copied to clipboard
[BUG]: Mojo hello world binary size unreasonably large
Bug description
Binary file large in mojo 0.7.0
Reoccurrence of BUG https://github.com/modularml/mojo/issues/599 which was resolved in 0.3.0.
Steps to reproduce
System information
WSL2 - Ubuntu 22.04.3 LTS
mojo 0.7.0 (af002202)
modular 0.4.1 (2d8afe15)
a whopping 4 megabytes before stripping, and 544KB after, here
mojo 0.7.0 (af002202), archlinux
woof, thanks for filing! We'll take a look at the stripping flags in binary generation
Looks like it was fixed in 24.1. On my Mac the binary size is 533 KB after build and 355 KB after strip hello
Yep, this should be fixed now! Please re-open if you still see if you see this again!
Thanks River. However, doesn't the comment from @toiletsandpaper imply that it's Not fixed? If we need to use the strip
command to decrease the binary further, then that means there are still unnecessary symbols making the binary larger?
On macOS, I get a size of 272K for a simple hello.mojo
program on version 2024.4.117 (8f6529b0). Then after using strip
command the binary is further reduced to 208K.
Could you please clarify if the presence of unnecessary symbols is still an issue?
Yeah, we may have some symbols that could still be stripped further, we'll need to investigate which symbols those are exactly. I marked this as fixed for the original underlying issue of being "unreasonably large"(the several mb was the big issue, digging into the last 60kb is not as pressing). We should open another issue to explore that last mile, but it's good to keep that exploration separate (we do have some symbols that only get used in certain scenarios, but we should certainly try to strip out all symbols that definitely won't be needed).
Ah got it. That makes sense. Thanks for clarifying!
seems to re-appearing in v24.2.1 @River707
cat world.mojo
fn main():
print("Hello world")
$ mojo --version
mojo 24.2.1 (2f0dcf11)
$ mojo build world.mojo
$ ./world
Hello world
$ du -hs world.mojo
4.0K world.mojo
$ du -hs world
4.3M world
$ uname -a
Linux pop-os 6.8.0-76060800daily20240311-generic #202403110203~1713206908~22.04~3a62479 SMP PREEMPT_DYNAMIC Mon A x86_64 x86_64 x86_64 GNU/Linux
On linux the binary size for hello world is 4.3MB by default