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 5a0d4344fed13..1e38f7e9e3b7c 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 a989ede3b418f..629b0afb3d898 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 547ab0c49c671..db324f07c7e91 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 ea5714a1c2c2d..b58d02f7eef6f 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; @@ -84,19 +82,3 @@ pub use assertion_helpers::{ has_prefix, has_suffix, invalid_utf8_contains, invalid_utf8_not_contains, not_contains, shallow_find_files, }; - -use command::Command; - -/// 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 d47e009fe9f95..17f8ce34f19c1 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 41fdaf55aad5e..9ed92ac415671 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() + }); +}