File tree Expand file tree Collapse file tree 8 files changed +24
-0
lines changed Expand file tree Collapse file tree 8 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -3569,6 +3569,7 @@ dependencies = [
35693569 " rustc_hir_pretty" ,
35703570 " rustc_hir_typeck" ,
35713571 " rustc_incremental" ,
3572+ " rustc_index" ,
35723573 " rustc_infer" ,
35733574 " rustc_interface" ,
35743575 " rustc_lint" ,
Original file line number Diff line number Diff line change @@ -30,5 +30,6 @@ features = ['unprefixed_malloc_on_supported_platforms']
3030jemalloc = [' dep:jemalloc-sys' ]
3131llvm = [' rustc_driver_impl/llvm' ]
3232max_level_info = [' rustc_driver_impl/max_level_info' ]
33+ rustc_randomized_layouts = [' rustc_driver_impl/rustc_randomized_layouts' ]
3334rustc_use_parallel_compiler = [' rustc_driver_impl/rustc_use_parallel_compiler' ]
3435# tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ rustc_hir_analysis = { path = "../rustc_hir_analysis" }
2323rustc_hir_pretty = { path = " ../rustc_hir_pretty" }
2424rustc_hir_typeck = { path = " ../rustc_hir_typeck" }
2525rustc_incremental = { path = " ../rustc_incremental" }
26+ rustc_index = { path = " ../rustc_index" }
2627rustc_infer = { path = " ../rustc_infer" }
2728rustc_interface = { path = " ../rustc_interface" }
2829rustc_lint = { path = " ../rustc_lint" }
@@ -72,6 +73,10 @@ ctrlc = "3.4.4"
7273# tidy-alphabetical-start
7374llvm = [' rustc_interface/llvm' ]
7475max_level_info = [' rustc_log/max_level_info' ]
76+ rustc_randomized_layouts = [
77+ ' rustc_index/rustc_randomized_layouts' ,
78+ ' rustc_middle/rustc_randomized_layouts'
79+ ]
7580rustc_use_parallel_compiler = [
7681 ' rustc_data_structures/rustc_use_parallel_compiler' ,
7782 ' rustc_interface/rustc_use_parallel_compiler' ,
Original file line number Diff line number Diff line change @@ -20,4 +20,5 @@ nightly = [
2020 " dep:rustc_macros" ,
2121 " rustc_index_macros/nightly" ,
2222]
23+ rustc_randomized_layouts = []
2324# tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -33,8 +33,19 @@ pub use vec::IndexVec;
3333///
3434/// </div>
3535#[ macro_export]
36+ #[ cfg( not( feature = "rustc_randomized_layouts" ) ) ]
3637macro_rules! static_assert_size {
3738 ( $ty: ty, $size: expr) => {
3839 const _: [ ( ) ; $size] = [ ( ) ; :: std:: mem:: size_of:: <$ty>( ) ] ;
3940 } ;
4041}
42+
43+ #[ macro_export]
44+ #[ cfg( feature = "rustc_randomized_layouts" ) ]
45+ macro_rules! static_assert_size {
46+ ( $ty: ty, $size: expr) => {
47+ // no effect other than using the statements.
48+ // struct sizes are not deterministic under randomized layouts
49+ const _: ( usize , usize ) = ( $size, :: std:: mem:: size_of:: <$ty>( ) ) ;
50+ } ;
51+ }
Original file line number Diff line number Diff line change @@ -40,5 +40,6 @@ tracing = "0.1"
4040
4141[features ]
4242# tidy-alphabetical-start
43+ rustc_randomized_layouts = []
4344rustc_use_parallel_compiler = [" dep:rustc-rayon-core" ]
4445# tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -337,6 +337,7 @@ macro_rules! define_callbacks {
337337 // Ensure that values grow no larger than 64 bytes by accident.
338338 // Increase this limit if necessary, but do try to keep the size low if possible
339339 #[ cfg( target_pointer_width = "64" ) ]
340+ #[ cfg( not( feature = "rustc_randomized_layouts" ) ) ]
340341 const _: ( ) = {
341342 if mem:: size_of:: <Value <' static >>( ) > 64 {
342343 panic!( "{}" , concat!(
Original file line number Diff line number Diff line change @@ -678,6 +678,9 @@ impl Build {
678678 if self . config . rustc_parallel {
679679 features. push ( "rustc_use_parallel_compiler" ) ;
680680 }
681+ if self . config . rust_randomize_layout {
682+ features. push ( "rustc_randomized_layouts" ) ;
683+ }
681684
682685 // If debug logging is on, then we want the default for tracing:
683686 // https://github.com/tokio-rs/tracing/blob/3dd5c03d907afdf2c39444a29931833335171554/tracing/src/level_filters.rs#L26
You can’t perform that action at this time.
0 commit comments