NotNite / GDWeave

Mod loader & runtime script patching for Godot
MIT License
140 stars 12 forks source link

Loader (winmm.dll) file size can be reduced #15

Closed BlueberryWolf closed 3 weeks ago

BlueberryWolf commented 3 weeks ago

By using some rust compiler flags, and packing the loader with UPX, I managed to reduce the file size to 514kb (from 2MB)

UPX compresses your binary, and can be unpacked, and is therefore non-destructive

I did not thoroughly research the compiler flags I used, and therefore use them with caution.

[profile.release]
strip = true
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"

I found this convenient info from the following guide: min-sized-rust

BlueberryWolf commented 3 weeks ago

It may not be the best solution to the issue (if it can even be considered one), but it is nice to see a smaller file size for the loader dll.

BlueberryWolf commented 3 weeks ago

To compress the binary, I used the following command:

upx --best --lzma loader.dll

cargo bloat reports the following: image

NotNite commented 3 weeks ago

I am not stripping the binary, making panic abort, or using UPX, but I'd be willing to try the other things. UPX as a packer tends to set off antimalware.

NotNite commented 3 weeks ago

LTO only shaves ~500kb off of the DLL, which isn't worth it for the risk of unknown compiler flags, so I probably won't do this.