Added -Z layout_seed for allowing user-defined randomization seeds
This commit is contained in:
@@ -1640,7 +1640,14 @@ impl ReprOptions {
|
||||
|
||||
// Generate a deterministically-derived seed from the item's path hash
|
||||
// to allow for cross-crate compilation to actually work
|
||||
let field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
|
||||
let mut field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
|
||||
|
||||
// If the user defined a custom seed for layout randomization, xor the item's
|
||||
// path hash with the user defined seed, this will allowing determinism while
|
||||
// still allowing users to further randomize layout generation for e.g. fuzzing
|
||||
if let Some(user_seed) = tcx.sess.opts.debugging_opts.layout_seed {
|
||||
field_shuffle_seed ^= user_seed;
|
||||
}
|
||||
|
||||
for attr in tcx.get_attrs(did).iter() {
|
||||
for r in attr::find_repr_attrs(&tcx.sess, attr) {
|
||||
|
||||
Reference in New Issue
Block a user