Skip to content

Commit 94ccb9b

Browse files
committed
Remove dependence on tmp_dir
And also remove some environment variables passed to compilation of `rmake.rs`.
1 parent 7ebcc37 commit 94ccb9b

File tree

5 files changed

+14
-34
lines changed

5 files changed

+14
-34
lines changed

src/tools/compiletest/src/runtest.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -3533,18 +3533,11 @@ impl<'test> TestCx<'test> {
35333533
.env("S", &src_root)
35343534
.env("RUST_BUILD_STAGE", &self.config.stage_id)
35353535
.env("RUSTC", cwd.join(&self.config.rustc_path))
3536-
.env("TMPDIR", &rmake_out_dir)
35373536
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
35383537
.env(dylib_env_var(), &host_dylib_env_paths)
35393538
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
35403539
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
3541-
.env("LLVM_COMPONENTS", &self.config.llvm_components)
3542-
// We for sure don't want these tests to run in parallel, so make
3543-
// sure they don't have access to these vars if we run via `make`
3544-
// at the top level
3545-
.env_remove("MAKEFLAGS")
3546-
.env_remove("MFLAGS")
3547-
.env_remove("CARGO_MAKEFLAGS");
3540+
.env("LLVM_COMPONENTS", &self.config.llvm_components);
35483541

35493542
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
35503543
let mut stage0_sysroot = build_root.clone();
@@ -3585,16 +3578,9 @@ impl<'test> TestCx<'test> {
35853578
.env("S", &src_root)
35863579
.env("RUST_BUILD_STAGE", &self.config.stage_id)
35873580
.env("RUSTC", cwd.join(&self.config.rustc_path))
3588-
.env("TMPDIR", &rmake_out_dir)
35893581
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
35903582
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
3591-
.env("LLVM_COMPONENTS", &self.config.llvm_components)
3592-
// We for sure don't want these tests to run in parallel, so make
3593-
// sure they don't have access to these vars if we run via `make`
3594-
// at the top level
3595-
.env_remove("MAKEFLAGS")
3596-
.env_remove("MFLAGS")
3597-
.env_remove("CARGO_MAKEFLAGS");
3583+
.env("LLVM_COMPONENTS", &self.config.llvm_components);
35983584

35993585
if let Some(ref rustdoc) = self.config.rustdoc_path {
36003586
cmd.env("RUSTDOC", cwd.join(rustdoc));

src/tools/run-make-support/src/cc.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ impl Cc {
5454
self
5555
}
5656

57-
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable
58-
/// is under `$TMPDIR`.
57+
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler.
5958
pub fn out_exe(&mut self, name: &str) -> &mut Self {
6059
// Ref: tools.mk (irrelevant lines omitted):
6160
//
@@ -69,13 +68,13 @@ impl Cc {
6968
// ```
7069

7170
if is_msvc() {
72-
let fe_path = cygpath_windows(tmp_dir().join(bin_name(name)));
73-
let fo_path = cygpath_windows(tmp_dir().join(format!("{name}.obj")));
71+
let fe_path = cygpath_windows(bin_name(name));
72+
let fo_path = cygpath_windows(format!("{name}.obj"));
7473
self.cmd.arg(format!("-Fe:{fe_path}"));
7574
self.cmd.arg(format!("-Fo:{fo_path}"));
7675
} else {
7776
self.cmd.arg("-o");
78-
self.cmd.arg(tmp_dir().join(name));
77+
self.cmd.arg(name);
7978
}
8079

8180
self

src/tools/run-make-support/src/clang.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl Clang {
3030
self
3131
}
3232

33-
/// Specify the name of the executable. The executable will be placed under `$TMPDIR`, and the
34-
/// extension will be determined by [`bin_name`].
33+
/// Specify the name of the executable. The executable will be placed under the current directory
34+
/// and the extension will be determined by [`bin_name`].
3535
pub fn out_exe(&mut self, name: &str) -> &mut Self {
3636
self.cmd.arg("-o");
37-
self.cmd.arg(tmp_dir().join(bin_name(name)));
37+
self.cmd.arg(bin_name(name));
3838
self
3939
}
4040

src/tools/run-make-support/src/lib.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ pub fn env_var_os(name: &str) -> OsString {
4545
}
4646
}
4747

48-
/// Path of `TMPDIR` (a temporary build directory, not under `/tmp`).
49-
pub fn tmp_dir() -> PathBuf {
50-
env_var_os("TMPDIR").into()
51-
}
52-
5348
/// `TARGET`
5449
pub fn target() -> String {
5550
env_var("TARGET")
@@ -73,7 +68,7 @@ pub fn is_darwin() -> bool {
7368
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
7469
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
7570
pub fn static_lib(name: &str) -> PathBuf {
76-
tmp_dir().join(static_lib_name(name))
71+
PathBuf::from(static_lib_name(name))
7772
}
7873

7974
pub fn python_command() -> Command {
@@ -119,7 +114,7 @@ pub fn static_lib_name(name: &str) -> String {
119114
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
120115
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
121116
pub fn dynamic_lib(name: &str) -> PathBuf {
122-
tmp_dir().join(dynamic_lib_name(name))
117+
PathBuf::from(dynamic_lib_name(name))
123118
}
124119

125120
/// Construct the dynamic library name based on the platform.
@@ -162,7 +157,7 @@ pub fn dynamic_lib_extension() -> &'static str {
162157
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
163158
/// path with `$TMPDIR` joined with the library name.
164159
pub fn rust_lib(name: &str) -> PathBuf {
165-
tmp_dir().join(rust_lib_name(name))
160+
PathBuf::from(rust_lib_name(name))
166161
}
167162

168163
/// Generate the name a rust library (rlib) would have. If you want the complete path, use

src/tools/run-make-support/src/run.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use super::handle_failed_output;
88

99
fn run_common(name: &str) -> (Command, Output) {
1010
let mut bin_path = PathBuf::new();
11-
bin_path.push(env_var("TMPDIR"));
11+
bin_path.push(env::current_dir().unwrap());
1212
bin_path.push(name);
1313
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
1414
let mut cmd = Command::new(bin_path);
1515
cmd.env(&ld_lib_path_envvar, {
1616
let mut paths = vec![];
17-
paths.push(PathBuf::from(env_var("TMPDIR")));
17+
paths.push(env::current_dir().unwrap());
1818
for p in env::split_paths(&env_var("TARGET_RPATH_ENV")) {
1919
paths.push(p.to_path_buf());
2020
}

0 commit comments

Comments
 (0)