rust/compiler
Miguel Ojeda 74b8d324eb Support .comment section like GCC/Clang (!llvm.ident)
Both GCC and Clang write by default a `.comment` section with compiler
information:

```txt
$ gcc -c -xc /dev/null && readelf -p '.comment' null.o

String dump of section '.comment':
  [     1]  GCC: (GNU) 11.2.0

$ clang -c -xc /dev/null && readelf -p '.comment' null.o

String dump of section '.comment':
  [     1]  clang version 14.0.1 (https://github.com/llvm/llvm-project.git c62053979489ccb002efe411c3af059addcb5d7d)
```

They also implement the `-Qn` flag to avoid doing so:

```txt
$ gcc -Qn -c -xc /dev/null && readelf -p '.comment' null.o
readelf: Warning: Section '.comment' was not dumped because it does not exist!

$ clang -Qn -c -xc /dev/null && readelf -p '.comment' null.o
readelf: Warning: Section '.comment' was not dumped because it does not exist!
```

So far, `rustc` only does it for WebAssembly targets and only
when debug info is enabled:

```txt
$ echo 'fn main(){}' | rustc --target=wasm32-unknown-unknown --emit=llvm-ir -Cdebuginfo=2 - && grep llvm.ident rust_out.ll
!llvm.ident = !{!27}
```

In the RFC part of this PR it was decided to always add
the information, which gets us closer to other popular compilers.
An opt-out flag like GCC and Clang may be added later on if deemed
necessary.

Implementation-wise, this covers both `ModuleLlvm::new()` and
`ModuleLlvm::new_metadata()` cases by moving the addition to
`context::create_module` and adds a few test cases.

ThinLTO also sees the `llvm.ident` named metadata duplicated (in
temporary outputs), so this deduplicates it like it is done for
`wasm.custom_sections`. The tests also check this duplication does
not take place.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-07-21 22:01:50 +02:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Track (partial) niche information in NaiveLayout 2023-07-21 14:23:23 +02:00
rustc_apfloat
rustc_arena Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
rustc_ast Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
rustc_ast_lowering Auto merge of #113847 - SparrowLii:path_clone, r=cjgillot 2023-07-21 11:02:47 +00:00
rustc_ast_passes Lint against misplaced where-clauses on assoc tys in traits 2023-07-11 01:19:11 +02:00
rustc_ast_pretty Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
rustc_attr Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_baked_icu_data Regen baked data 2023-05-02 10:45:16 -07:00
rustc_borrowck Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
rustc_builtin_macros Add a comparison between match *self and intrinsics::unreachable() 2023-07-16 15:33:29 -07:00
rustc_codegen_cranelift support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
rustc_codegen_gcc Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk 2023-07-21 15:00:36 +00:00
rustc_codegen_llvm Support .comment section like GCC/Clang (!llvm.ident) 2023-07-21 22:01:50 +02:00
rustc_codegen_ssa Rollup merge of #113780 - dtolnay:printkindpath, r=b-naber 2023-07-21 06:52:28 +02:00
rustc_const_eval CTFE: move target_{i, u}size_{min, max) to rustc_abi::TargetDataLayout 2023-07-21 03:31:47 +02:00
rustc_data_structures Introduce ExtentUnord trait for collections that can safely consume UnordItems. 2023-07-14 10:10:15 +02:00
rustc_driver Update rustix 2023-07-03 07:20:51 +00:00
rustc_driver_impl Rollup merge of #113780 - dtolnay:printkindpath, r=b-naber 2023-07-21 06:52:28 +02:00
rustc_error_codes error/E0691: include alignment in error message 2023-07-21 11:04:16 +02:00
rustc_error_messages On nightly, dump ICE backtraces to disk 2023-07-19 14:10:07 +00:00
rustc_errors Don't translate compiler-internal bug messages 2023-07-20 09:51:47 +00:00
rustc_expand Don't translate compiler-internal bug messages 2023-07-20 09:51:47 +00:00
rustc_feature Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_fluent_macro Fix diagnostics with errors 2023-05-26 10:44:18 +00:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
rustc_hir Properly document lifetime_mapping in OpaqueTy 2023-07-17 14:56:33 +00:00
rustc_hir_analysis error/E0691: include alignment in error message 2023-07-21 11:04:16 +02:00
rustc_hir_pretty hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
rustc_hir_typeck Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
rustc_incremental Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_index Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_infer Document PredicateSet::insert 2023-07-19 09:44:40 +00:00
rustc_interface Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk 2023-07-21 15:00:36 +00:00
rustc_lexer Revert the lexing of c_str_literals 2023-07-05 13:11:17 +02:00
rustc_lint Rollup merge of #113832 - WaffleLapkin:track_lint_caller, r=compiler-errors 2023-07-18 19:06:04 +02:00
rustc_lint_defs Fix removal span calculation of unused_qualifications suggestion 2023-07-18 09:52:08 +08:00
rustc_llvm Support .comment section like GCC/Clang (!llvm.ident) 2023-07-21 22:01:50 +02:00
rustc_log Downgrade tracing and syn 2023-07-02 21:02:31 +02:00
rustc_macros Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_metadata add crate-local -Z reference_niches unstable flag (does nothing for now) 2023-07-21 03:31:45 +02:00
rustc_middle Auto merge of #113922 - matthiaskrgr:rollup-90cj2vv, r=matthiaskrgr 2023-07-21 16:52:21 +00:00
rustc_mir_build Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
rustc_mir_dataflow Turn copy into moves during DSE. 2023-07-19 09:59:12 +00:00
rustc_mir_transform Auto merge of #113802 - cjgillot:check-debuginfo, r=compiler-errors 2023-07-21 09:14:55 +00:00
rustc_monomorphize Change the primary CGU merging algorithm. 2023-07-19 07:23:11 +10:00
rustc_parse Don't translate compiler-internal bug messages 2023-07-20 09:51:47 +00:00
rustc_parse_format Fix unit tests 2023-07-19 16:37:09 +00:00
rustc_passes Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_plugin_impl Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_privacy refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_query_impl Avoid calling queries during query stack printing 2023-06-27 16:12:07 +02:00
rustc_query_system add naive_layout_of query 2023-07-21 03:31:45 +02:00
rustc_resolve Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
rustc_serialize Upgrade to indexmap 2.0.0 2023-07-03 13:51:54 -07:00
rustc_session Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk 2023-07-21 15:00:36 +00:00
rustc_smir Implement Stable for ty::Ty 2023-07-21 11:56:49 -03:00
rustc_span Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
rustc_symbol_mangling refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_target Auto merge of #113922 - matthiaskrgr:rollup-90cj2vv, r=matthiaskrgr 2023-07-21 16:52:21 +00:00
rustc_trait_selection Auto merge of #113922 - matthiaskrgr:rollup-90cj2vv, r=matthiaskrgr 2023-07-21 16:52:21 +00:00
rustc_traits refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_transmute Auto merge of #113677 - bryangarza:unevaluated-const-ice_issue-110892, r=davidtwco 2023-07-18 09:07:32 +00:00
rustc_ty_utils Track (partial) niche information in NaiveLayout 2023-07-21 14:23:23 +02:00
rustc_type_ir refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00