@@ -2076,6 +2076,42 @@ enum TargetKind {
20762076 Builtin ,
20772077}
20782078
2079+ #[ derive( PartialEq , Clone , Debug ) ]
2080+ pub enum BinaryFormat {
2081+ Coff ,
2082+ Elf ,
2083+ MachO ,
2084+ Wasm ,
2085+ Xcoff ,
2086+ }
2087+
2088+ impl FromStr for BinaryFormat {
2089+ type Err = ( ) ;
2090+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
2091+ match s {
2092+ "Coff" => Ok ( Self :: Coff ) ,
2093+ "Elf" => Ok ( Self :: Elf ) ,
2094+ "MachO" => Ok ( Self :: MachO ) ,
2095+ "Wasm" => Ok ( Self :: Wasm ) ,
2096+ "Xcoff" => Ok ( Self :: Xcoff ) ,
2097+ _ => Err ( ( ) ) ,
2098+ }
2099+ }
2100+ }
2101+
2102+ impl ToJson for BinaryFormat {
2103+ fn to_json ( & self ) -> Json {
2104+ match self {
2105+ Self :: Coff => "Coff" ,
2106+ Self :: Elf => "Elf" ,
2107+ Self :: MachO => "MachO" ,
2108+ Self :: Wasm => "Wasm" ,
2109+ Self :: Xcoff => "Xcoff" ,
2110+ }
2111+ . to_json ( )
2112+ }
2113+ }
2114+
20792115/// Everything `rustc` knows about how to compile for a specific target.
20802116///
20812117/// Every field here must be specified, and has no default value.
@@ -2369,6 +2405,8 @@ pub struct TargetOptions {
23692405 pub is_like_wasm : bool ,
23702406 /// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
23712407 pub is_like_android : bool ,
2408+ /// Default used is BinaryFormat::Elf
2409+ pub binary_format : BinaryFormat ,
23722410 /// Default supported version of DWARF on this platform.
23732411 /// Useful because some platforms (osx, bsd) only want up to DWARF2.
23742412 pub default_dwarf_version : u32 ,
@@ -2744,6 +2782,7 @@ impl Default for TargetOptions {
27442782 is_like_msvc : false ,
27452783 is_like_wasm : false ,
27462784 is_like_android : false ,
2785+ binary_format : BinaryFormat :: Elf ,
27472786 default_dwarf_version : 4 ,
27482787 allows_weak_linkage : true ,
27492788 has_rpath : false ,
0 commit comments