@@ -42,7 +42,9 @@ use std::path::{Path, PathBuf};
4242use  std:: str:: FromStr ; 
4343use  std:: { fmt,  io} ; 
4444
45- use  rustc_abi:: { Endian ,  ExternAbi ,  Integer ,  Size ,  TargetDataLayout ,  TargetDataLayoutErrors } ; 
45+ use  rustc_abi:: { 
46+     Align ,  Endian ,  ExternAbi ,  Integer ,  Size ,  TargetDataLayout ,  TargetDataLayoutErrors , 
47+ } ; 
4648use  rustc_data_structures:: fx:: { FxHashSet ,  FxIndexSet } ; 
4749use  rustc_fs_util:: try_canonicalize; 
4850use  rustc_macros:: { Decodable ,  Encodable ,  HashStable_Generic } ; 
@@ -3599,6 +3601,25 @@ impl Target {
35993601            _ => return  None , 
36003602        } ) 
36013603    } 
3604+ 
3605+     /// Returns whether this target is known to have unreliable alignment: 
3606+      /// native C code for the target fails to align some data to the degree 
3607+      /// required by the C standard. We can't *really* do anything about that 
3608+      /// since unsafe Rust code may assume alignment any time, but we can at least 
3609+      /// inhibit some optimizations, and we suppress the alignment checks that 
3610+      /// would detect this unsoundness. 
3611+      /// 
3612+      /// Every target that returns less than `Align::MAX` here is still has a soundness bug. 
3613+      pub  fn  max_reliable_alignment ( & self )  -> Align  { 
3614+         // FIXME(#112480) MSVC on x86-32 is unsound and fails to properly align many types with 
3615+         // more-than-4-byte-alignment on the stack. This makes alignments larger than 4 generally 
3616+         // unreliable on 32bit Windows. 
3617+         if  self . is_like_windows  && self . arch  == "x86"  { 
3618+             Align :: from_bytes ( 4 ) . unwrap ( ) 
3619+         }  else  { 
3620+             Align :: MAX 
3621+         } 
3622+     } 
36023623} 
36033624
36043625/// Either a target tuple string or a path to a JSON file. 
0 commit comments