|
| 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. |
0 commit comments