275-fix-random-sigsegv #303

Closed
z78078 wants to merge 7 commits from 275-fix-random-sigsegv into master
4 changed files with 20 additions and 3 deletions

1
Cargo.lock generated
View File

@ -521,6 +521,7 @@ dependencies = [
"inkwell",
"insta",
"itertools",
"lazy_static",
"nac3parser",
"parking_lot 0.11.2",
"rayon",

View File

@ -10,6 +10,7 @@ crossbeam = "0.8.1"
parking_lot = "0.11.1"
rayon = "1.5.1"
nac3parser = { path = "../nac3parser" }
lazy_static = "1.4.0"
[dependencies.inkwell]
git = "https://github.com/TheDan64/inkwell.git"

View File

@ -52,6 +52,12 @@ pub struct StaticValueStore {
pub type VarValue<'ctx> = (PointerValue<'ctx>, Option<Arc<dyn StaticValue + Send + Sync>>, i64);
lazy_static!(
// HACK: The Mutex is a work-around for issue
// https://git.m-labs.hk/M-Labs/nac3/issues/275
static ref PASSES_INIT_LOCK: Mutex<AtomicBool> = Mutex::new(AtomicBool::new(true));
);
pub struct CodeGenContext<'ctx, 'a> {
pub ctx: &'ctx Context,
pub builder: Builder<'ctx>,
@ -218,10 +224,16 @@ impl WorkerRegistry {
context.i32_type().const_int(4, false),
);
let passes = PassManager::create(&module);
// HACK: This critical section is a work-around for issue
// https://git.m-labs.hk/M-Labs/nac3/issues/275
{
let _data = PASSES_INIT_LOCK.lock();
let pass_builder = PassManagerBuilder::create();
pass_builder.set_optimization_level(OptimizationLevel::Default);
let passes = PassManager::create(&module);
pass_builder.populate_function_pass_manager(&passes);
}
let mut errors = HashSet::new();
while let Some(task) = self.receiver.recv().unwrap() {

View File

@ -1,6 +1,9 @@
#![warn(clippy::all)]
#![allow(dead_code)]
#[macro_use]
extern crate lazy_static;
pub mod codegen;
pub mod symbol_resolver;
pub mod toplevel;