Skip to content

core::fmt fails to optimize on arm-none-eabi #43369

Open
@therealprof

Description

@therealprof

While generating code for an Cortex-M0 I noticed that using core::fmt to generate printable output generates extremely bloated code, even when just using a plain string as format.

According to @rkruppe on IRC this is most likely due to a missed elimination of dead code by LTO.

A stripped down example can be found here:
https://gist.github.com/anonymous/7cfc8b881fcb8fdc792428dd772502cb

The generated assembly is here:
https://gist.github.com/anonymous/9cfa48e53e3b1c8ba1ddb69f8ae3ea3b

I also have an example (serial_slow_helloworld) in this repo https://github.com/therealprof/stm32f042.git . xargo build --release --examples will create a binary demonstrating the problem.

This happens for me with:

rustc 1.20.0-nightly (8f1339af2 2017-07-16)
binary: rustc
commit-hash: 8f1339af2e5d1b33ec9ee3c8a3c531bcd61770fc
commit-date: 2017-07-16
host: x86_64-apple-darwin
release: 1.20.0-nightly
LLVM version: 4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.I-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.WG-embeddedWorking group: Embedded systems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions