Skip to content

Revert #107834 #108302

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

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Revert "port over symlink_file function from Build to Config and crea…
…te symlink for legacy rustfmt path"

This reverts commit 41c6c5d.
  • Loading branch information
Kobzol committed Feb 21, 2023
commit a5d27316fe49feb36c332f16dd82da959de664fb
19 changes: 1 addition & 18 deletions src/bootstrap/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
env,
ffi::{OsStr, OsString},
fs::{self, File},
io::{self, BufRead, BufReader, ErrorKind},
io::{BufRead, BufReader, ErrorKind},
path::{Path, PathBuf},
process::{Command, Stdio},
};
Expand All @@ -26,14 +26,6 @@ impl Config {
self.verbose > 0
}

pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
#[cfg(unix)]
use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
if !self.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
}

pub(crate) fn create(&self, path: &Path, s: &str) {
if self.dry_run() {
return;
Expand Down Expand Up @@ -338,15 +330,6 @@ impl Config {
let bin_root = self.out.join(host.triple).join("rustfmt");
let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
let rustfmt_stamp = bin_root.join(".rustfmt-stamp");

#[cfg(not(windows))]
{
let legacy_rustfmt = self.initial_rustc.with_file_name(exe("rustfmt", host));
if !legacy_rustfmt.exists() {
t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt));
}
}

if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) {
return Some(rustfmt_path);
}
Expand Down
11 changes: 10 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::cell::{Cell, RefCell};
use std::collections::{HashMap, HashSet};
use std::env;
use std::fs::{self, File};
use std::io;
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
Expand Down Expand Up @@ -1406,7 +1407,7 @@ impl Build {
src = t!(fs::canonicalize(src));
} else {
let link = t!(fs::read_link(src));
t!(self.config.symlink_file(link, dst));
t!(self.symlink_file(link, dst));
return;
}
}
Expand Down Expand Up @@ -1524,6 +1525,14 @@ impl Build {
iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter()
}

fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
#[cfg(unix)]
use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
}

/// Returns if config.ninja is enabled, and checks for ninja existence,
/// exiting with a nicer error message if not.
fn ninja(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ impl Step for Llvm {

let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
if !lib_llvm.exists() {
t!(builder.build.config.symlink_file("libLLVM.dylib", &lib_llvm));
t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
}
}

Expand Down