mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Make sure tempfiles don't get dropped too early
This commit is contained in:
parent
6b446fe592
commit
0b73ea69af
6 changed files with 46 additions and 25 deletions
|
@ -100,18 +100,18 @@ fn build_wasm_test_host() {
|
|||
let mut outfile = PathBuf::from(&out_dir).join(PLATFORM_FILENAME);
|
||||
outfile.set_extension("wasm");
|
||||
|
||||
let builtins_host_file = tempfile::Builder::new()
|
||||
let builtins_host_tempfile = tempfile::Builder::new()
|
||||
.prefix("host_bitcode")
|
||||
.suffix(".wasm")
|
||||
.rand_bytes(5)
|
||||
.tempfile()
|
||||
.unwrap();
|
||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
||||
std::fs::write(builtins_host_tempfile.path(), bitcode::HOST_WASM)
|
||||
.expect("failed to write host builtins object to tempfile");
|
||||
|
||||
run_zig(&[
|
||||
"wasm-ld",
|
||||
builtins_host_file.path().to_str().unwrap(),
|
||||
builtins_host_tempfile.path().to_str().unwrap(),
|
||||
platform_path.to_str().unwrap(),
|
||||
WASI_COMPILER_RT_PATH,
|
||||
WASI_LIBC_PATH,
|
||||
|
@ -120,6 +120,10 @@ fn build_wasm_test_host() {
|
|||
"--no-entry",
|
||||
"--relocatable",
|
||||
]);
|
||||
|
||||
// Extend the lifetime of the tempfile so it doesn't get dropped
|
||||
// (and thus deleted) before the Zig process is done using it!
|
||||
let _ = builtins_host_tempfile;
|
||||
}
|
||||
|
||||
fn build_wasm_platform(out_dir: &str, source_path: &str) -> PathBuf {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue