Merge branch 'precompiled-legacy' into https-packages

This commit is contained in:
Richard Feldman 2022-11-24 04:25:54 -05:00
commit f5cb2d73a1
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
96 changed files with 4063 additions and 1334 deletions

View file

@ -193,7 +193,8 @@ pub fn helper(
.expect("failed to build output object");
std::fs::write(&app_o_file, module_out).expect("failed to write object to file");
// std::fs::copy(&app_o_file, "/tmp/app.o").unwrap();
let builtins_host_tempfile =
bitcode::host_unix_tempfile().expect("failed to write host builtins object to tempfile");
let (mut child, dylib_path) = link(
&target,
@ -202,7 +203,7 @@ pub fn helper(
// With the current method all methods are kept and it adds about 100k to all outputs.
&[
app_o_file.to_str().unwrap(),
&bitcode::get_builtins_host_obj_path(),
builtins_host_tempfile.path().to_str().unwrap(),
],
LinkType::Dylib,
)
@ -210,6 +211,10 @@ pub fn helper(
child.wait().unwrap();
// Extend the lifetime of the tempfile so it doesn't get dropped
// (and thus deleted) before the linking process is done using it!
let _ = builtins_host_tempfile;
// Load the dylib
let path = dylib_path.as_path().to_str().unwrap();

View file

@ -1,7 +1,8 @@
use roc_error_macros::internal_error;
use roc_gen_wasm::{round_up_to_alignment, wasm32_sized::Wasm32Sized};
use roc_gen_wasm::wasm32_sized::Wasm32Sized;
use roc_mono::layout::Builtin;
use roc_std::{RocDec, RocList, RocOrder, RocResult, RocStr, I128, U128};
use roc_wasm_module::round_up_to_alignment;
use std::convert::TryInto;
pub trait FromWasm32Memory: Wasm32Sized {

View file

@ -2,10 +2,10 @@ use super::RefCount;
use crate::helpers::from_wasm32_memory::FromWasm32Memory;
use roc_collections::all::MutSet;
use roc_gen_wasm::wasm32_result::Wasm32Result;
use roc_gen_wasm::wasm_module::{Export, ExportType};
use roc_gen_wasm::DEBUG_SETTINGS;
use roc_load::{ExecutionMode, LoadConfig, Threading};
use roc_reporting::report::DEFAULT_PALETTE_HTML;
use roc_wasm_module::{Export, ExportType};
use std::marker::PhantomData;
use std::path::PathBuf;
use std::rc::Rc;
@ -138,10 +138,11 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
)
});
let (mut module, called_preload_fns, main_fn_index) =
let (mut module, mut called_fns, main_fn_index) =
roc_gen_wasm::build_app_module(&env, &mut interns, host_module, procedures);
T::insert_wrapper(arena, &mut module, TEST_WRAPPER_NAME, main_fn_index);
called_fns.push(true);
// Export the initialiser function for refcount tests
let init_refcount_idx = module
@ -158,7 +159,7 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
index: init_refcount_idx,
});
module.eliminate_dead_code(env.arena, called_preload_fns);
module.eliminate_dead_code(env.arena, called_fns);
let mut app_module_bytes = std::vec::Vec::with_capacity(module.size());
module.serialize(&mut app_module_bytes);