@@ -2077,6 +2077,42 @@ enum TargetKind {
20772077 Builtin ,
20782078}
20792079
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+
20802116/// Everything `rustc` knows about how to compile for a specific target.
20812117///
20822118/// Every field here must be specified, and has no default value.
@@ -2370,6 +2406,8 @@ pub struct TargetOptions {
23702406 pub is_like_wasm : bool ,
23712407 /// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
23722408 pub is_like_android : bool ,
2409+ /// Default used is BinaryFormat::Elf
2410+ pub binary_format : BinaryFormat ,
23732411 /// Default supported version of DWARF on this platform.
23742412 /// Useful because some platforms (osx, bsd) only want up to DWARF2.
23752413 pub default_dwarf_version : u32 ,
@@ -2745,6 +2783,7 @@ impl Default for TargetOptions {
27452783 is_like_msvc : false ,
27462784 is_like_wasm : false ,
27472785 is_like_android : false ,
2786+ binary_format : BinaryFormat :: Elf ,
27482787 default_dwarf_version : 4 ,
27492788 allows_weak_linkage : true ,
27502789 has_rpath : false ,
0 commit comments