mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +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
|
@ -23,19 +23,19 @@ fn main() {
|
|||
pre_linked_binary_path.extend(["pre_linked_binary"]);
|
||||
pre_linked_binary_path.set_extension("o");
|
||||
|
||||
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");
|
||||
|
||||
let output = Command::new(&zig_executable())
|
||||
.args([
|
||||
"wasm-ld",
|
||||
builtins_host_file.path().to_str().unwrap(),
|
||||
builtins_host_tempfile.path().to_str().unwrap(),
|
||||
platform_obj.to_str().unwrap(),
|
||||
WASI_COMPILER_RT_PATH,
|
||||
WASI_LIBC_PATH,
|
||||
|
@ -48,6 +48,10 @@ fn main() {
|
|||
.output()
|
||||
.unwrap();
|
||||
|
||||
// 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;
|
||||
|
||||
assert!(output.status.success(), "{:#?}", output);
|
||||
assert!(output.stdout.is_empty(), "{:#?}", output);
|
||||
assert!(output.stderr.is_empty(), "{:#?}", output);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue