diff options
| author | Gary Guo <gary@garyguo.net> | 2023-08-17 12:07:22 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2023-08-18 17:44:04 +0100 |
| commit | a7633b8a71d163a7392f4ef2cb80ea7076302f71 (patch) | |
| tree | 95de5e4dfcddbee97537504bbbd795f75c50a53b | |
| parent | 0f7f6b70617fbcda9f73755fa9b560bfb0a588eb (diff) | |
| download | rust-a7633b8a71d163a7392f4ef2cb80ea7076302f71.tar.gz rust-a7633b8a71d163a7392f4ef2cb80ea7076302f71.zip | |
Add an (perma-)unstable option to disable vtable vptr
This flag is intended for evaluation of trait upcasting space cost for embedded use cases.
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/vtable.rs | 2 |
3 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index e3d66d18388..b53ba251bcd 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -807,6 +807,7 @@ fn test_unstable_options_tracking_hash() { tracked!(no_jump_tables, true); tracked!(no_link, true); tracked!(no_profiler_runtime, true); + tracked!(no_trait_vptr, true); tracked!(no_unique_section_names, true); tracked!(oom, OomStrategy::Panic); tracked!(osx_rpath_install_name, true); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 055ab2d9c15..40099de707b 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1631,6 +1631,8 @@ options! { "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"), no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED], "prevent automatic injection of the profiler_builtins crate"), + no_trait_vptr: bool = (false, parse_no_flag, [TRACKED], + "disable generation of trait vptr in vtable for upcasting"), no_unique_section_names: bool = (false, parse_bool, [TRACKED], "do not use unique names for text and data sections when -Z function-sections is used"), normalize_docs: bool = (false, parse_bool, [TRACKED], diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 427ac368432..e41073937be 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -152,7 +152,7 @@ fn prepare_vtable_segments_inner<'tcx, T>( while let Some((inner_most_trait_ref, emit_vptr, mut siblings)) = stack.pop() { segment_visitor(VtblSegment::TraitOwnEntries { trait_ref: inner_most_trait_ref, - emit_vptr, + emit_vptr: emit_vptr && !tcx.sess.opts.unstable_opts.no_trait_vptr, })?; // If we've emitted (fed to `segment_visitor`) a trait that has methods present in the vtable, |
