Skip to content

Commit a7633b8

Browse files
committed
Add an (perma-)unstable option to disable vtable vptr
This flag is intended for evaluation of trait upcasting space cost for embedded use cases.
1 parent 0f7f6b7 commit a7633b8

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ fn test_unstable_options_tracking_hash() {
807807
tracked!(no_jump_tables, true);
808808
tracked!(no_link, true);
809809
tracked!(no_profiler_runtime, true);
810+
tracked!(no_trait_vptr, true);
810811
tracked!(no_unique_section_names, true);
811812
tracked!(oom, OomStrategy::Panic);
812813
tracked!(osx_rpath_install_name, true);

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,8 @@ options! {
16311631
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
16321632
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
16331633
"prevent automatic injection of the profiler_builtins crate"),
1634+
no_trait_vptr: bool = (false, parse_no_flag, [TRACKED],
1635+
"disable generation of trait vptr in vtable for upcasting"),
16341636
no_unique_section_names: bool = (false, parse_bool, [TRACKED],
16351637
"do not use unique names for text and data sections when -Z function-sections is used"),
16361638
normalize_docs: bool = (false, parse_bool, [TRACKED],

compiler/rustc_trait_selection/src/traits/vtable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn prepare_vtable_segments_inner<'tcx, T>(
152152
while let Some((inner_most_trait_ref, emit_vptr, mut siblings)) = stack.pop() {
153153
segment_visitor(VtblSegment::TraitOwnEntries {
154154
trait_ref: inner_most_trait_ref,
155-
emit_vptr,
155+
emit_vptr: emit_vptr && !tcx.sess.opts.unstable_opts.no_trait_vptr,
156156
})?;
157157

158158
// If we've emitted (fed to `segment_visitor`) a trait that has methods present in the vtable,

0 commit comments

Comments
 (0)