rust/compiler/rustc_codegen_llvm/src
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
..
back Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum 2021-10-25 22:59:46 +02:00
coverageinfo Fix clippy lints 2021-10-01 23:17:19 +02:00
debuginfo Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser 2021-10-11 04:31:47 +00:00
llvm Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum 2021-10-25 22:59:46 +02:00
abi.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
allocator.rs Include debug info for the allocator shim 2021-08-31 15:24:20 -07:00
asm.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
attributes.rs Enable AutoFDO. 2021-10-06 19:36:52 +00:00
base.rs Make hash_result an Option. 2021-10-20 18:29:18 +02:00
builder.rs Remap ssa RealPredicate to llvm RealPredicate 2021-10-12 11:55:45 +02:00
callee.rs add platform support details file for armv7-unknown-linux-uclibc 2021-10-06 14:33:13 +00:00
common.rs Make abi::Abi Copy and remove a *lot* of refs 2021-09-09 10:41:19 +02:00
consts.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
context.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
declare.rs Remove the decl arg from FnAbi::llvm_type 2021-08-05 10:58:55 -07:00
intrinsic.rs Rollup merge of #89298 - gcohara:issue89193, r=workingjubilee 2021-10-07 16:24:48 +02:00
lib.rs allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
llvm_util.rs Auto merge of #89808 - tmiasko:llvm-multithreaded, r=nagisa 2021-10-25 05:28:07 +00:00
mono_item.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
type_.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
type_of.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
va_arg.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00