Call add_intrinsics after add_default_roc_externs

This is necessary to prevent defining things twice
This commit is contained in:
Richard Feldman 2021-05-23 17:33:12 -04:00
parent e6ece40f76
commit ebad3597c9
4 changed files with 67 additions and 50 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::build::add_intrinsics;
use roc_gen::llvm::externs::add_default_roc_externs;
use roc_module::symbol::Symbol;
use roc_types::subs::VarStore;
@ -180,8 +181,16 @@ pub fn helper<'a>(
),
};
let builder = context.create_builder();
let module = roc_gen::llvm::build::module_from_builtins(context, "app");
// Add roc_alloc, roc_realloc, and roc_dealloc, since the repl has no
// platform to provide them. These must be added *before* adding intrinsics!
add_default_roc_externs(context, &module, &builder, ptr_bytes);
// Add LLVM intrinsics.
add_intrinsics(context, &module);
// strip Zig debug stuff
module.strip_debug_info();
@ -216,11 +225,6 @@ 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,