Skip to content

28x binary size regression in recent nightly #85519

Closed

Description

@jonas-schievink

There seems to be a significant regression in binary size in the most recent nightly:

nightly-2021-05-19

$ size target/thumbv6m-none-eabi/debug/hello
   text	   data	    bss	    dec	    hex	filename
   6056	     48	   1032	   7136	   1be0	target/thumbv6m-none-eabi/debug/hello

nightly-2021-05-20

$ size target/thumbv6m-none-eabi/debug/hello
   text	   data	    bss	    dec	    hex	filename
 201372	     48	   1032	 202452	  316d4	target/thumbv6m-none-eabi/debug/hello

Steps to reproduce:

Commits in that range: 4e3e6db...f94942d

#85274 looks suspicious (cc @luqmana)

Activity

  1. added
    A-linkageArea: linking into static, shared libraries and binaries
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    I-heavyIssue: Problems and improvements with respect to binary size of generated code.
    on May 20, 2021
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on May 20, 2021
  3. jamesmunns commented on May 20, 2021

    @jamesmunns
    Contributor

    This seems to have been noticed here as well: rust-osdev/bootloader#168

    Edit: Fixed link to rust-osdev repo instead of this issue

    Edit 2: This also indicates you can work-around the regression by manually passing --gc-sections as a linker flag.

  4. jamesmunns commented on May 20, 2021

    @jamesmunns
    Contributor

    Also as a note, @japaric tested this with using arm-none-eabi-ld as the linker instead of the default rust-lld, and this issue remained (referring to #85274). He can confirm whether he set the "linker flavor" or similar as well.

  5. Dirbaio commented on May 20, 2021

    @Dirbaio
    Contributor

    it's very likely #85274, since adding -C link-arg=--gc-sections to rustflags fixes the bloat.

  6. nagisa commented on May 20, 2021

    @nagisa
    Member

    Is the linker for this target guaranteed to be gnu ld? Doesn't sound like something that we can claim, can we? It does look like we default to lld.

  7. jonas-schievink commented on May 20, 2021

    @jonas-schievink
    ContributorAuthor

    We do default to LLD, which can also garbage-collect unused sections

  8. nagisa commented on May 20, 2021

    @nagisa
    Member

    Yeah, I was just wondering if we should expand our logic around when we specify the --gc-sections flag or just say that the targets use a gnu-ld-like linker.

  9. jonas-schievink commented on May 20, 2021

    @jonas-schievink
    ContributorAuthor

    Yeah, in practice I don't think anyone uses a non-GNU-compatible linker there

  10. petrochenkov commented on May 20, 2021

    @petrochenkov
    Contributor

    It may make sense to set the default for linker_is_gnu to true because ld-style linkers are usually gnu, and it's easier to explicitly list exceptions than to not forget setting it to true for all random embedded targets.

  11. petrochenkov commented on May 20, 2021

    @petrochenkov
    Contributor

    If the default is not flipped then compiler\rustc_target\src\spec\thumb_base.rs needs to add linker_is_gnu: true + other target specs should probably be audited as well.

  12. added a commit that references this issue on May 22, 2021
    21e1cd9
  13. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions