@@ -196,11 +196,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
196
196
}
197
197
198
198
let mut with_cfg = process. clone ( ) ;
199
+ with_cfg. arg ( "--print=sysroot" ) ;
199
200
with_cfg. arg ( "--print=cfg" ) ;
200
201
201
- let mut has_cfg = true ;
202
+ let mut has_cfg_and_sysroot = true ;
202
203
let output = with_cfg. exec_with_output ( ) . or_else ( |_| {
203
- has_cfg = false ;
204
+ has_cfg_and_sysroot = false ;
204
205
process. exec_with_output ( )
205
206
} ) . chain_error ( || {
206
207
human ( format ! ( "failed to run `rustc` to learn about \
@@ -237,14 +238,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
237
238
map. insert ( crate_type. to_string ( ) , Some ( ( prefix. to_string ( ) , suffix. to_string ( ) ) ) ) ;
238
239
}
239
240
240
- let cfg = if has_cfg {
241
- Some ( try!( lines. map ( Cfg :: from_str) . collect ( ) ) )
242
- } else {
243
- None
244
- } ;
245
-
246
- if let Some ( ref sysroot) = self . config . rustc ( ) ?. sysroot {
247
- let mut rustlib = sysroot. clone ( ) ;
241
+ if has_cfg_and_sysroot {
242
+ let line = match lines. next ( ) {
243
+ Some ( line) => line,
244
+ None => bail ! ( "output of --print=sysroot missing when learning about \
245
+ target-specific information from rustc") ,
246
+ } ;
247
+ let mut rustlib = PathBuf :: from ( line) ;
248
248
if kind == Kind :: Host {
249
249
if cfg ! ( windows) {
250
250
rustlib. push ( "bin" ) ;
@@ -259,6 +259,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
259
259
rustlib. push ( "lib" ) ;
260
260
self . compilation . target_dylib_path = Some ( rustlib) ;
261
261
}
262
+ }
263
+
264
+ let cfg = if has_cfg_and_sysroot {
265
+ Some ( try!( lines. map ( Cfg :: from_str) . collect ( ) ) )
266
+ } else {
267
+ None
262
268
} ;
263
269
264
270
let info = match kind {
0 commit comments