@@ -358,37 +358,37 @@ impl Config {
358358 . collect ( ) ;
359359 }
360360 "CFG_MUSL_ROOT" if value. len ( ) > 0 => {
361- self . musl_root = Some ( PathBuf :: from ( value) ) ;
361+ self . musl_root = Some ( parse_configure_path ( value) ) ;
362362 }
363363 "CFG_MUSL_ROOT_X86_64" if value. len ( ) > 0 => {
364364 let target = "x86_64-unknown-linux-musl" . to_string ( ) ;
365365 let target = self . target_config . entry ( target)
366366 . or_insert ( Target :: default ( ) ) ;
367- target. musl_root = Some ( PathBuf :: from ( value) ) ;
367+ target. musl_root = Some ( parse_configure_path ( value) ) ;
368368 }
369369 "CFG_MUSL_ROOT_I686" if value. len ( ) > 0 => {
370370 let target = "i686-unknown-linux-musl" . to_string ( ) ;
371371 let target = self . target_config . entry ( target)
372372 . or_insert ( Target :: default ( ) ) ;
373- target. musl_root = Some ( PathBuf :: from ( value) ) ;
373+ target. musl_root = Some ( parse_configure_path ( value) ) ;
374374 }
375375 "CFG_MUSL_ROOT_ARM" if value. len ( ) > 0 => {
376376 let target = "arm-unknown-linux-musleabi" . to_string ( ) ;
377377 let target = self . target_config . entry ( target)
378378 . or_insert ( Target :: default ( ) ) ;
379- target. musl_root = Some ( PathBuf :: from ( value) ) ;
379+ target. musl_root = Some ( parse_configure_path ( value) ) ;
380380 }
381381 "CFG_MUSL_ROOT_ARMHF" if value. len ( ) > 0 => {
382382 let target = "arm-unknown-linux-musleabihf" . to_string ( ) ;
383383 let target = self . target_config . entry ( target)
384384 . or_insert ( Target :: default ( ) ) ;
385- target. musl_root = Some ( PathBuf :: from ( value) ) ;
385+ target. musl_root = Some ( parse_configure_path ( value) ) ;
386386 }
387387 "CFG_MUSL_ROOT_ARMV7" if value. len ( ) > 0 => {
388388 let target = "armv7-unknown-linux-musleabihf" . to_string ( ) ;
389389 let target = self . target_config . entry ( target)
390390 . or_insert ( Target :: default ( ) ) ;
391- target. musl_root = Some ( PathBuf :: from ( value) ) ;
391+ target. musl_root = Some ( parse_configure_path ( value) ) ;
392392 }
393393 "CFG_DEFAULT_AR" if value. len ( ) > 0 => {
394394 self . rustc_default_ar = Some ( value. to_string ( ) ) ;
@@ -397,7 +397,7 @@ impl Config {
397397 self . rustc_default_linker = Some ( value. to_string ( ) ) ;
398398 }
399399 "CFG_GDB" if value. len ( ) > 0 => {
400- self . gdb = Some ( PathBuf :: from ( value) ) ;
400+ self . gdb = Some ( parse_configure_path ( value) ) ;
401401 }
402402 "CFG_RELEASE_CHANNEL" => {
403403 self . channel = value. to_string ( ) ;
@@ -417,40 +417,40 @@ impl Config {
417417 "CFG_LLVM_ROOT" if value. len ( ) > 0 => {
418418 let target = self . target_config . entry ( self . build . clone ( ) )
419419 . or_insert ( Target :: default ( ) ) ;
420- let root = PathBuf :: from ( value) ;
420+ let root = parse_configure_path ( value) ;
421421 target. llvm_config = Some ( push_exe_path ( root, & [ "bin" , "llvm-config" ] ) ) ;
422422 }
423423 "CFG_JEMALLOC_ROOT" if value. len ( ) > 0 => {
424424 let target = self . target_config . entry ( self . build . clone ( ) )
425425 . or_insert ( Target :: default ( ) ) ;
426- target. jemalloc = Some ( PathBuf :: from ( value) ) ;
426+ target. jemalloc = Some ( parse_configure_path ( value) ) ;
427427 }
428428 "CFG_ARM_LINUX_ANDROIDEABI_NDK" if value. len ( ) > 0 => {
429429 let target = "arm-linux-androideabi" . to_string ( ) ;
430430 let target = self . target_config . entry ( target)
431431 . or_insert ( Target :: default ( ) ) ;
432- target. ndk = Some ( PathBuf :: from ( value) ) ;
432+ target. ndk = Some ( parse_configure_path ( value) ) ;
433433 }
434434 "CFG_ARMV7_LINUX_ANDROIDEABI_NDK" if value. len ( ) > 0 => {
435435 let target = "armv7-linux-androideabi" . to_string ( ) ;
436436 let target = self . target_config . entry ( target)
437437 . or_insert ( Target :: default ( ) ) ;
438- target. ndk = Some ( PathBuf :: from ( value) ) ;
438+ target. ndk = Some ( parse_configure_path ( value) ) ;
439439 }
440440 "CFG_I686_LINUX_ANDROID_NDK" if value. len ( ) > 0 => {
441441 let target = "i686-linux-android" . to_string ( ) ;
442442 let target = self . target_config . entry ( target)
443443 . or_insert ( Target :: default ( ) ) ;
444- target. ndk = Some ( PathBuf :: from ( value) ) ;
444+ target. ndk = Some ( parse_configure_path ( value) ) ;
445445 }
446446 "CFG_AARCH64_LINUX_ANDROID_NDK" if value. len ( ) > 0 => {
447447 let target = "aarch64-linux-android" . to_string ( ) ;
448448 let target = self . target_config . entry ( target)
449449 . or_insert ( Target :: default ( ) ) ;
450- target. ndk = Some ( PathBuf :: from ( value) ) ;
450+ target. ndk = Some ( parse_configure_path ( value) ) ;
451451 }
452452 "CFG_LOCAL_RUST_ROOT" if value. len ( ) > 0 => {
453- let path = PathBuf :: from ( value) ;
453+ let path = parse_configure_path ( value) ;
454454 self . rustc = Some ( push_exe_path ( path. clone ( ) , & [ "bin" , "rustc" ] ) ) ;
455455 self . cargo = Some ( push_exe_path ( path, & [ "bin" , "cargo" ] ) ) ;
456456 }
@@ -460,6 +460,29 @@ impl Config {
460460 }
461461}
462462
463+ #[ cfg( not( windows) ) ]
464+ fn parse_configure_path ( path : & str ) -> PathBuf {
465+ path. into ( )
466+ }
467+
468+ #[ cfg( windows) ]
469+ fn parse_configure_path ( path : & str ) -> PathBuf {
470+ // on windows, configure produces unix style paths e.g. /c/some/path but we
471+ // only want real windows paths
472+
473+ use build_helper;
474+
475+ // '/' is invalid in windows paths, so we can detect unix paths by the presence of it
476+ if !path. contains ( '/' ) {
477+ return path. into ( ) ;
478+ }
479+
480+ let win_path = build_helper:: output ( Command :: new ( "cygpath" ) . arg ( "-w" ) . arg ( path) ) ;
481+ let win_path = win_path. trim ( ) ;
482+
483+ win_path. into ( )
484+ }
485+
463486fn set < T > ( field : & mut T , val : Option < T > ) {
464487 if let Some ( v) = val {
465488 * field = v;
0 commit comments