{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/56068","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/56068/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/56068/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/56068/events","html_url":"https://github.com/rust-lang/rust/issues/56068","id":382175735,"node_id":"MDU6SXNzdWUzODIxNzU3MzU=","number":56068,"title":"Trivial dependencies on large crates pull in massive amounts of debuginfo","user":{"login":"rocallahan","id":296135,"node_id":"MDQ6VXNlcjI5NjEzNQ==","avatar_url":"https://avatars0.githubusercontent.com/u/296135?v=4","gravatar_id":"","url":"https://api.github.com/users/rocallahan","html_url":"https://github.com/rocallahan","followers_url":"https://api.github.com/users/rocallahan/followers","following_url":"https://api.github.com/users/rocallahan/following{/other_user}","gists_url":"https://api.github.com/users/rocallahan/gists{/gist_id}","starred_url":"https://api.github.com/users/rocallahan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rocallahan/subscriptions","organizations_url":"https://api.github.com/users/rocallahan/orgs","repos_url":"https://api.github.com/users/rocallahan/repos","events_url":"https://api.github.com/users/rocallahan/events{/privacy}","received_events_url":"https://api.github.com/users/rocallahan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-11-19T11:39:38Z","updated_at":"2018-11-20T06:34:45Z","closed_at":null,"author_association":"NONE","body":"```\r\nextern crate rusoto_core;\r\nconst REGION: rusoto_core::Region = rusoto_core::Region::UsEast1;\r\nfn main() {\r\n    println!(\"Hello, region {:?}\", &REGION);\r\n}\r\n```\r\n`rusoto_core::Region` is a very simple enum type. This doesn't run any interesting code. The resulting Linux debug-build binary is 41MB. If I replace `&REGION` with `0` the binary is 7.5MB.\r\n\r\n`readelf -a` shows that `.text` is 370,558 bytes. `.debug_info` is 10,541,677 bytes. The other debug sections account for most of the rest.\r\n\r\nInspecting the debuginfo shows DWARF compilation units for `rusoto_core` and lots of its dependencies that are entirely dead code. For example:\r\n```\r\nCOMPILE_UNIT<header overall offset = 0x0034b008>:\r\n< 0><0x0000000b>  DW_TAG_compile_unit\r\n                    DW_AT_producer              clang LLVM (rustc version 1.30.1 (1433507eb 2018-11-07))\r\n                    DW_AT_language              DW_LANG_Rust\r\n                    DW_AT_name                  /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/src/lib.rs\r\n                    DW_AT_stmt_list             0x001534c8\r\n                    DW_AT_comp_dir              /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33\r\n                    DW_AT_GNU_pubnames          yes(1)\r\n                    DW_AT_low_pc                0x00000000\r\n                    DW_AT_ranges                0x000a7120\r\n                ranges: 89 at .debug_ranges offset 684320 (0x000a7120)\r\n                        [ 0] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>\r\n                        [ 1] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>\r\n                        [ 2] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>\r\n                        [ 3] <offset pair low-off: 0x00000001 addr 0x00000001 high-off: 0x00000001 addr 0x00000001>\r\n```\r\n... followed by 85 more identical ranges. These all indicate empty code ranges; all code for this CU has been stripped by the linker. However, this CU still has a ton of debuginfo for types and for functions. E.g.:\r\n```\r\n< 4><0x00001802>          DW_TAG_subprogram\r\n                            DW_AT_low_pc                0x00000000\r\n                            DW_AT_high_pc               <offset-from-lowpc>262\r\n                            DW_AT_frame_base            len 0x0001: 57: DW_OP_reg7\r\n                            DW_AT_linkage_name          _ZN91_$LT$core..slice..Iter$LT$$u27$a$C$$u20$T$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$4next1\r\n7hc6f1932985554eebE\r\n                            DW_AT_name                  next<serde_json::value::Value>\r\n                            DW_AT_decl_file             0x00000005 /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/libcore/slice/m\r\nod.rs\r\n                            DW_AT_decl_line             0x00000978\r\n                            DW_AT_type                  <0x000007b0>\r\n< 5><0x00001820>            DW_TAG_formal_parameter\r\n                              DW_AT_location              len 0x0002: 9128: DW_OP_fbreg 40\r\n                              DW_AT_name                  self\r\n                              DW_AT_decl_file             0x00000003 /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/src/lib.rs\r\n                              DW_AT_decl_line             0x00000001\r\n                              DW_AT_type                  <0x00002f94>\r\n< 5><0x0000182e>            DW_TAG_inlined_subroutine\r\n                              DW_AT_abstract_origin       <0x00001a7d>\r\n                              DW_AT_low_pc                0x00000000\r\n                              DW_AT_high_pc               <offset-from-lowpc>123\r\n                              DW_AT_call_file             0x00000005 /home/roc/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.33/libcore/slice/mod.rs\r\n                              DW_AT_call_line             0x00000982\r\n< 6><0x00001842>              DW_TAG_formal_parameter\r\n                                DW_AT_location              len 0x0002: 9138: DW_OP_fbreg 56\r\n                                DW_AT_abstract_origin       <0x00001a97>\r\n< 6><0x0000184a>              DW_TAG_formal_parameter\r\n                                DW_AT_location              len 0x0003: 91c000: DW_OP_fbreg 64\r\n                                DW_AT_abstract_origin       <0x00001aa2>\r\n< 6><0x00001853>              DW_TAG_lexical_block\r\n                                DW_AT_low_pc                0x00000000\r\n                                DW_AT_high_pc               <offset-from-lowpc>36\r\n< 7><0x00001860>                DW_TAG_variable\r\n                                  DW_AT_location              len 0x0003: 91d000: DW_OP_fbreg 80\r\n                                  DW_AT_abstract_origin       <0x00001aae>\r\n< 5><0x0000186b>            DW_TAG_template_type_parameter\r\n                              DW_AT_type                  <0x00000064>\r\n                              DW_AT_name                  T\r\n```\r\nAll `DW_AT_low_pc`s of `DW_TAG_subprogram`, `DW_TAG_lexical_block` and `DW_TAG_inlined_subroutine` in this CU are zero. There are a lot of CUs like this."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/440160568","html_url":"https://github.com/rust-lang/rust/issues/56068#issuecomment-440160568","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/56068","id":440160568,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDE2MDU2OA==","user":{"login":"rocallahan","id":296135,"node_id":"MDQ6VXNlcjI5NjEzNQ==","avatar_url":"https://avatars0.githubusercontent.com/u/296135?v=4","gravatar_id":"","url":"https://api.github.com/users/rocallahan","html_url":"https://github.com/rocallahan","followers_url":"https://api.github.com/users/rocallahan/followers","following_url":"https://api.github.com/users/rocallahan/following{/other_user}","gists_url":"https://api.github.com/users/rocallahan/gists{/gist_id}","starred_url":"https://api.github.com/users/rocallahan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rocallahan/subscriptions","organizations_url":"https://api.github.com/users/rocallahan/orgs","repos_url":"https://api.github.com/users/rocallahan/repos","events_url":"https://api.github.com/users/rocallahan/events{/privacy}","received_events_url":"https://api.github.com/users/rocallahan/received_events","type":"User","site_admin":false},"created_at":"2018-11-20T06:34:45Z","updated_at":"2018-11-20T06:34:45Z","author_association":"NONE","body":"> In that case, probably the best option here would be to teach the linker's --gc-sections implementation to drop all debuginfo sections for any object file that has had all its code and data sections discarded.\r\n\r\nI implemented this in LLD. It works well for some of my binaries, and for the testcase here, but only shrank the overall size of my built binaries from 2.4G to 2.0G, so I'm not sure whether it's worth the effort to push upstream..."}}
{"actor":{"display_login":"rocallahan"}}