Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generating rustc docs with non-default lib directory. #76717

Merged
merged 2 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,15 +710,15 @@ impl<'a> Builder<'a> {

/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
/// library lookup path.
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Cargo) {
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
// Windows doesn't need dylib path munging because the dlls for the
// compiler live next to the compiler and the system will find them
// automatically.
if cfg!(windows) {
return;
}

add_dylib_path(vec![self.rustc_libdir(compiler)], &mut cmd.command);
add_dylib_path(vec![self.rustc_libdir(compiler)], cmd);
}

/// Gets a path to the compiler specified.
Expand Down Expand Up @@ -1515,6 +1515,10 @@ impl Cargo {
self.command.env(key.as_ref(), value.as_ref());
self
}

pub fn add_rustc_lib_path(&mut self, builder: &Builder<'_>, compiler: Compiler) {
builder.add_rustc_lib_path(compiler, &mut self.command);
}
}

impl From<Cargo> for Command {
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ impl Step for RustcBook {
if builder.config.verbose() {
cmd.arg("--verbose");
}
// If the lib directories are in an unusual location (changed in
// config.toml), then this needs to explicitly update the dylib search
// path.
builder.add_rustc_lib_path(self.compiler, &mut cmd);
builder.run(&mut cmd);
// Run rustbook/mdbook to generate the HTML pages.
builder.ensure(RustbookSrc {
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Step for Rls {
&[],
);

builder.add_rustc_lib_path(compiler, &mut cargo);
cargo.add_rustc_lib_path(builder, compiler);
cargo.arg("--").args(builder.config.cmd.test_args());

if try_run(builder, &mut cargo.into()) {
Expand Down Expand Up @@ -328,7 +328,7 @@ impl Step for Rustfmt {
t!(fs::create_dir_all(&dir));
cargo.env("RUSTFMT_TEST_DIR", dir);

builder.add_rustc_lib_path(compiler, &mut cargo);
cargo.add_rustc_lib_path(builder, compiler);

if try_run(builder, &mut cargo.into()) {
builder.save_toolstate("rustfmt", ToolState::TestPass);
Expand Down Expand Up @@ -449,7 +449,7 @@ impl Step for Miri {

cargo.arg("--").args(builder.config.cmd.test_args());

builder.add_rustc_lib_path(compiler, &mut cargo);
cargo.add_rustc_lib_path(builder, compiler);

if !try_run(builder, &mut cargo.into()) {
return;
Expand Down Expand Up @@ -554,7 +554,7 @@ impl Step for Clippy {

cargo.arg("--").args(builder.config.cmd.test_args());

builder.add_rustc_lib_path(compiler, &mut cargo);
cargo.add_rustc_lib_path(builder, compiler);

builder.run(&mut cargo.into());
}
Expand Down
5 changes: 4 additions & 1 deletion src/tools/lint-docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,12 @@ fn generate_lint_output(
None => {
let rendered: Vec<&str> =
msgs.iter().filter_map(|msg| msg["rendered"].as_str()).collect();
let non_json: Vec<&str> =
stderr.lines().filter(|line| !line.starts_with('{')).collect();
Err(format!(
"did not find lint `{}` in output of example, got:\n{}",
"did not find lint `{}` in output of example, got:\n{}\n{}",
name,
non_json.join("\n"),
rendered.join("\n")
)
.into())
Expand Down