Extract externs helpers into gen

This commit is contained in:
Richard Feldman 2021-05-23 12:12:00 -04:00
parent 3eb75619ea
commit e6ece40f76
4 changed files with 201 additions and 191 deletions

View file

@ -4,6 +4,7 @@ use roc_build::program::FunctionIterator;
use roc_can::builtins::builtin_defs_map;
use roc_can::def::Def;
use roc_collections::all::{MutMap, MutSet};
use roc_gen::llvm::externs::add_default_roc_externs;
use roc_module::symbol::Symbol;
use roc_types::subs::VarStore;
@ -184,7 +185,6 @@ pub fn helper<'a>(
// strip Zig debug stuff
module.strip_debug_info();
let builder = context.create_builder();
let opt_level = if cfg!(debug_assertions) {
roc_gen::llvm::build::OptLevel::Normal
} else {
@ -216,6 +216,11 @@ pub fn helper<'a>(
}
}
// Add roc_alloc, roc_realloc, and roc_dealloc, since the repl has no
// platform to provide them.
let builder = context.create_builder();
add_default_roc_externs(&context, module, &builder, ptr_bytes);
// Compile and add all the Procs before adding main
let env = roc_gen::llvm::build::Env {
arena: &arena,