rust/compiler
Guillaume Gomez 8dfbc76f34
Rollup merge of #114974 - nbdd0121:vtable, r=b-naber
Add an (perma-)unstable option to disable vtable vptr

This flag is intended for evaluation of trait upcasting space cost for embedded use cases.

Compared to the approach in #112355, this option provides a way to evaluate end-to-end cost of trait upcasting. Rationale: https://github.com/rust-lang/rust/issues/112355#issuecomment-1658207769

## How this flag should be used (after merge)

Build your project with and without `-Zno-trait-vptr` flag. If you are using cargo, set `RUSTFLAGS="-Zno-trait-vptr"` in the environment variable. You probably also want to use `-Zbuild-std` or the binary built may be broken. Save both binaries somewhere.

### Evaluate the space cost

The option has a direct and indirect impact on vtable space usage. Directly, it gets rid of the trait vptr entry needed to store a pointer to a vtable of a supertrait. (IMO) this is a small saving usually. The larger saving usually comes with the indirect saving by eliminating the vtable of the supertrait (and its parent).

Both impacts only affects vtables (notably the number of functions monomorphized should , however where vtable reside can depend on your relocation model. If the relocation model is static, then vtable is rodata (usually stored in Flash/ROM together with text in embedded scenario). If the binary is relocatable, however, the vtable will live in `.data` (more specifically, `.data.rel.ro`), and this will need to reside in RAM (which may be a more scarce resource in some cases), together with dynamic relocation info living in readonly segment.

For evaluation, you should run `size` on both binaries, with and without the flag. `size` would output three columns, `text`, `data`, `bss` and the sum `dec` (and it's hex version). As explained above, both `text` and `data` may change. `bss` shouldn't usually change. It'll be useful to see:
* Percentage change in text + data (indicating required flash/ROM size)
* Percentage change in data + bss (indicating required RAM size)
2023-08-27 20:12:47 +02:00
..
rustc inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_abi Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
rustc_arena Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
rustc_ast Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov 2023-08-24 12:52:35 +00:00
rustc_ast_lowering Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov 2023-08-24 12:52:35 +00:00
rustc_ast_passes Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov 2023-08-24 12:52:35 +00:00
rustc_ast_pretty Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov 2023-08-24 12:52:35 +00:00
rustc_attr Auto merge of #114201 - Centri3:explicit-repr-rust, r=WaffleLapkin 2023-08-25 00:02:54 +00:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco 2023-08-25 08:47:18 +00:00
rustc_builtin_macros rustc: Move features from Session to GlobalCtxt 2023-08-11 16:51:50 +08:00
rustc_codegen_cranelift when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
rustc_codegen_gcc Revert "Use the same DISubprogram for each instance of the same inlined function within the caller" 2023-08-25 19:49:10 -04:00
rustc_codegen_llvm Auto merge of #115232 - wesleywiser:revert_114643, r=tmiasko 2023-08-26 07:47:26 +00:00
rustc_codegen_ssa Auto merge of #115139 - cjgillot:llvm-fragment, r=nikic 2023-08-27 14:06:57 +00:00
rustc_const_eval Auto merge of #115184 - saethlin:local-allocated-spans, r=RalfJung 2023-08-25 17:03:33 +00:00
rustc_data_structures Rollup merge of #114987 - RalfJung:unsound-mmap, r=cjgillot 2023-08-24 22:53:57 +01:00
rustc_driver Update rustix 2023-07-03 07:20:51 +00:00
rustc_driver_impl Move extra_compiler_flags() to rustc_session 2023-08-24 06:31:11 +02:00
rustc_error_codes Fix syntax in E0191 explanation. 2023-08-21 18:45:51 +07:00
rustc_error_messages Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
rustc_errors Add comment to the push_trailing function 2023-08-24 17:09:14 -04:00
rustc_expand Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
rustc_feature add rustc_abi debugging attribute 2023-08-27 11:55:49 +02:00
rustc_fluent_macro Fix diagnostics with errors 2023-05-26 10:44:18 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco 2023-08-25 08:47:18 +00:00
rustc_hir_analysis Allow MaybeUninit in input and output of inline assembly 2023-08-23 21:57:18 +09:00
rustc_hir_pretty Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obk 2023-08-08 19:23:41 +00:00
rustc_hir_typeck Account for Weak alias kinds when adding more targetted obligation 2023-08-26 20:10:19 +00:00
rustc_incremental Ignore unexpected incr-comp session dirs 2023-08-18 19:57:41 +02:00
rustc_index Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur 2023-08-24 11:10:52 +00:00
rustc_infer Merge if and match expressions that don't make sense to have separated 2023-08-26 13:37:43 -03:00
rustc_interface Rollup merge of #114974 - nbdd0121:vtable, r=b-naber 2023-08-27 20:12:47 +02:00
rustc_lexer Update lexer emoji diagnostics to Unicode 15.0 2023-07-29 08:47:21 +08:00
rustc_lint Rollup merge of #115152 - weihanglo:lint-refactor, r=compiler-errors 2023-08-24 22:53:59 +01:00
rustc_lint_defs Auto merge of #115104 - compiler-errors:rollup-8235xz5, r=compiler-errors 2023-08-22 16:16:32 +00:00
rustc_llvm Auto merge of #115079 - cuviper:unused-mcinfo, r=Mark-Simulacrum 2023-08-27 10:32:24 +00:00
rustc_log inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_macros Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
rustc_metadata Remove metadata_loader query 2023-08-13 16:38:50 +00:00
rustc_middle Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco 2023-08-25 08:47:18 +00:00
rustc_mir_build Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco 2023-08-25 08:47:18 +00:00
rustc_mir_dataflow when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
rustc_mir_transform Auto merge of #115138 - cjgillot:dse-move-packed, r=compiler-errors 2023-08-25 13:27:21 +00:00
rustc_monomorphize when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
rustc_parse Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov 2023-08-24 12:52:35 +00:00
rustc_parse_format Fix unit tests 2023-07-19 16:37:09 +00:00
rustc_passes add rustc_abi debugging attribute 2023-08-27 11:55:49 +02:00
rustc_plugin_impl
rustc_privacy Use {Local}ModDefId in many queries 2023-08-14 07:22:48 +00:00
rustc_query_impl Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
rustc_query_system Fix waiting on a query that panicked 2023-08-25 03:34:36 +02:00
rustc_resolve Auto merge of #113408 - petrochenkov:bindintern2, r=cjgillot 2023-08-24 20:05:57 +00:00
rustc_serialize Upgrade to indexmap 2.0.0 2023-07-03 13:51:54 -07:00
rustc_session Rollup merge of #114974 - nbdd0121:vtable, r=b-naber 2023-08-27 20:12:47 +02:00
rustc_smir Auto merge of #115211 - spastorino:add-missing-smir-generics-of, r=compiler-errors 2023-08-26 00:32:16 +00:00
rustc_span add rustc_abi debugging attribute 2023-08-27 11:55:49 +02:00
rustc_symbol_mangling Fix CFI: f32 and f64 are encoded incorrectly for c 2023-08-24 21:02:06 -07:00
rustc_target Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur 2023-08-24 11:10:52 +00:00
rustc_trait_selection Rollup merge of #114974 - nbdd0121:vtable, r=b-naber 2023-08-27 20:12:47 +02:00
rustc_traits refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_transmute Don't attempt to compute layout of type referencing error 2023-07-27 18:24:08 +00:00
rustc_ty_utils Rollup merge of #114670 - compiler-errors:issue-114660, r=cjgillot 2023-08-09 23:00:00 +02:00
rustc_type_ir Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00