@@ -2066,6 +2066,7 @@ impl Step for Crate {
20662066 }
20672067}
20682068
2069+ /// Rustdoc is special in various ways, which is why this step is different from `Crate`.
20692070#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
20702071pub struct CrateRustdoc {
20712072 host : TargetSelection ,
@@ -2093,11 +2094,15 @@ impl Step for CrateRustdoc {
20932094 let test_kind = self . test_kind ;
20942095 let target = self . host ;
20952096
2096- // Use the previous stage compiler to reuse the artifacts that are
2097- // created when running compiletest for src/test/rustdoc. If this used
2098- // `compiler`, then it would cause rustdoc to be built *again*, which
2099- // isn't really necessary.
2100- let compiler = builder. compiler_for ( builder. top_stage , target, target) ;
2097+ let compiler = if builder. config . download_rustc {
2098+ builder. compiler ( builder. top_stage , target)
2099+ } else {
2100+ // Use the previous stage compiler to reuse the artifacts that are
2101+ // created when running compiletest for src/test/rustdoc. If this used
2102+ // `compiler`, then it would cause rustdoc to be built *again*, which
2103+ // isn't really necessary.
2104+ builder. compiler_for ( builder. top_stage , target, target)
2105+ } ;
21012106 builder. ensure ( compile:: Rustc { compiler, target } ) ;
21022107
21032108 let mut cargo = tool:: prepare_tool_cargo (
@@ -2137,6 +2142,8 @@ impl Step for CrateRustdoc {
21372142 // sets up the dylib path for the *host* (stage1/lib), which is the
21382143 // wrong directory.
21392144 //
2145+ // Recall that we special-cased `compiler_for(top_stage)` above, so we always use stage1.
2146+ //
21402147 // It should be considered to just stop running doctests on
21412148 // librustdoc. There is only one test, and it doesn't look too
21422149 // important. There might be other ways to avoid this, but it seems
@@ -2145,8 +2152,15 @@ impl Step for CrateRustdoc {
21452152 // See also https://github.com/rust-lang/rust/issues/13983 where the
21462153 // host vs target dylibs for rustdoc are consistently tricky to deal
21472154 // with.
2155+ //
2156+ // Note that this set the host libdir for `download_rustc`, which uses a normal rust distribution.
2157+ let libdir = if builder. config . download_rustc {
2158+ builder. rustc_libdir ( compiler)
2159+ } else {
2160+ builder. sysroot_libdir ( compiler, target) . to_path_buf ( )
2161+ } ;
21482162 let mut dylib_path = dylib_path ( ) ;
2149- dylib_path. insert ( 0 , PathBuf :: from ( & * builder . sysroot_libdir ( compiler , target ) ) ) ;
2163+ dylib_path. insert ( 0 , PathBuf :: from ( & * libdir ) ) ;
21502164 cargo. env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
21512165
21522166 if !builder. config . verbose_tests {
0 commit comments