rust/compiler
bors c79419af07 Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisa
rustc: Store metadata-in-rlibs in object files

This commit updates how rustc compiler metadata is stored in rlibs.
Previously metadata was stored as a raw file that has the same format as
`--emit metadata`. After this commit, however, the metadata is encoded
into a small object file which has one section which is the contents of
the metadata.

The motivation for this commit is to fix a common case where #83730
arises. The problem is that when rustc crates a `dylib` crate type it
needs to include entire rlib files into the dylib, so it passes
`--whole-archive` (or the equivalent) to the linker. The problem with
this, though, is that the linker will attempt to read all files in the
archive. If the metadata file were left as-is (today) then the linker
would generate an error saying it can't read the file. The previous
solution was to alter the rlib just before linking, creating a new
archive in a temporary directory which has the metadata file removed.

This problem from before this commit is now removed if the metadata file
is stored in an object file that the linker can read. The only caveat we
have to take care of is to ensure that the linker never actually
includes the contents of the object file into the final output. We apply
similar tricks as the `.llvmbc` bytecode sections to do this.

This involved changing the metadata loading code a bit, namely updating
some of the LLVM C APIs used to use non-deprecated ones and fiddling
with the lifetimes a bit to get everything to work out. Otherwise though
this isn't intended to be a functional change really, only that metadata
is stored differently in archives now.

This should end up fixing #83730 because by default dylibs will no
longer have their rlib dependencies "altered" meaning that
split-debuginfo will continue to have valid paths pointing at the
original rlibs. (note that we still "alter" rlibs if LTO is enabled to
remove Rust object files and we also "alter" for the #[link(cfg)]
feature, but that's rarely used).

Closes #83730
2021-06-04 19:29:50 +00:00
..
rustc
rustc_apfloat remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_arena
rustc_ast Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
rustc_ast_lowering Rename take_trait_map. 2021-06-01 20:53:04 +02:00
rustc_ast_passes Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_ast_pretty remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_attr remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_builtin_macros remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_codegen_cranelift Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
rustc_codegen_llvm Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisa 2021-06-04 19:29:50 +00:00
rustc_codegen_ssa Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisa 2021-06-04 19:29:50 +00:00
rustc_data_structures Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_driver
rustc_error_codes
rustc_errors Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
rustc_expand Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_feature Auto merge of #85331 - cjgillot:dirty-dancing, r=Aaron1011 2021-06-01 23:02:52 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_hir_pretty remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_incremental Auto merge of #85337 - cjgillot:less-anon, r=michaelwoerister 2021-06-02 13:11:41 +00:00
rustc_index Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_infer Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_interface Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisa 2021-06-04 19:29:50 +00:00
rustc_lexer
rustc_lint Auto merge of #85788 - rylev:force-warns, r=nikomatsakis 2021-06-04 13:31:51 +00:00
rustc_lint_defs Rollup merge of #85852 - m-ou-se:machineapplicable-docs, r=nikomatsakis 2021-06-03 14:35:30 +09:00
rustc_llvm rustc: Store metadata-in-rlibs in object files 2021-06-04 10:05:20 -07:00
rustc_macros
rustc_metadata Rollup merge of #85889 - denismerigoux:master, r=petrochenkov 2021-06-04 13:42:56 +09:00
rustc_middle Auto merge of #85788 - rylev:force-warns, r=nikomatsakis 2021-06-04 13:31:51 +00:00
rustc_mir Auto merge of #85385 - richkadel:simpler-simplify-with-coverage, r=wesleywiser 2021-06-04 10:18:54 +00:00
rustc_mir_build Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_parse Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_parse_format remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_passes Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_plugin_impl
rustc_privacy Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
rustc_query_impl Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_query_system Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_resolve Rollup merge of #85896 - BoxyUwU:remove-fixme-fwd-declared-const-default, r=petrochenkov 2021-06-03 14:35:36 +09:00
rustc_save_analysis Merge CrateDisambiguator into StableCrateId 2021-05-30 12:51:34 +02:00
rustc_serialize Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_session Auto merge of #85788 - rylev:force-warns, r=nikomatsakis 2021-06-04 13:31:51 +00:00
rustc_span Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_symbol_mangling Restrict access to crate_name. 2021-06-02 18:35:32 +02:00
rustc_target Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_trait_selection Restrict access to crate_name. 2021-06-02 18:35:32 +02:00
rustc_traits
rustc_ty_utils Restrict access to crate_name. 2021-06-02 18:35:32 +02:00
rustc_type_ir Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_typeck Rollup merge of #85937 - m-ou-se:macro-ref-suggestions, r=estebank 2021-06-04 13:42:58 +09:00