Skip to content

Commit de4c897

Browse files
committed
bootstrap: Set the dylib path when building books with rustdoc
The library path is needed when the toolchain has been configured with `[rust] rpath = false`. Otherwise, building the reference book will get an error when it tries to run rustdoc, like: rustdoc: error while loading shared libraries: librustc_driver-2ec457c3b8826b72.so
1 parent 28e8f01 commit de4c897

File tree

1 file changed

+11
-9
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+11
-9
lines changed

Diff for: src/bootstrap/src/core/build_steps/doc.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ macro_rules! book {
6363
src: builder.src.join($path),
6464
parent: Some(self),
6565
languages: $lang.into(),
66-
rustdoc: None,
66+
rustdoc_compiler: None,
6767
})
6868
}
6969
}
@@ -113,7 +113,7 @@ impl Step for UnstableBook {
113113
src: builder.md_doc_out(self.target).join("unstable-book"),
114114
parent: Some(self),
115115
languages: vec![],
116-
rustdoc: None,
116+
rustdoc_compiler: None,
117117
})
118118
}
119119
}
@@ -125,7 +125,7 @@ struct RustbookSrc<P: Step> {
125125
src: PathBuf,
126126
parent: Option<P>,
127127
languages: Vec<&'static str>,
128-
rustdoc: Option<PathBuf>,
128+
rustdoc_compiler: Option<Compiler>,
129129
}
130130

131131
impl<P: Step> Step for RustbookSrc<P> {
@@ -157,14 +157,17 @@ impl<P: Step> Step for RustbookSrc<P> {
157157
let _ = fs::remove_dir_all(&out);
158158

159159
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
160-
if let Some(mut rustdoc) = self.rustdoc {
160+
161+
if let Some(compiler) = self.rustdoc_compiler {
162+
let mut rustdoc = builder.rustdoc(compiler);
161163
rustdoc.pop();
162164
let old_path = env::var_os("PATH").unwrap_or_default();
163165
let new_path =
164166
env::join_paths(std::iter::once(rustdoc).chain(env::split_paths(&old_path)))
165167
.expect("could not add rustdoc to PATH");
166168

167169
rustbook_cmd.env("PATH", new_path);
170+
builder.add_rustc_lib_path(compiler, &mut rustbook_cmd);
168171
}
169172

170173
rustbook_cmd.arg("build").arg(&src).arg("-d").arg(&out).run(builder);
@@ -240,7 +243,7 @@ impl Step for TheBook {
240243
src: absolute_path.clone(),
241244
parent: Some(self),
242245
languages: vec![],
243-
rustdoc: None,
246+
rustdoc_compiler: None,
244247
});
245248

246249
// building older edition redirects
@@ -253,7 +256,7 @@ impl Step for TheBook {
253256
// treat the other editions as not having a parent.
254257
parent: Option::<Self>::None,
255258
languages: vec![],
256-
rustdoc: None,
259+
rustdoc_compiler: None,
257260
});
258261
}
259262

@@ -1229,7 +1232,7 @@ impl Step for RustcBook {
12291232
src: out_base,
12301233
parent: Some(self),
12311234
languages: vec![],
1232-
rustdoc: None,
1235+
rustdoc_compiler: None,
12331236
});
12341237
}
12351238
}
@@ -1263,16 +1266,15 @@ impl Step for Reference {
12631266
// This is needed for generating links to the standard library using
12641267
// the mdbook-spec plugin.
12651268
builder.ensure(compile::Std::new(self.compiler, builder.config.build));
1266-
let rustdoc = builder.rustdoc(self.compiler);
12671269

12681270
// Run rustbook/mdbook to generate the HTML pages.
12691271
builder.ensure(RustbookSrc {
12701272
target: self.target,
12711273
name: "reference".to_owned(),
12721274
src: builder.src.join("src/doc/reference"),
1275+
rustdoc_compiler: Some(self.compiler),
12731276
parent: Some(self),
12741277
languages: vec![],
1275-
rustdoc: Some(rustdoc),
12761278
});
12771279
}
12781280
}

0 commit comments

Comments
 (0)