This commit is contained in:
Folkert 2022-07-06 15:43:17 +02:00
parent 8b39cc444e
commit d931546424
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
2 changed files with 8 additions and 40 deletions

View File

@ -8,9 +8,7 @@ use roc_build::link::{LinkType, LinkingStrategy};
use roc_error_macros::{internal_error, user_error};
use roc_load::{LoadingProblem, Threading};
use roc_mono::ir::OptLevel;
use roc_region::all::Region;
use roc_repl_cli::expect_mono_module_to_dylib;
use roc_reporting::report::{Palette, Report, RocDocAllocator, RocDocBuilder};
use roc_target::TargetInfo;
use std::env;
use std::ffi::{CString, OsStr};
@ -296,8 +294,6 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
(false, false, false) => OptLevel::Normal,
_ => user_error!("build can be only one of `--dev`, `--optimize`, or `--opt-size`"),
};
let emit_debug_info = matches.is_present(FLAG_DEBUG);
let emit_timings = matches.is_present(FLAG_TIME);
let threading = match matches
.value_of(FLAG_MAX_THREADS)
@ -309,27 +305,6 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
Some(n) => Threading::AtMost(n),
};
let wasm_dev_backend = matches!(opt_level, OptLevel::Development)
&& matches!(triple.architecture, Architecture::Wasm32);
let linking_strategy = if wasm_dev_backend {
LinkingStrategy::Additive
} else if !roc_linker::supported(&LinkType::Dylib, &triple)
|| matches.value_of(FLAG_LINKER) == Some("legacy")
{
LinkingStrategy::Legacy
} else {
LinkingStrategy::Surgical
};
let precompiled = if matches.is_present(FLAG_PRECOMPILED) {
matches.value_of(FLAG_PRECOMPILED) == Some("true")
} else {
// When compiling for a different target, default to assuming a precompiled host.
// Otherwise compilation would most likely fail because many toolchains assume you're compiling for the host
// We make an exception for Wasm, because cross-compiling is the norm in that case.
triple != Triple::host() && !matches!(triple.architecture, Architecture::Wasm32)
};
let path = Path::new(filename);
// Spawn the root task
@ -378,7 +353,8 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
}
let src_dir = path.parent().unwrap().canonicalize().unwrap();
let target_valgrind = matches.is_present(FLAG_VALGRIND);
// let target_valgrind = matches.is_present(FLAG_VALGRIND);
let arena = &arena;
let target = &triple;
@ -388,9 +364,9 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
// Step 1: compile the app and generate the .o file
let subs_by_module = Default::default();
let mut loaded = roc_load::load_and_monomorphize(
let loaded = roc_load::load_and_monomorphize(
arena,
path.clone(),
path,
src_dir.as_path(),
subs_by_module,
target_info,
@ -400,7 +376,7 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
)
.unwrap();
let (lib, expects, subs) =
let (lib, expects) =
expect_mono_module_to_dylib(arena, target.clone(), loaded, opt_level).unwrap();
use roc_gen_llvm::run_jit_function;

View File

@ -196,21 +196,13 @@ pub fn expect_mono_module_to_dylib<'a>(
target: Triple,
loaded: MonomorphizedModule<'a>,
opt_level: OptLevel,
) -> Result<
(
libloading::Library,
bumpalo::collections::Vec<'a, &'a str>,
Subs,
),
libloading::Error,
> {
) -> Result<(libloading::Library, bumpalo::collections::Vec<'a, &'a str>), libloading::Error> {
let target_info = TargetInfo::from(&target);
let MonomorphizedModule {
procedures,
entry_point,
interns,
subs,
..
} = loaded;
@ -221,7 +213,7 @@ pub fn expect_mono_module_to_dylib<'a>(
));
let module = arena.alloc(module);
let (module_pass, function_pass) =
let (module_pass, _function_pass) =
roc_gen_llvm::llvm::build::construct_optimization_passes(module, opt_level);
let (dibuilder, compile_unit) = roc_gen_llvm::llvm::build::Env::new_debug_info(module);
@ -273,7 +265,7 @@ pub fn expect_mono_module_to_dylib<'a>(
);
}
llvm_module_to_dylib(env.module, &target, opt_level).map(|lib| (lib, expects, subs))
llvm_module_to_dylib(env.module, &target, opt_level).map(|lib| (lib, expects))
}
pub fn mono_module_to_dylib<'a>(