Skip to content

Commit a8df4b1

Browse files
authored
Rollup merge of #107834 - zephaniahong:issue-107547-fix, r=albertlarsan68
create symlink for legacy rustfmt path Fixes #107547 . Main change is in the `download.rs` file. Created a symlink for the legacy rustfmt path to the new rustfmt path. Other file changes are simply as a result of porting over the symlink_file function from the Build struct to the config Struct
2 parents a3e152c + 41c6c5d commit a8df4b1

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/bootstrap/download.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
env,
33
ffi::{OsStr, OsString},
44
fs::{self, File},
5-
io::{BufRead, BufReader, ErrorKind},
5+
io::{self, BufRead, BufReader, ErrorKind},
66
path::{Path, PathBuf},
77
process::{Command, Stdio},
88
};
@@ -26,6 +26,14 @@ impl Config {
2626
self.verbose > 0
2727
}
2828

29+
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
30+
#[cfg(unix)]
31+
use std::os::unix::fs::symlink as symlink_file;
32+
#[cfg(windows)]
33+
use std::os::windows::fs::symlink_file;
34+
if !self.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
35+
}
36+
2937
pub(crate) fn create(&self, path: &Path, s: &str) {
3038
if self.dry_run() {
3139
return;
@@ -331,6 +339,12 @@ impl Config {
331339
let bin_root = self.out.join(host.triple).join("rustfmt");
332340
let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
333341
let rustfmt_stamp = bin_root.join(".rustfmt-stamp");
342+
343+
let legacy_rustfmt = self.initial_rustc.with_file_name(exe("rustfmt", host));
344+
if !legacy_rustfmt.exists() {
345+
t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt));
346+
}
347+
334348
if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) {
335349
return Some(rustfmt_path);
336350
}

src/bootstrap/lib.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use std::cell::{Cell, RefCell};
2020
use std::collections::{HashMap, HashSet};
2121
use std::env;
2222
use std::fs::{self, File};
23-
use std::io;
2423
use std::io::ErrorKind;
2524
use std::path::{Path, PathBuf};
2625
use std::process::{Command, Stdio};
@@ -1407,7 +1406,7 @@ impl Build {
14071406
src = t!(fs::canonicalize(src));
14081407
} else {
14091408
let link = t!(fs::read_link(src));
1410-
t!(self.symlink_file(link, dst));
1409+
t!(self.config.symlink_file(link, dst));
14111410
return;
14121411
}
14131412
}
@@ -1525,14 +1524,6 @@ impl Build {
15251524
iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter()
15261525
}
15271526

1528-
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
1529-
#[cfg(unix)]
1530-
use std::os::unix::fs::symlink as symlink_file;
1531-
#[cfg(windows)]
1532-
use std::os::windows::fs::symlink_file;
1533-
if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
1534-
}
1535-
15361527
/// Returns if config.ninja is enabled, and checks for ninja existence,
15371528
/// exiting with a nicer error message if not.
15381529
fn ninja(&self) -> bool {

src/bootstrap/native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl Step for Llvm {
516516

517517
let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
518518
if !lib_llvm.exists() {
519-
t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
519+
t!(builder.build.config.symlink_file("libLLVM.dylib", &lib_llvm));
520520
}
521521
}
522522

0 commit comments

Comments
 (0)