@@ -2076,6 +2076,42 @@ enum TargetKind {
2076
2076
Builtin ,
2077
2077
}
2078
2078
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
+
2079
2115
/// Everything `rustc` knows about how to compile for a specific target.
2080
2116
///
2081
2117
/// Every field here must be specified, and has no default value.
@@ -2369,6 +2405,8 @@ pub struct TargetOptions {
2369
2405
pub is_like_wasm : bool ,
2370
2406
/// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
2371
2407
pub is_like_android : bool ,
2408
+ /// Default used is BinaryFormat::Elf
2409
+ pub binary_format : BinaryFormat ,
2372
2410
/// Default supported version of DWARF on this platform.
2373
2411
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
2374
2412
pub default_dwarf_version : u32 ,
@@ -2744,6 +2782,7 @@ impl Default for TargetOptions {
2744
2782
is_like_msvc : false ,
2745
2783
is_like_wasm : false ,
2746
2784
is_like_android : false ,
2785
+ binary_format : BinaryFormat :: Elf ,
2747
2786
default_dwarf_version : 4 ,
2748
2787
allows_weak_linkage : true ,
2749
2788
has_rpath : false ,
0 commit comments