-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from direc85/rust-1.75-tmpdir
Use `$HOME/.tmp` as temp dir if `TMPDIR` is unset
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs | ||
index dd9d277fb..160e472cf 100644 | ||
--- a/compiler/rustc_codegen_ssa/src/back/link.rs | ||
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs | ||
@@ -48,7 +48,7 @@ use std::ffi::OsString; | ||
use std::fs::{read, File, OpenOptions}; | ||
use std::io::{BufWriter, Write}; | ||
use std::ops::Deref; | ||
-use std::path::{Path, PathBuf}; | ||
+use std::path::{MAIN_SEPARATOR, Path, PathBuf}; | ||
use std::process::{ExitStatus, Output, Stdio}; | ||
use std::{env, fmt, fs, io, mem, str}; | ||
|
||
@@ -95,11 +95,24 @@ pub fn link_binary<'a>( | ||
}); | ||
|
||
if outputs.outputs.should_link() { | ||
+ let mut clear_tmp = false; | ||
+ if env::var_os("TMPDIR").is_none() && env::var_os("HOME").is_some() { | ||
+ let home_tmp = env::var_os("HOME").unwrap(); | ||
+ let home_tmp = format!("{}{}{}", home_tmp.to_string_lossy(), MAIN_SEPARATOR, ".tmp"); | ||
+ env::set_var("TMPDIR", &home_tmp); | ||
+ if !Path::new(&home_tmp).exists() { | ||
+ let _ = fs::create_dir_all(home_tmp); | ||
+ } | ||
+ clear_tmp = true; | ||
+ } | ||
let tmpdir = TempFileBuilder::new() | ||
.prefix("rustc") | ||
.tempdir() | ||
.unwrap_or_else(|error| sess.emit_fatal(errors::CreateTempDir { error })); | ||
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); | ||
+ if clear_tmp { | ||
+ env::remove_var("TMP"); | ||
+ } | ||
let output = out_filename( | ||
sess, | ||
crate_type, | ||
@@ -1904,6 +1917,10 @@ fn add_linked_symbol_object( | ||
return; | ||
}; | ||
|
||
+ if std::env::var("SB2_RUST_TARGET_TRIPLE").is_ok() { | ||
+ return; | ||
+ } | ||
+ | ||
if file.format() == object::BinaryFormat::Coff { | ||
// NOTE(nbdd0121): MSVC will hang if the input object file contains no sections, | ||
// so add an empty section. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters