@@ -2077,6 +2077,42 @@ enum TargetKind {
2077
2077
Builtin ,
2078
2078
}
2079
2079
2080
+ #[ derive( PartialEq , Clone , Debug ) ]
2081
+ pub enum BinaryFormat {
2082
+ Coff ,
2083
+ Elf ,
2084
+ MachO ,
2085
+ Wasm ,
2086
+ Xcoff ,
2087
+ }
2088
+
2089
+ impl FromStr for BinaryFormat {
2090
+ type Err = ( ) ;
2091
+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
2092
+ match s {
2093
+ "Coff" => Ok ( Self :: Coff ) ,
2094
+ "Elf" => Ok ( Self :: Elf ) ,
2095
+ "MachO" => Ok ( Self :: MachO ) ,
2096
+ "Wasm" => Ok ( Self :: Wasm ) ,
2097
+ "Xcoff" => Ok ( Self :: Xcoff ) ,
2098
+ _ => Err ( ( ) ) ,
2099
+ }
2100
+ }
2101
+ }
2102
+
2103
+ impl ToJson for BinaryFormat {
2104
+ fn to_json ( & self ) -> Json {
2105
+ match self {
2106
+ Self :: Coff => "Coff" ,
2107
+ Self :: Elf => "Elf" ,
2108
+ Self :: MachO => "MachO" ,
2109
+ Self :: Wasm => "Wasm" ,
2110
+ Self :: Xcoff => "Xcoff" ,
2111
+ }
2112
+ . to_json ( )
2113
+ }
2114
+ }
2115
+
2080
2116
/// Everything `rustc` knows about how to compile for a specific target.
2081
2117
///
2082
2118
/// Every field here must be specified, and has no default value.
@@ -2370,6 +2406,8 @@ pub struct TargetOptions {
2370
2406
pub is_like_wasm : bool ,
2371
2407
/// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
2372
2408
pub is_like_android : bool ,
2409
+ /// Default used is BinaryFormat::Elf
2410
+ pub binary_format : BinaryFormat ,
2373
2411
/// Default supported version of DWARF on this platform.
2374
2412
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
2375
2413
pub default_dwarf_version : u32 ,
@@ -2745,6 +2783,7 @@ impl Default for TargetOptions {
2745
2783
is_like_msvc : false ,
2746
2784
is_like_wasm : false ,
2747
2785
is_like_android : false ,
2786
+ binary_format : BinaryFormat :: Elf ,
2748
2787
default_dwarf_version : 4 ,
2749
2788
allows_weak_linkage : true ,
2750
2789
has_rpath : false ,
0 commit comments