I shaved off 10 MiB from my binary in 2 hours!

I made a program using Macroquad, then I built it in release mode, the binary was 63 MiB in size.

So I used cargo vendor to have a better look at Macroquad and one of its dependencies, glam.

I then started to delete code, like, lots and lots of code(about 30_000 lines of code); none of it affected my main project, some of it became ‘dead_code’ just by removing the pub keyword.

The result is that my project was unaffected and the binary went down to 52 MiB.

Is there a way to automate removal of unneeded elements from dependencies? This is potentially huge.

  • Doods@infosec.pubOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    14 hours ago

    Yes, I am using both LTO and release mode, I can show you:

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

    cargo build --release

      • Doods@infosec.pubOP
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        14 hours ago

        Should I bring it up to the ‘min-sized-rust’ working group or the forums or something?

        • TehPers@beehaw.org
          link
          fedilink
          English
          arrow-up
          2
          ·
          11 hours ago

          Yes. This behavior seems strange, so either an explanation or investigation by a compiler dev seems like it would be helpful.