File tree 8 files changed +24
-0
lines changed 8 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -3569,6 +3569,7 @@ dependencies = [
3569
3569
" rustc_hir_pretty" ,
3570
3570
" rustc_hir_typeck" ,
3571
3571
" rustc_incremental" ,
3572
+ " rustc_index" ,
3572
3573
" rustc_infer" ,
3573
3574
" rustc_interface" ,
3574
3575
" rustc_lint" ,
Original file line number Diff line number Diff line change @@ -30,5 +30,6 @@ features = ['unprefixed_malloc_on_supported_platforms']
30
30
jemalloc = [' dep:jemalloc-sys' ]
31
31
llvm = [' rustc_driver_impl/llvm' ]
32
32
max_level_info = [' rustc_driver_impl/max_level_info' ]
33
+ rustc_randomized_layouts = [' rustc_driver_impl/rustc_randomized_layouts' ]
33
34
rustc_use_parallel_compiler = [' rustc_driver_impl/rustc_use_parallel_compiler' ]
34
35
# tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ rustc_hir_analysis = { path = "../rustc_hir_analysis" }
23
23
rustc_hir_pretty = { path = " ../rustc_hir_pretty" }
24
24
rustc_hir_typeck = { path = " ../rustc_hir_typeck" }
25
25
rustc_incremental = { path = " ../rustc_incremental" }
26
+ rustc_index = { path = " ../rustc_index" }
26
27
rustc_infer = { path = " ../rustc_infer" }
27
28
rustc_interface = { path = " ../rustc_interface" }
28
29
rustc_lint = { path = " ../rustc_lint" }
@@ -72,6 +73,10 @@ ctrlc = "3.4.4"
72
73
# tidy-alphabetical-start
73
74
llvm = [' rustc_interface/llvm' ]
74
75
max_level_info = [' rustc_log/max_level_info' ]
76
+ rustc_randomized_layouts = [
77
+ ' rustc_index/rustc_randomized_layouts' ,
78
+ ' rustc_middle/rustc_randomized_layouts'
79
+ ]
75
80
rustc_use_parallel_compiler = [
76
81
' rustc_data_structures/rustc_use_parallel_compiler' ,
77
82
' rustc_interface/rustc_use_parallel_compiler' ,
Original file line number Diff line number Diff line change @@ -20,4 +20,5 @@ nightly = [
20
20
" dep:rustc_macros" ,
21
21
" rustc_index_macros/nightly" ,
22
22
]
23
+ rustc_randomized_layouts = []
23
24
# tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -33,8 +33,19 @@ pub use vec::IndexVec;
33
33
///
34
34
/// </div>
35
35
#[ macro_export]
36
+ #[ cfg( not( feature = "rustc_randomized_layouts" ) ) ]
36
37
macro_rules! static_assert_size {
37
38
( $ty: ty, $size: expr) => {
38
39
const _: [ ( ) ; $size] = [ ( ) ; :: std:: mem:: size_of:: <$ty>( ) ] ;
39
40
} ;
40
41
}
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"
40
40
41
41
[features ]
42
42
# tidy-alphabetical-start
43
+ rustc_randomized_layouts = []
43
44
rustc_use_parallel_compiler = [" dep:rustc-rayon-core" ]
44
45
# tidy-alphabetical-end
Original file line number Diff line number Diff line change @@ -337,6 +337,7 @@ macro_rules! define_callbacks {
337
337
// Ensure that values grow no larger than 64 bytes by accident.
338
338
// Increase this limit if necessary, but do try to keep the size low if possible
339
339
#[ cfg( target_pointer_width = "64" ) ]
340
+ #[ cfg( not( feature = "rustc_randomized_layouts" ) ) ]
340
341
const _: ( ) = {
341
342
if mem:: size_of:: <Value <' static >>( ) > 64 {
342
343
panic!( "{}" , concat!(
Original file line number Diff line number Diff line change @@ -678,6 +678,9 @@ impl Build {
678
678
if self . config . rustc_parallel {
679
679
features. push ( "rustc_use_parallel_compiler" ) ;
680
680
}
681
+ if self . config . rust_randomize_layout {
682
+ features. push ( "rustc_randomized_layouts" ) ;
683
+ }
681
684
682
685
// If debug logging is on, then we want the default for tracing:
683
686
// 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