Skip to content
Snippets Groups Projects
Commit 9db302b1 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'use_tempfile' into 'main'

Create temporary LLVM IR files in a fresh temporary directory.

See merge request !102
parents 500fc3d2 31d56bd2
No related branches found
No related tags found
1 merge request!102Create temporary LLVM IR files in a fresh temporary directory.
Pipeline #200966 passed
...@@ -650,6 +650,7 @@ dependencies = [ ...@@ -650,6 +650,7 @@ dependencies = [
"postcard", "postcard",
"serde", "serde",
"take_mut", "take_mut",
"tempfile",
] ]
[[package]] [[package]]
...@@ -1392,6 +1393,19 @@ version = "1.0.1" ...@@ -1392,6 +1393,19 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "tempfile"
version = "3.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
dependencies = [
"cfg-if",
"fastrand",
"once_cell",
"rustix",
"windows-sys 0.59.0",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.36" version = "0.3.36"
......
...@@ -7,6 +7,7 @@ edition = "2021" ...@@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
ordered-float = "*" ordered-float = "*"
bitvec = "*" bitvec = "*"
tempfile = "*"
either = "*" either = "*"
itertools = "*" itertools = "*"
take_mut = "*" take_mut = "*"
......
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::env::temp_dir;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::iter::zip; use std::iter::zip;
...@@ -8,6 +7,8 @@ use std::process::{Command, Stdio}; ...@@ -8,6 +7,8 @@ use std::process::{Command, Stdio};
use serde::Deserialize; use serde::Deserialize;
use tempfile::TempDir;
use hercules_cg::*; use hercules_cg::*;
use hercules_ir::*; use hercules_ir::*;
...@@ -960,7 +961,8 @@ impl PassManager { ...@@ -960,7 +961,8 @@ impl PassManager {
println!("{}", rust_rt); println!("{}", rust_rt);
// Write the LLVM IR into a temporary file. // Write the LLVM IR into a temporary file.
let mut tmp_path = temp_dir(); let tmp_dir = TempDir::new().unwrap();
let mut tmp_path = tmp_dir.path().to_path_buf();
tmp_path.push(format!("{}.ll", module_name)); tmp_path.push(format!("{}.ll", module_name));
println!("{}", tmp_path.display()); println!("{}", tmp_path.display());
let mut file = File::create(&tmp_path) let mut file = File::create(&tmp_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment