mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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 https://github.com/rust-lang/rust/issues/110354
This commit is contained in:
commit
1de29ac2bd
@ -39,11 +39,12 @@ impl<'a> LintExtractor<'a> {
|
||||
fn collect_groups(&self) -> Result<LintGroups, Box<dyn Error>> {
|
||||
let mut result = BTreeMap::new();
|
||||
let mut cmd = Command::new(self.rustc_path);
|
||||
cmd.env_remove("LD_LIBRARY_PATH");
|
||||
cmd.arg("-Whelp");
|
||||
let output = cmd.output().map_err(|e| format!("failed to run command {:?}\n{}", cmd, e))?;
|
||||
if !output.status.success() {
|
||||
return Err(format!(
|
||||
"failed to collect lint info: {:?}\n--- stderr\n{}--- stdout\n{}\n",
|
||||
"failed to collect lint info: failed to run {cmd:?}: {:?}\n--- stderr\n{}--- stdout\n{}\n",
|
||||
output.status,
|
||||
std::str::from_utf8(&output.stderr).unwrap(),
|
||||
std::str::from_utf8(&output.stdout).unwrap(),
|
||||
|
@ -403,6 +403,12 @@ impl<'a> LintExtractor<'a> {
|
||||
fs::write(&tempfile, source)
|
||||
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
|
||||
let mut cmd = Command::new(self.rustc_path);
|
||||
// NOTE: bootstrap sets `LD_LIBRARY_PATH` for building lint-docs itself.
|
||||
// Unfortunately, lint-docs is a bootstrap tool while rustc is built from source,
|
||||
// and sometimes the paths conflict. In particular, when using `download-rustc`,
|
||||
// the LLVM versions can differ between `ci-llvm` and `ci-rustc-sysroot`.
|
||||
// Unset LD_LIBRARY_PATH here so it doesn't interfere with running the compiler.
|
||||
cmd.env_remove("LD_LIBRARY_PATH");
|
||||
if options.contains(&"edition2015") {
|
||||
cmd.arg("--edition=2015");
|
||||
} else {
|
||||
@ -415,6 +421,9 @@ impl<'a> LintExtractor<'a> {
|
||||
}
|
||||
cmd.arg("lint_example.rs");
|
||||
cmd.current_dir(tempdir.path());
|
||||
if self.verbose {
|
||||
eprintln!("running: {cmd:?}");
|
||||
}
|
||||
let output = cmd.output().map_err(|e| format!("failed to run command {:?}\n{}", cmd, e))?;
|
||||
let stderr = std::str::from_utf8(&output.stderr).unwrap();
|
||||
let msgs = stderr
|
||||
|
Loading…
Reference in New Issue
Block a user