Skip to content

Support smaller failure in libcore #14442

Closed
@bharrisau

Description

@bharrisau

With the reshuffle of libcore (#13851) it is becoming easier to build an embedded project with Rust. I've implemented the new weak failure in Zinc.rs, but as a result the binaries are 5-6kB larger (hackndev/zinc#41).

The two sources of additional size are c_str_to_static_slice pulling in is_utf8 in an assertion (could this be debug_assert?), and the format_args! macro. Trimming these gets the 5-6kB back (i.e. the empty application goes from 7576 bytes to 1888 bytes).

@alexcrichton: I'm not sure the best solution. My limited knowledge of the system suggests having a --cfg flag to compile libcore with stringless failures (maybe --cfg failure_tiny). Just replacing the c_str_to_static_slice with a zero len Slice {data: pointer, len: 0} (we can get the info from the debugger) and passing a zero length string to format_args!.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions