Skip to content

Commit 1de29ac

Browse files
authored
Rollup merge of #110521 - jyn514:test-lint-docs, r=albertlarsan68
Fix `x test lint-docs linkchecker` when download-rustc is enabled Bootstrap was setting LD_LIBRARY_PATH for bootstrap tools in `tool_cmd`, and rustc inherited that environment. That broke when download-rustc was enabled; see the new comment for details. Fixes #110354
2 parents 6fdc121 + abf9cbc commit 1de29ac

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: src/tools/lint-docs/src/groups.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ impl<'a> LintExtractor<'a> {
3939
fn collect_groups(&self) -> Result<LintGroups, Box<dyn Error>> {
4040
let mut result = BTreeMap::new();
4141
let mut cmd = Command::new(self.rustc_path);
42+
cmd.env_remove("LD_LIBRARY_PATH");
4243
cmd.arg("-Whelp");
4344
let output = cmd.output().map_err(|e| format!("failed to run command {:?}\n{}", cmd, e))?;
4445
if !output.status.success() {
4546
return Err(format!(
46-
"failed to collect lint info: {:?}\n--- stderr\n{}--- stdout\n{}\n",
47+
"failed to collect lint info: failed to run {cmd:?}: {:?}\n--- stderr\n{}--- stdout\n{}\n",
4748
output.status,
4849
std::str::from_utf8(&output.stderr).unwrap(),
4950
std::str::from_utf8(&output.stdout).unwrap(),

Diff for: src/tools/lint-docs/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ impl<'a> LintExtractor<'a> {
403403
fs::write(&tempfile, source)
404404
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
405405
let mut cmd = Command::new(self.rustc_path);
406+
// NOTE: bootstrap sets `LD_LIBRARY_PATH` for building lint-docs itself.
407+
// Unfortunately, lint-docs is a bootstrap tool while rustc is built from source,
408+
// and sometimes the paths conflict. In particular, when using `download-rustc`,
409+
// the LLVM versions can differ between `ci-llvm` and `ci-rustc-sysroot`.
410+
// Unset LD_LIBRARY_PATH here so it doesn't interfere with running the compiler.
411+
cmd.env_remove("LD_LIBRARY_PATH");
406412
if options.contains(&"edition2015") {
407413
cmd.arg("--edition=2015");
408414
} else {
@@ -415,6 +421,9 @@ impl<'a> LintExtractor<'a> {
415421
}
416422
cmd.arg("lint_example.rs");
417423
cmd.current_dir(tempdir.path());
424+
if self.verbose {
425+
eprintln!("running: {cmd:?}");
426+
}
418427
let output = cmd.output().map_err(|e| format!("failed to run command {:?}\n{}", cmd, e))?;
419428
let stderr = std::str::from_utf8(&output.stderr).unwrap();
420429
let msgs = stderr

0 commit comments

Comments
 (0)