@@ -91,7 +91,7 @@ pub struct Target {
9191#[ derive( Clone , Debug ) ]
9292pub struct TargetOptions {
9393 /// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
94- pub data_layout : String ,
94+ pub data_layout : Option < String > ,
9595 /// Linker to invoke. Defaults to "cc".
9696 pub linker : String ,
9797 /// Archive utility to use when managing archives. Defaults to "ar".
@@ -186,7 +186,7 @@ impl Default for TargetOptions {
186186 /// incomplete, and if used for compilation, will certainly not work.
187187 fn default ( ) -> TargetOptions {
188188 TargetOptions {
189- data_layout : String :: new ( ) ,
189+ data_layout : None ,
190190 linker : option_env ! ( "CFG_DEFAULT_LINKER" ) . unwrap_or ( "cc" ) . to_string ( ) ,
191191 ar : option_env ! ( "CFG_DEFAULT_AR" ) . unwrap_or ( "ar" ) . to_string ( ) ,
192192 pre_link_args : Vec :: new ( ) ,
@@ -287,6 +287,14 @@ impl Target {
287287 )
288288 ) ;
289289 } ) ;
290+ ( $key_name: ident, optional) => ( {
291+ let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
292+ if let Some ( o) = obj. find( & name[ ..] ) {
293+ base. options. $key_name = o
294+ . as_string( )
295+ . map( |s| s. to_string( ) ) ;
296+ }
297+ } ) ;
290298 }
291299
292300 key ! ( cpu) ;
@@ -300,7 +308,7 @@ impl Target {
300308 key ! ( staticlib_prefix) ;
301309 key ! ( staticlib_suffix) ;
302310 key ! ( features) ;
303- key ! ( data_layout) ;
311+ key ! ( data_layout, optional ) ;
304312 key ! ( dynamic_linking, bool ) ;
305313 key ! ( executables, bool ) ;
306314 key ! ( disable_redzone, bool ) ;
0 commit comments