From 98ddd69aaeec6bebaf30637a8beb1da47281af87 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 19 Feb 2023 15:28:01 +0000 Subject: [PATCH] Add wrappers to dist/bin/ too in addition to dist/ Rust's build system since recently expects rustc to be in a bin/ directory if it is specified using the rustc option in config.toml. --- build_system/build_sysroot.rs | 4 +++- scripts/cargo-clif.rs | 6 +++++- scripts/rustc-clif.rs | 7 +++++-- scripts/rustdoc-clif.rs | 6 +++++- scripts/setup_rust_fork.sh | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 62a025b4f8f..4fb77c35c70 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -46,13 +46,15 @@ pub(crate) fn build_sysroot( let wrapper_name = wrapper_base_name.replace("____", wrapper); let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc); + let wrapper_path = DIST_DIR.to_path(dirs).join(&wrapper_name); build_cargo_wrapper_cmd .env("TOOLCHAIN_NAME", toolchain_name.clone()) .arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs"))) .arg("-o") - .arg(DIST_DIR.to_path(dirs).join(wrapper_name)) + .arg(&wrapper_path) .arg("-Cstrip=debuginfo"); spawn_and_wait(build_cargo_wrapper_cmd); + try_hard_link(wrapper_path, BIN_DIR.to_path(dirs).join(wrapper_name)); } let host = build_sysroot_for_triple( diff --git a/scripts/cargo-clif.rs b/scripts/cargo-clif.rs index c993430b830..67791a20327 100644 --- a/scripts/cargo-clif.rs +++ b/scripts/cargo-clif.rs @@ -5,7 +5,11 @@ use std::path::PathBuf; use std::process::Command; fn main() { - let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap()); + let current_exe = env::current_exe().unwrap(); + let mut sysroot = current_exe.parent().unwrap(); + if sysroot.file_name().unwrap().to_str().unwrap() == "bin" { + sysroot = sysroot.parent().unwrap(); + } let mut rustflags = String::new(); rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests -Zcodegen-backend="); diff --git a/scripts/rustc-clif.rs b/scripts/rustc-clif.rs index c187f54a60e..b9bba7f2e08 100644 --- a/scripts/rustc-clif.rs +++ b/scripts/rustc-clif.rs @@ -2,11 +2,14 @@ use std::env; use std::ffi::OsString; #[cfg(unix)] use std::os::unix::process::CommandExt; -use std::path::PathBuf; use std::process::Command; fn main() { - let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap()); + let current_exe = env::current_exe().unwrap(); + let mut sysroot = current_exe.parent().unwrap(); + if sysroot.file_name().unwrap().to_str().unwrap() == "bin" { + sysroot = sysroot.parent().unwrap(); + } let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join( env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX, diff --git a/scripts/rustdoc-clif.rs b/scripts/rustdoc-clif.rs index a6528ac41ae..82c761634c7 100644 --- a/scripts/rustdoc-clif.rs +++ b/scripts/rustdoc-clif.rs @@ -6,7 +6,11 @@ use std::path::PathBuf; use std::process::Command; fn main() { - let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap()); + let current_exe = env::current_exe().unwrap(); + let mut sysroot = current_exe.parent().unwrap(); + if sysroot.file_name().unwrap().to_str().unwrap() == "bin" { + sysroot = sysroot.parent().unwrap(); + } let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join( env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX, diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index a08e80dd19a..35aa3984491 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -36,7 +36,7 @@ changelog-seen = 2 ninja = false [build] -rustc = "$(pwd)/../dist/rustc-clif" +rustc = "$(pwd)/../dist/bin/rustc-clif" cargo = "$(rustup which cargo)" full-bootstrap = true local-rebuild = true