Remove dependence on tmp_dir

And also remove some environment variables passed to compilation of `rmake.rs`.
This commit is contained in:
Jakub Beránek 2024-06-06 20:47:00 +02:00
parent 7ebcc37d65
commit 94ccb9b34d
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
5 changed files with 14 additions and 34 deletions

View file

@ -3533,18 +3533,11 @@ impl<'test> TestCx<'test> {
.env("S", &src_root)
.env("RUST_BUILD_STAGE", &self.config.stage_id)
.env("RUSTC", cwd.join(&self.config.rustc_path))
.env("TMPDIR", &rmake_out_dir)
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
.env(dylib_env_var(), &host_dylib_env_paths)
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
.env("LLVM_COMPONENTS", &self.config.llvm_components)
// We for sure don't want these tests to run in parallel, so make
// sure they don't have access to these vars if we run via `make`
// at the top level
.env_remove("MAKEFLAGS")
.env_remove("MFLAGS")
.env_remove("CARGO_MAKEFLAGS");
.env("LLVM_COMPONENTS", &self.config.llvm_components);
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
let mut stage0_sysroot = build_root.clone();
@ -3585,16 +3578,9 @@ impl<'test> TestCx<'test> {
.env("S", &src_root)
.env("RUST_BUILD_STAGE", &self.config.stage_id)
.env("RUSTC", cwd.join(&self.config.rustc_path))
.env("TMPDIR", &rmake_out_dir)
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
.env("LLVM_COMPONENTS", &self.config.llvm_components)
// We for sure don't want these tests to run in parallel, so make
// sure they don't have access to these vars if we run via `make`
// at the top level
.env_remove("MAKEFLAGS")
.env_remove("MFLAGS")
.env_remove("CARGO_MAKEFLAGS");
.env("LLVM_COMPONENTS", &self.config.llvm_components);
if let Some(ref rustdoc) = self.config.rustdoc_path {
cmd.env("RUSTDOC", cwd.join(rustdoc));

View file

@ -54,8 +54,7 @@ impl Cc {
self
}
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable
/// is under `$TMPDIR`.
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler.
pub fn out_exe(&mut self, name: &str) -> &mut Self {
// Ref: tools.mk (irrelevant lines omitted):
//
@ -69,13 +68,13 @@ impl Cc {
// ```
if is_msvc() {
let fe_path = cygpath_windows(tmp_dir().join(bin_name(name)));
let fo_path = cygpath_windows(tmp_dir().join(format!("{name}.obj")));
let fe_path = cygpath_windows(bin_name(name));
let fo_path = cygpath_windows(format!("{name}.obj"));
self.cmd.arg(format!("-Fe:{fe_path}"));
self.cmd.arg(format!("-Fo:{fo_path}"));
} else {
self.cmd.arg("-o");
self.cmd.arg(tmp_dir().join(name));
self.cmd.arg(name);
}
self

View file

@ -30,11 +30,11 @@ impl Clang {
self
}
/// Specify the name of the executable. The executable will be placed under `$TMPDIR`, and the
/// extension will be determined by [`bin_name`].
/// Specify the name of the executable. The executable will be placed under the current directory
/// and the extension will be determined by [`bin_name`].
pub fn out_exe(&mut self, name: &str) -> &mut Self {
self.cmd.arg("-o");
self.cmd.arg(tmp_dir().join(bin_name(name)));
self.cmd.arg(bin_name(name));
self
}

View file

@ -45,11 +45,6 @@ pub fn env_var_os(name: &str) -> OsString {
}
}
/// Path of `TMPDIR` (a temporary build directory, not under `/tmp`).
pub fn tmp_dir() -> PathBuf {
env_var_os("TMPDIR").into()
}
/// `TARGET`
pub fn target() -> String {
env_var("TARGET")
@ -73,7 +68,7 @@ pub fn is_darwin() -> bool {
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
pub fn static_lib(name: &str) -> PathBuf {
tmp_dir().join(static_lib_name(name))
PathBuf::from(static_lib_name(name))
}
pub fn python_command() -> Command {
@ -119,7 +114,7 @@ pub fn static_lib_name(name: &str) -> String {
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
pub fn dynamic_lib(name: &str) -> PathBuf {
tmp_dir().join(dynamic_lib_name(name))
PathBuf::from(dynamic_lib_name(name))
}
/// Construct the dynamic library name based on the platform.
@ -162,7 +157,7 @@ pub fn dynamic_lib_extension() -> &'static str {
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with the library name.
pub fn rust_lib(name: &str) -> PathBuf {
tmp_dir().join(rust_lib_name(name))
PathBuf::from(rust_lib_name(name))
}
/// Generate the name a rust library (rlib) would have. If you want the complete path, use

View file

@ -8,13 +8,13 @@ use super::handle_failed_output;
fn run_common(name: &str) -> (Command, Output) {
let mut bin_path = PathBuf::new();
bin_path.push(env_var("TMPDIR"));
bin_path.push(env::current_dir().unwrap());
bin_path.push(name);
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
let mut cmd = Command::new(bin_path);
cmd.env(&ld_lib_path_envvar, {
let mut paths = vec![];
paths.push(PathBuf::from(env_var("TMPDIR")));
paths.push(env::current_dir().unwrap());
for p in env::split_paths(&env_var("TARGET_RPATH_ENV")) {
paths.push(p.to_path_buf());
}