rust/compiler
Matthias Krüger 2f67647606
Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum
Add -Z no-unique-section-names to reduce ELF header bloat.

This change adds a new compiler flag that can help reduce the size of ELF binaries that contain many functions.

By default, when enabling function sections (which is the default for most targets), the LLVM backend will generate different section names for each function. For example, a function `func` would generate a section called `.text.func`. Normally this is fine because the linker will merge all those sections into a single one in the binary. However, starting with [LLVM 12](ee5d1a04), the backend will also generate unique section names for exception handling, resulting in thousands of `.gcc_except_table.*` sections ending up in the final binary because some linkers like LLD don't currently merge or strip these EH sections (see discussion [here](https://reviews.llvm.org/D83655)). This can bloat the ELF headers and string table significantly in binaries that contain many functions.

The new option is analogous to Clang's `-fno-unique-section-names`, and instructs LLVM to generate the same `.text` and `.gcc_except_table` section for each function, resulting in a smaller final binary.

The motivation to add this new option was because we have a binary that ended up with so many ELF sections (over 65,000) that it broke some existing ELF tools, which couldn't handle so many sections.

Here's our old binary:

```
$ readelf --sections old.elf | head -1
There are 71746 section headers, starting at offset 0x2a246508:

$ readelf --sections old.elf | grep shstrtab
  [71742] .shstrtab      STRTAB          0000000000000000 2977204c ad44bb 00      0   0  1
```

That's an 11MB+ string table. Here's the new binary using this option:

```
$ readelf --sections new.elf | head -1
There are 43 section headers, starting at offset 0x29143ca8:

$ readelf --sections new.elf | grep shstrtab
  [40] .shstrtab         STRTAB          0000000000000000 29143acc 0001db 00      0   0  1
```

The whole binary size went down by over 20MB, which is quite significant.
2021-10-25 22:59:46 +02:00
..
rustc Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_apfloat Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_arena Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_ast Rollup merge of #89991 - petrochenkov:visitok2, r=jackh726 2021-10-22 19:42:48 +09:00
rustc_ast_lowering Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_ast_passes Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_ast_pretty Some "parenthesis" and "parentheses" fixes 2021-10-17 12:04:01 +02:00
rustc_attr Correct typo 2021-10-16 13:36:05 -07:00
rustc_borrowck Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum 2021-10-25 11:31:47 +00:00
rustc_builtin_macros Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_codegen_cranelift Make hash_result an Option. 2021-10-20 18:29:18 +02:00
rustc_codegen_gcc Make hash_result an Option. 2021-10-20 18:29:18 +02:00
rustc_codegen_llvm Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum 2021-10-25 22:59:46 +02:00
rustc_codegen_ssa enable i8mm on arm 2021-10-25 15:10:14 +08:00
rustc_const_eval Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_data_structures Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum 2021-10-25 11:31:47 +00:00
rustc_driver Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_error_codes Rollup merge of #89922 - JohnTitor:update-e0637, r=jackh726 2021-10-22 19:42:46 +09:00
rustc_errors Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726 2021-10-24 22:26:41 +00:00
rustc_expand Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_feature Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_fs_util Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_graphviz Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_hir Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obk 2021-10-21 14:11:08 +09:00
rustc_hir_pretty Auto merge of #89124 - cjgillot:owner-info, r=michaelwoerister 2021-10-18 19:53:05 +00:00
rustc_incremental Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_index update cfg(bootstrap) 2021-10-23 21:55:57 -04:00
rustc_infer Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_interface Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum 2021-10-25 22:59:46 +02:00
rustc_lexer Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_lint Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_lint_defs Make all proc-macro back-compat lints deny-by-default 2021-10-18 13:17:05 -05:00
rustc_llvm Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum 2021-10-25 22:59:46 +02:00
rustc_macros Do not require QueryCtxt for cache_on_disk. 2021-10-23 18:12:43 +02:00
rustc_metadata Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_middle Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726 2021-10-24 22:26:41 +00:00
rustc_mir_build Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_mir_dataflow Ignore errors re: unreachable blocks in dataflow cursor unit tests 2021-10-23 21:55:57 -04:00
rustc_mir_transform Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum 2021-10-25 11:31:47 +00:00
rustc_monomorphize Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_parse Rollup merge of #89257 - aDotInTheVoid:macro-error-2, r=estebank 2021-10-22 19:42:43 +09:00
rustc_parse_format Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_passes allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
rustc_plugin_impl Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
rustc_privacy Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_query_impl Auto merge of #90210 - cjgillot:qarray2, r=Mark-Simulacrum 2021-10-25 01:10:50 +00:00
rustc_query_system Auto merge of #90210 - cjgillot:qarray2, r=Mark-Simulacrum 2021-10-25 01:10:50 +00:00
rustc_resolve Rollup merge of #90127 - JohnTitor:fix-90113, r=estebank 2021-10-25 07:54:13 +02:00
rustc_save_analysis allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
rustc_serialize Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_session Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum 2021-10-25 22:59:46 +02:00
rustc_span Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank 2021-10-24 15:48:42 +02:00
rustc_symbol_mangling allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
rustc_target Auto merge of #90040 - nbdd0121:issue-90038, r=oli-obk 2021-10-19 08:13:35 +00:00
rustc_trait_selection Rollup merge of #89889 - estebank:unmet-send-bound-on-foreign-future, r=tmandry 2021-10-25 07:54:12 +02:00
rustc_traits Move some outlives bounds things from rustc_trait_selection to rustc_typeck 2021-10-15 12:14:19 -04:00
rustc_ty_utils Replace FnLikeNode by FnKind. 2021-10-19 23:31:51 +02:00
rustc_type_ir Add two inline annotations for hot functions 2021-10-03 12:43:43 -04:00
rustc_typeck Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726 2021-10-24 22:26:41 +00:00