Skip to content

Commit 62fed52

Browse files
authored
Merge pull request #2 from direc85/rust-1.75-tmpdir
Use `$HOME/.tmp` as temp dir if `TMPDIR` is unset
2 parents 74da0f8 + 57c5270 commit 62fed52

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

0009-Relocate-unset-tmp.patch

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
2+
index dd9d277fb..160e472cf 100644
3+
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
4+
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
5+
@@ -48,7 +48,7 @@ use std::ffi::OsString;
6+
use std::fs::{read, File, OpenOptions};
7+
use std::io::{BufWriter, Write};
8+
use std::ops::Deref;
9+
-use std::path::{Path, PathBuf};
10+
+use std::path::{MAIN_SEPARATOR, Path, PathBuf};
11+
use std::process::{ExitStatus, Output, Stdio};
12+
use std::{env, fmt, fs, io, mem, str};
13+
14+
@@ -95,11 +95,24 @@ pub fn link_binary<'a>(
15+
});
16+
17+
if outputs.outputs.should_link() {
18+
+ let mut clear_tmp = false;
19+
+ if env::var_os("TMPDIR").is_none() && env::var_os("HOME").is_some() {
20+
+ let home_tmp = env::var_os("HOME").unwrap();
21+
+ let home_tmp = format!("{}{}{}", home_tmp.to_string_lossy(), MAIN_SEPARATOR, ".tmp");
22+
+ env::set_var("TMPDIR", &home_tmp);
23+
+ if !Path::new(&home_tmp).exists() {
24+
+ let _ = fs::create_dir_all(home_tmp);
25+
+ }
26+
+ clear_tmp = true;
27+
+ }
28+
let tmpdir = TempFileBuilder::new()
29+
.prefix("rustc")
30+
.tempdir()
31+
.unwrap_or_else(|error| sess.emit_fatal(errors::CreateTempDir { error }));
32+
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps);
33+
+ if clear_tmp {
34+
+ env::remove_var("TMP");
35+
+ }
36+
let output = out_filename(
37+
sess,
38+
crate_type,
39+
@@ -1904,6 +1917,10 @@ fn add_linked_symbol_object(
40+
return;
41+
};
42+
43+
+ if std::env::var("SB2_RUST_TARGET_TRIPLE").is_ok() {
44+
+ return;
45+
+ }
46+
+
47+
if file.format() == object::BinaryFormat::Coff {
48+
// NOTE(nbdd0121): MSVC will hang if the input object file contains no sections,
49+
// so add an empty section.

rust.spec

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Patch5: 0005-Provide-ENV-controls-to-bypass-some-sb2-calls-betwee.patch
7777
Patch6: 0006-Scratchbox2-needs-to-be-able-to-tell-cargo-the-defau.patch
7878
Patch7: 0007-Disable-aarch64-outline-atomics-for-now.patch
7979
Patch8: 0008-Revert-Use-statx-s-64-bit-times-on-32-bit-linux-gnu.patch
80+
Patch9: 0009-Relocate-unset-tmp.patch
8081
# This is the real rustc spec - the stub one appears near the end.
8182
%ifarch %ix86
8283

0 commit comments

Comments
 (0)