From b6e28b59679e3e4ee47b20090035ef33889b3f3b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 24 Jun 2022 14:27:37 -0700 Subject: Allow dynamically linking against libLLVM on macOS Create symlinks to workaround file missing error in llvm-config --- src/bootstrap/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/bootstrap/lib.rs') diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 4ac857b470e..d30f69ffc51 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -107,15 +107,11 @@ use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; use std::env; use std::fs::{self, File}; +use std::io; use std::path::{Path, PathBuf}; use std::process::{self, Command}; use std::str; -#[cfg(unix)] -use std::os::unix::fs::symlink as symlink_file; -#[cfg(windows)] -use std::os::windows::fs::symlink_file; - use filetime::FileTime; use once_cell::sync::OnceCell; @@ -1446,7 +1442,7 @@ impl Build { src = t!(fs::canonicalize(src)); } else { let link = t!(fs::read_link(src)); - t!(symlink_file(link, dst)); + t!(self.symlink_file(link, dst)); return; } } @@ -1571,6 +1567,14 @@ impl Build { iter.map(|e| t!(e)).collect::>().into_iter() } + fn symlink_file, Q: AsRef>(&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(()) } + } + fn remove(&self, f: &Path) { if self.config.dry_run { return; -- cgit 1.4.1-3-g733a5