@@ -91,7 +91,7 @@ pub struct Target {
91
91
#[ derive( Clone , Debug ) ]
92
92
pub struct TargetOptions {
93
93
/// [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 > ,
95
95
/// Linker to invoke. Defaults to "cc".
96
96
pub linker : String ,
97
97
/// Archive utility to use when managing archives. Defaults to "ar".
@@ -186,7 +186,7 @@ impl Default for TargetOptions {
186
186
/// incomplete, and if used for compilation, will certainly not work.
187
187
fn default ( ) -> TargetOptions {
188
188
TargetOptions {
189
- data_layout : String :: new ( ) ,
189
+ data_layout : None ,
190
190
linker : option_env ! ( "CFG_DEFAULT_LINKER" ) . unwrap_or ( "cc" ) . to_string ( ) ,
191
191
ar : option_env ! ( "CFG_DEFAULT_AR" ) . unwrap_or ( "ar" ) . to_string ( ) ,
192
192
pre_link_args : Vec :: new ( ) ,
@@ -287,6 +287,14 @@ impl Target {
287
287
)
288
288
) ;
289
289
} ) ;
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
+ } ) ;
290
298
}
291
299
292
300
key ! ( cpu) ;
@@ -300,7 +308,7 @@ impl Target {
300
308
key ! ( staticlib_prefix) ;
301
309
key ! ( staticlib_suffix) ;
302
310
key ! ( features) ;
303
- key ! ( data_layout) ;
311
+ key ! ( data_layout, optional ) ;
304
312
key ! ( dynamic_linking, bool ) ;
305
313
key ! ( executables, bool ) ;
306
314
key ! ( disable_redzone, bool ) ;
0 commit comments