Skip to content

Object size of the rfl drviers are larger than the corresponding C drivers especially when with debug symbols #1039

@Richardhongyu

Description

@Richardhongyu

Recently I have a research project about comparing the RFL drivers with C drivers. I found that Rust drivers are bigger than C especially when they are compiled with symbols. From what I observed, the Rust drivers are 2X than C drivers without debug symbols and 4-6X with debug symbols. I use the binder driver from the earlier version as an example to show this. There are two object files of the binder driver on the C side. I just use one as an example to explain.

drivers/android/rust_binder.o : section size addr .text 44744 0 .initcall6.init 4 0 .rodata 3089 0 .data 8 0 .rodata.cst8 16 0 .rodata.cst32 32 0 .rodata.cst4 12 0 .bss 24 0 .modinfo 148 0 .debug_loc 159816 0 .debug_abbrev 1430 0 .debug_info 401422 0 .debug_aranges 112 0 .debug_ranges 92784 0 .debug_str 466822 0 .debug_pubnames 58507 0 .debug_pubtypes 244866 0 .note.GNU-stack 0 0 .debug_frame 5504 0 .debug_line 38268 0 Total 1517608 drivers/android/binder.o : section size addr .text 51504 0 .note.gnu.property 32 0 .initcall6.init 4 0 __ex_table 240 0 .rodata 2504 0 .altinstructions 756 0 .init.text 196 0 __bug_table 1092 0 .rodata.str 2275 0 .data 216 0 __param 120 0 .modinfo 119 0 .rodata.str1.1 9081 0 .bss 20264 0 .discard.addressable 8 0 .debug_loclists 54436 0 .debug_abbrev 2165 0 .debug_info 126699 0 .debug_rnglists 12959 0 .debug_str_offsets 15136 0 .debug_str 47377 0 .debug_addr 14672 0 .comment 38 0 .note.GNU-stack 0 0 .debug_frame 4472 0 .debug_line 35596 0 .debug_line_str 2322 0 .llvm_addrsig 114 0 Total 404397

The extra size comes from two reasons.

  • Currently, Rust generates some unnecessary sections such as debug_pubnames, debug_pubtypes, and debug_ranges. There is a PR, but it is not landing due to the CI problems.
  • Some sections are larger than the C side, such as debug_str and debug_info. These are caused by generic programming and the wrapping functions. It is hard to optimize them for now.

Before optimizing this, I want to ask for advice/opinions from the community. Does the object size of the RFL drivers matter? Is there anyone working on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    • toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions