diff --git a/src/tools/run-make-support/src/external_deps/llvm.rs b/src/tools/run-make-support/src/external_deps/llvm.rs index e7715a905fb..9c821dfc03d 100644 --- a/src/tools/run-make-support/src/external_deps/llvm.rs +++ b/src/tools/run-make-support/src/external_deps/llvm.rs @@ -1,6 +1,7 @@ use std::path::{Path, PathBuf}; -use crate::{env_var, Command}; +use crate::command::Command; +use crate::env_checked::env_var; /// Construct a new `llvm-readobj` invocation with the `GNU` output style. /// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`. diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs index 8dc6d1238b3..ce04caf6d34 100644 --- a/src/tools/run-make-support/src/external_deps/rustc.rs +++ b/src/tools/run-make-support/src/external_deps/rustc.rs @@ -1,8 +1,10 @@ -use command::Command; use std::ffi::{OsStr, OsString}; use std::path::Path; -use crate::{command, cwd, env_var, set_host_rpath}; +use crate::command::Command; +use crate::env_checked::env_var; +use crate::path_helpers::cwd; +use crate::util::set_host_rpath; /// Construct a new `rustc` invocation. This will automatically set the library /// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this. diff --git a/src/tools/run-make-support/src/external_deps/rustdoc.rs b/src/tools/run-make-support/src/external_deps/rustdoc.rs index 547ab0c49c6..db324f07c7e 100644 --- a/src/tools/run-make-support/src/external_deps/rustdoc.rs +++ b/src/tools/run-make-support/src/external_deps/rustdoc.rs @@ -2,7 +2,8 @@ use std::ffi::OsStr; use std::path::Path; use crate::command::Command; -use crate::{env_var, env_var_os, set_host_rpath}; +use crate::env_checked::{env_var, env_var_os}; +use crate::util::set_host_rpath; /// Construct a plain `rustdoc` invocation with no flags set. #[track_caller] diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 7c7b890f6ed..593655d7fd2 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -20,8 +20,6 @@ pub mod run; pub mod scoped_run; pub mod targets; -use std::path::PathBuf; - // Re-exports of third-party library crates. pub use bstr; pub use gimli; @@ -85,8 +83,6 @@ pub use assertion_helpers::{ shallow_find_files, }; -use command::Command; - /// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name. #[track_caller] pub fn build_native_static_lib(lib_name: &str) -> PathBuf { @@ -106,17 +102,3 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf { llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run(); path(lib_path) } - -/// Set the runtime library path as needed for running the host rustc/rustdoc/etc. -pub fn set_host_rpath(cmd: &mut Command) { - let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR"); - cmd.env(&ld_lib_path_envvar, { - let mut paths = vec![]; - paths.push(cwd()); - paths.push(PathBuf::from(env_var("HOST_RPATH_DIR"))); - for p in std::env::split_paths(&env_var(&ld_lib_path_envvar)) { - paths.push(p.to_path_buf()); - } - std::env::join_paths(paths.iter()).unwrap() - }); -} diff --git a/src/tools/run-make-support/src/run.rs b/src/tools/run-make-support/src/run.rs index d47e009fe9f..17f8ce34f19 100644 --- a/src/tools/run-make-support/src/run.rs +++ b/src/tools/run-make-support/src/run.rs @@ -4,8 +4,8 @@ use std::panic; use std::path::{Path, PathBuf}; use crate::command::{Command, CompletedProcess}; -use crate::util::handle_failed_output; -use crate::{cwd, env_var, is_windows, set_host_rpath}; +use crate::util::{handle_failed_output, set_host_rpath}; +use crate::{cwd, env_var, is_windows}; #[track_caller] fn run_common(name: &str, args: Option<&[&str]>) -> Command { diff --git a/src/tools/run-make-support/src/util.rs b/src/tools/run-make-support/src/util.rs index 41fdaf55aad..9ed92ac4156 100644 --- a/src/tools/run-make-support/src/util.rs +++ b/src/tools/run-make-support/src/util.rs @@ -1,4 +1,8 @@ +use std::path::PathBuf; + use crate::command::{Command, CompletedProcess}; +use crate::env_checked::env_var; +use crate::path_helpers::cwd; /// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the /// executed command, failure location, output status and stdout/stderr, and abort the process with @@ -19,3 +23,17 @@ pub(crate) fn handle_failed_output( eprintln!("=== STDERR ===\n{}\n\n", output.stderr_utf8()); std::process::exit(1) } + +/// Set the runtime library path as needed for running the host rustc/rustdoc/etc. +pub(crate) fn set_host_rpath(cmd: &mut Command) { + let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR"); + cmd.env(&ld_lib_path_envvar, { + let mut paths = vec![]; + paths.push(cwd()); + paths.push(PathBuf::from(env_var("HOST_RPATH_DIR"))); + for p in std::env::split_paths(&env_var(&ld_lib_path_envvar)) { + paths.push(p.to_path_buf()); + } + std::env::join_paths(paths.iter()).unwrap() + }); +}