Skip to content

Serious regression in binary size when using LTO #43054

Closed
@japaric

Description

@japaric

STR

$ git clone https://github.com/japaric/2wd

$ cd 2wd/firmware

$ git rev-parse HEAD
3750a542d77a37c099f9cfffe066f7369d6ec9de

$ xargo build --release

$ arm-none-eabi-size arm-none-eabi-size target/thumbv7m-none-eabi/release/firmware
   text    data     bss     dec     hex filename
  10118      24      20   10162    27b2 firmware

With version: rustc 1.20.0-nightly (067971139 2017-07-02)
(nightly-2017-07-03).

This is a 200%+ increase in binary size compared to an older nightly:

$ arm-none-eabi-size arm-none-eabi-size target/thumbv7m-none-eabi/release/firmware
   text    data     bss     dec     hex filename
   3057      24      20    3101     c1d firmware

With version: rustc 1.20.0-nightly (05b579766 2017-07-01)
(nightly-2017-07-02).

The number gets worst with simpler programs. I've seen increases of up to 600%
(1KB -> 7KB).

The compiler seems to have lost the ability to optimize away the formatting
machinery -- the program shown here doesn't do any formatting on panics.
Compare the disassembly of the normal program vs the one of the "bloated"
program.

PRs between the good and bad version:

cc @alexcrichton @brson @est31

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions