mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-15 21:23:57 +00:00
Merge branch 'precompiled-legacy' into https-packages
This commit is contained in:
commit
f5cb2d73a1
96 changed files with 4063 additions and 1334 deletions
|
|
@ -14,6 +14,7 @@ path = "src/tests.rs"
|
|||
roc_builtins = { path = "../builtins" }
|
||||
roc_utils = { path = "../../utils" }
|
||||
wasi_libc_sys = { path = "../../wasi-libc-sys" }
|
||||
tempfile.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
roc_gen_llvm = { path = "../gen_llvm" }
|
||||
|
|
@ -40,6 +41,7 @@ roc_target = { path = "../roc_target" }
|
|||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
roc_debug_flags = {path="../debug_flags"}
|
||||
roc_wasm_module = {path="../../wasm_module"}
|
||||
|
||||
bumpalo.workspace = true
|
||||
libc.workspace = true
|
||||
|
|
|
|||
|
|
@ -100,9 +100,12 @@ fn build_wasm_test_host() {
|
|||
let mut outfile = PathBuf::from(&out_dir).join(PLATFORM_FILENAME);
|
||||
outfile.set_extension("wasm");
|
||||
|
||||
let builtins_host_tempfile =
|
||||
bitcode::host_wasm_tempfile().expect("failed to write host builtins object to tempfile");
|
||||
|
||||
run_zig(&[
|
||||
"wasm-ld",
|
||||
&bitcode::get_builtins_wasm32_obj_path(),
|
||||
builtins_host_tempfile.path().to_str().unwrap(),
|
||||
platform_path.to_str().unwrap(),
|
||||
WASI_COMPILER_RT_PATH,
|
||||
WASI_LIBC_PATH,
|
||||
|
|
@ -111,6 +114,10 @@ fn build_wasm_test_host() {
|
|||
"--no-entry",
|
||||
"--relocatable",
|
||||
]);
|
||||
|
||||
// Extend the lifetime of the tempfile so it doesn't get dropped
|
||||
// (and thus deleted) before the Zig process is done using it!
|
||||
let _ = builtins_host_tempfile;
|
||||
}
|
||||
|
||||
fn build_wasm_platform(out_dir: &str, source_path: &str) -> PathBuf {
|
||||
|
|
|
|||
|
|
@ -2513,7 +2513,7 @@ fn function_malformed_pattern() {
|
|||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[should_panic(expected = "Hit an erroneous type when creating a layout for")]
|
||||
#[ignore = "causes alias analysis panics, should roc_panic"]
|
||||
fn call_invalid_layout() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
|
|
|||
|
|
@ -1642,7 +1642,7 @@ fn issue_2777_default_branch_codegen() {
|
|||
not(target_family = "windows"),
|
||||
any(feature = "gen-llvm", feature = "gen-wasm")
|
||||
))]
|
||||
#[should_panic(expected = "Erroneous")]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Tag Foo was part of a type error!""#)]
|
||||
fn issue_2900_unreachable_pattern() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
|
@ -1846,7 +1846,7 @@ fn alignment_i128() {
|
|||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Erroneous: Expr::Closure""#)]
|
||||
#[ignore = "causes alias analysis panics, should roc_panic"]
|
||||
fn error_type_in_tag_union_payload() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
|
@ -2022,3 +2022,64 @@ fn dispatch_tag_union_function_inferred() {
|
|||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn issue_4077_fixed_fixpoint() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
Input : [FromProjectSource, FromJob Job]
|
||||
|
||||
Job : [Job { inputs : List Input }]
|
||||
|
||||
job : { inputs : List Input } -> Job
|
||||
job = \config -> Job config
|
||||
|
||||
main =
|
||||
when job { inputs: [] } is
|
||||
_ -> "OKAY"
|
||||
"#
|
||||
),
|
||||
RocStr::from("OKAY"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn unify_types_with_fixed_fixpoints_outside_fixing_region() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
Input := [
|
||||
FromJob Job (List Str),
|
||||
]
|
||||
|
||||
Job := [
|
||||
Job (List Input)
|
||||
]
|
||||
|
||||
job : List Input -> Job
|
||||
job = \inputs ->
|
||||
@Job (Job inputs)
|
||||
|
||||
helloWorld : Job
|
||||
helloWorld =
|
||||
@Job ( Job [ @Input (FromJob greeting []) ] )
|
||||
|
||||
greeting : Job
|
||||
greeting =
|
||||
job []
|
||||
|
||||
main = (\_ -> "OKAY") helloWorld
|
||||
"#
|
||||
),
|
||||
RocStr::from("OKAY"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::process::Command;
|
|||
|
||||
use roc_builtins::bitcode::IntWidth;
|
||||
use roc_collections::{MutMap, MutSet};
|
||||
use roc_gen_wasm::wasm_module::WasmModule;
|
||||
use roc_module::ident::{ForeignSymbol, ModuleName};
|
||||
use roc_module::low_level::LowLevel;
|
||||
use roc_module::symbol::{
|
||||
|
|
@ -19,6 +18,7 @@ use roc_mono::ir::{
|
|||
UpdateModeId,
|
||||
};
|
||||
use roc_mono::layout::{Builtin, CapturesNiche, LambdaName, Layout, STLayoutInterner};
|
||||
use roc_wasm_module::WasmModule;
|
||||
use wasm3::{Environment, Module};
|
||||
|
||||
const LINKING_TEST_HOST_WASM: &str = "build/wasm_linking_test_host.wasm";
|
||||
|
|
@ -252,7 +252,7 @@ fn test_linking_without_dce() {
|
|||
]
|
||||
);
|
||||
|
||||
let (final_module, _called_preload_fns, _roc_main_index) =
|
||||
let (final_module, _called_fns, _roc_main_index) =
|
||||
roc_gen_wasm::build_app_module(&env, &mut interns, host_module, procedures);
|
||||
|
||||
let mut buffer = Vec::with_capacity(final_module.size());
|
||||
|
|
@ -309,10 +309,10 @@ fn test_linking_with_dce() {
|
|||
|
||||
assert!(&host_module.names.function_names.is_empty());
|
||||
|
||||
let (mut final_module, called_preload_fns, _roc_main_index) =
|
||||
let (mut final_module, called_fns, _roc_main_index) =
|
||||
roc_gen_wasm::build_app_module(&env, &mut interns, host_module, procedures);
|
||||
|
||||
final_module.eliminate_dead_code(env.arena, called_preload_fns);
|
||||
final_module.eliminate_dead_code(env.arena, called_fns);
|
||||
|
||||
let mut buffer = Vec::with_capacity(final_module.size());
|
||||
final_module.serialize(&mut buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue