@@ -2066,6 +2066,7 @@ impl Step for Crate {
2066
2066
}
2067
2067
}
2068
2068
2069
+ /// Rustdoc is special in various ways, which is why this step is different from `Crate`.
2069
2070
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
2070
2071
pub struct CrateRustdoc {
2071
2072
host : TargetSelection ,
@@ -2093,11 +2094,15 @@ impl Step for CrateRustdoc {
2093
2094
let test_kind = self . test_kind ;
2094
2095
let target = self . host ;
2095
2096
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
+ } ;
2101
2106
builder. ensure ( compile:: Rustc { compiler, target } ) ;
2102
2107
2103
2108
let mut cargo = tool:: prepare_tool_cargo (
@@ -2137,6 +2142,8 @@ impl Step for CrateRustdoc {
2137
2142
// sets up the dylib path for the *host* (stage1/lib), which is the
2138
2143
// wrong directory.
2139
2144
//
2145
+ // Recall that we special-cased `compiler_for(top_stage)` above, so we always use stage1.
2146
+ //
2140
2147
// It should be considered to just stop running doctests on
2141
2148
// librustdoc. There is only one test, and it doesn't look too
2142
2149
// important. There might be other ways to avoid this, but it seems
@@ -2145,8 +2152,15 @@ impl Step for CrateRustdoc {
2145
2152
// See also https://github.com/rust-lang/rust/issues/13983 where the
2146
2153
// host vs target dylibs for rustdoc are consistently tricky to deal
2147
2154
// 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
+ } ;
2148
2162
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 ) ) ;
2150
2164
cargo. env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
2151
2165
2152
2166
if !builder. config . verbose_tests {
0 commit comments