From e8c3ff042cbe6fca7a135acb52b686d4aa737c34 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 27 May 2021 18:08:32 -0400 Subject: [PATCH 01/16] Remove examples/balance --- examples/balance/.gitignore | 1 - examples/balance/Main.roc | 7 - examples/balance/platform/Cargo.lock | 23 --- examples/balance/platform/Cargo.toml | 14 -- examples/balance/platform/Package-Config.roc | 15 -- examples/balance/platform/host.c | 7 - examples/balance/platform/src/lib.rs | 147 ------------------- 7 files changed, 214 deletions(-) delete mode 100644 examples/balance/.gitignore delete mode 100644 examples/balance/Main.roc delete mode 100644 examples/balance/platform/Cargo.lock delete mode 100644 examples/balance/platform/Cargo.toml delete mode 100644 examples/balance/platform/Package-Config.roc delete mode 100644 examples/balance/platform/host.c delete mode 100644 examples/balance/platform/src/lib.rs diff --git a/examples/balance/.gitignore b/examples/balance/.gitignore deleted file mode 100644 index ba2906d066..0000000000 --- a/examples/balance/.gitignore +++ /dev/null @@ -1 +0,0 @@ -main diff --git a/examples/balance/Main.roc b/examples/balance/Main.roc deleted file mode 100644 index 441dfb50f3..0000000000 --- a/examples/balance/Main.roc +++ /dev/null @@ -1,7 +0,0 @@ -app "main" imports [ Effect ] provides [ rocMain ] to "./platform" - - -rocMain : Effect.Effect {} as Fx -rocMain = - when List.len (Str.split "hello" "JJJJ there") is - _ -> Effect.putLine "Yay" diff --git a/examples/balance/platform/Cargo.lock b/examples/balance/platform/Cargo.lock deleted file mode 100644 index c386bb6c4a..0000000000 --- a/examples/balance/platform/Cargo.lock +++ /dev/null @@ -1,23 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "host" -version = "0.1.0" -dependencies = [ - "roc_std 0.1.0", -] - -[[package]] -name = "libc" -version = "0.2.79" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "roc_std" -version = "0.1.0" -dependencies = [ - "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)" = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" diff --git a/examples/balance/platform/Cargo.toml b/examples/balance/platform/Cargo.toml deleted file mode 100644 index b0a2a5e96e..0000000000 --- a/examples/balance/platform/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "host" -version = "0.1.0" -authors = ["The Roc Contributors"] -license = "UPL-1.0" -edition = "2018" - -[lib] -crate-type = ["staticlib"] - -[dependencies] -roc_std = { path = "../../../roc_std" } - -[workspace] diff --git a/examples/balance/platform/Package-Config.roc b/examples/balance/platform/Package-Config.roc deleted file mode 100644 index 0d66513ebe..0000000000 --- a/examples/balance/platform/Package-Config.roc +++ /dev/null @@ -1,15 +0,0 @@ -platform folkertdev/foo - requires { rocMain : Effect {} } - exposes [] - packages {} - imports [] - provides [ mainForHost ] - effects Effect - { - putChar : Int -> Effect {}, - putLine : Str -> Effect {}, - getLine : Effect Str - } - -mainForHost : Effect {} as Fx -mainForHost = rocMain diff --git a/examples/balance/platform/host.c b/examples/balance/platform/host.c deleted file mode 100644 index 0378c69589..0000000000 --- a/examples/balance/platform/host.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -extern int rust_main(); - -int main() { - return rust_main(); -} diff --git a/examples/balance/platform/src/lib.rs b/examples/balance/platform/src/lib.rs deleted file mode 100644 index 5bff358b10..0000000000 --- a/examples/balance/platform/src/lib.rs +++ /dev/null @@ -1,147 +0,0 @@ -#![allow(non_snake_case)] - -use roc_std::alloca; -use roc_std::RocCallResult; -use roc_std::RocStr; -use std::alloc::Layout; -use std::ffi::c_void; -use std::time::SystemTime; - -extern "C" { - #[link_name = "roc__rocMain_1_exposed"] - fn roc_main(output: *mut u8) -> (); - - #[link_name = "roc__rocMain_1_size"] - fn roc_main_size() -> i64; - - #[link_name = "roc__rocMain_1_Fx_caller"] - fn call_Fx(function_pointer: *const u8, closure_data: *const u8, output: *mut u8) -> (); - - #[link_name = "roc__rocMain_1_Fx_size"] - fn size_Fx() -> i64; - - fn malloc(size: usize) -> *mut c_void; - fn realloc(c_ptr: *mut c_void, size: usize) -> *mut c_void; - fn free(c_ptr: *mut c_void); -} - -#[no_mangle] -pub unsafe fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void { - return malloc(size); -} - -#[no_mangle] -pub unsafe fn roc_realloc( - c_ptr: *mut c_void, - new_size: usize, - _old_size: usize, - _alignment: u32, -) -> *mut c_void { - return realloc(c_ptr, new_size); -} - -#[no_mangle] -pub unsafe fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) { - return free(c_ptr); -} - -#[no_mangle] -pub fn roc_fx_putChar(foo: i64) -> () { - let character = foo as u8 as char; - print!("{}", character); - - () -} - -#[no_mangle] -pub fn roc_fx_putLine(line: RocStr) -> () { - let bytes = line.as_slice(); - let string = unsafe { std::str::from_utf8_unchecked(bytes) }; - println!("{}", string); - - () -} - -#[no_mangle] -pub fn roc_fx_getLine() -> RocStr { - use std::io::{self, BufRead}; - - let stdin = io::stdin(); - let line1 = stdin.lock().lines().next().unwrap().unwrap(); - - RocStr::from_slice_with_capacity(line1.as_bytes(), line1.len()) -} - -unsafe fn call_the_closure(function_pointer: *const u8, closure_data_ptr: *const u8) -> i64 { - let size = size_Fx() as usize; - - alloca::with_stack_bytes(size, |buffer| { - let buffer: *mut std::ffi::c_void = buffer; - let buffer: *mut u8 = buffer as *mut u8; - - call_Fx( - function_pointer, - closure_data_ptr as *const u8, - buffer as *mut u8, - ); - - let output = &*(buffer as *mut RocCallResult); - - match output.into() { - Ok(_) => 0, - Err(e) => panic!("failed with {}", e), - } - }) -} - -#[no_mangle] -pub fn rust_main() -> isize { - println!("Running Roc closure"); - let start_time = SystemTime::now(); - - let size = unsafe { roc_main_size() } as usize; - let layout = Layout::array::(size).unwrap(); - let answer = unsafe { - let buffer = std::alloc::alloc(layout); - - roc_main(buffer); - - let output = &*(buffer as *mut RocCallResult<()>); - - match output.into() { - Ok(()) => { - let function_pointer = { - // this is a pointer to the location where the function pointer is stored - // we pass just the function pointer - let temp = buffer.offset(8) as *const i64; - - (*temp) as *const u8 - }; - - let closure_data_ptr = buffer.offset(16); - - let result = - call_the_closure(function_pointer as *const u8, closure_data_ptr as *const u8); - - std::alloc::dealloc(buffer, layout); - - result - } - Err(msg) => { - std::alloc::dealloc(buffer, layout); - - panic!("Roc failed with message: {}", msg); - } - } - }; - let end_time = SystemTime::now(); - let duration = end_time.duration_since(start_time).unwrap(); - - println!( - "Roc execution took {:.4} ms", - duration.as_secs_f64() * 1000.0, - ); - - // Exit code - 0 -} From 3a35fe55cfea96d0aed60e3706d6215a81a0a702 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 27 May 2021 18:09:01 -0400 Subject: [PATCH 02/16] Combine two conditionals, rename some stuff --- compiler/build/src/program.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/compiler/build/src/program.rs b/compiler/build/src/program.rs index 3fad005f6e..afdfcbaf38 100644 --- a/compiler/build/src/program.rs +++ b/compiler/build/src/program.rs @@ -100,20 +100,22 @@ pub fn gen_from_mono_module( let kind_id = Attribute::get_named_enum_kind_id("alwaysinline"); debug_assert!(kind_id > 0); - let attr = context.create_enum_attribute(kind_id, 1); + let enum_attr = context.create_enum_attribute(kind_id, 1); for function in FunctionIterator::from_module(module) { let name = function.get_name().to_str().unwrap(); + + // mark our zig-defined builtins as internal if name.starts_with("roc_builtins") { function.set_linkage(Linkage::Internal); } - if name.starts_with("roc_builtins.dict") || name.starts_with("dict.RocDict") { - function.add_attribute(AttributeLoc::Function, attr); - } - - if name.starts_with("roc_builtins.list") || name.starts_with("list.RocList") { - function.add_attribute(AttributeLoc::Function, attr); + if name.starts_with("roc_builtins.dict") + || name.starts_with("dict.RocDict") + || name.starts_with("roc_builtins.list") + || name.starts_with("list.RocList") + { + function.add_attribute(AttributeLoc::Function, enum_attr); } } From 4af5cda91d201a3133bd2c609d68418d3f3f8997 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 27 May 2021 18:09:16 -0400 Subject: [PATCH 03/16] Reuse a variable instead of duplicating strings --- compiler/gen/src/llvm/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index ed34bfc104..41dacb9476 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -5791,7 +5791,7 @@ fn get_gxx_personality_v0<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> Function None => { let personality_func = add_func( module, - "__gxx_personality_v0", + name, context.i64_type().fn_type(&[], false), Linkage::External, C_CALL_CONV, @@ -5843,7 +5843,7 @@ fn cxa_begin_catch<'a, 'ctx, 'env>( let cxa_begin_catch = add_func( module, - "__cxa_begin_catch", + name, u8_ptr.fn_type(&[u8_ptr.into()], false), Linkage::External, C_CALL_CONV, From 2c0b52dd6fd59202dd3c7a5d488fe64b920aa573 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 27 May 2021 21:57:35 -0400 Subject: [PATCH 04/16] Fix mono test --- compiler/mono/tests/test_mono.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/mono/tests/test_mono.rs b/compiler/mono/tests/test_mono.rs index ce1f0bac7e..9924474515 100644 --- a/compiler/mono/tests/test_mono.rs +++ b/compiler/mono/tests/test_mono.rs @@ -270,11 +270,12 @@ mod test_mono { indoc!( r#" procedure Test.0 (): - let Test.11 = 1i64; - let Test.9 = 1i64; - let Test.10 = 2i64; - let Test.5 = These Test.11 Test.9 Test.10; - switch Test.5: + let Test.12 = 1i64; + let Test.10 = 1i64; + let Test.11 = 2i64; + let Test.5 = These Test.12 Test.10 Test.11; + let Test.9 = Index 0 Test.5; + switch Test.9: case 2: let Test.2 = Index 1 Test.5; ret Test.2; From 0589735ff24ef2f4e5dc12421b01522570d61281 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 27 May 2021 18:08:47 -0400 Subject: [PATCH 05/16] Fix typo --- BUILDING_FROM_SOURCE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING_FROM_SOURCE.md b/BUILDING_FROM_SOURCE.md index b2f92c10cf..8b4e627883 100644 --- a/BUILDING_FROM_SOURCE.md +++ b/BUILDING_FROM_SOURCE.md @@ -20,7 +20,7 @@ For debugging LLVM IR, we use [DebugIR](https://github.com/vaivaswatha/debugir). ### libunwind & libc++-dev -MacOS systems should already have `libunwind`, but other systems will need to install it (On Ubuntu, this can be donw with `sudo apt-get install libunwind-dev`). +MacOS systems should already have `libunwind`, but other systems will need to install it (On Ubuntu, this can be done with `sudo apt-get install libunwind-dev`). Some systems may already have `libc++-dev` on them, but if not, you may need to install it. (On Ubuntu, this can be done with `sudo apt-get install libc++-dev`.) ### libcxb libraries From 4739b5db913b1dc1cb33991630986b2ad66fcc61 Mon Sep 17 00:00:00 2001 From: rvcas Date: Fri, 28 May 2021 12:57:45 -0400 Subject: [PATCH 06/16] test: add a test to contrain if expr --- editor/tests/solve_expr2.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor/tests/solve_expr2.rs b/editor/tests/solve_expr2.rs index 4685f3e2bb..699f5fa3a7 100644 --- a/editor/tests/solve_expr2.rs +++ b/editor/tests/solve_expr2.rs @@ -274,3 +274,15 @@ fn constrain_access() { "Str", ) } + +#[test] +fn constrain_if() { + infer_eq( + indoc!( + r#" + if True then Green else Red + "# + ), + "[ Green, Red ]*", + ) +} From 695a5a7aa98130a871a58ab6cde358b62fdc0e2d Mon Sep 17 00:00:00 2001 From: rvcas Date: Fri, 28 May 2021 13:01:01 -0400 Subject: [PATCH 07/16] fix: made if branches smaller --- editor/src/lang/ast.rs | 8 ++++---- editor/src/lang/expr.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/editor/src/lang/ast.rs b/editor/src/lang/ast.rs index 87c4ed6e9e..7b2c87095e 100644 --- a/editor/src/lang/ast.rs +++ b/editor/src/lang/ast.rs @@ -119,10 +119,10 @@ pub enum Expr2 { elems: PoolVec, // 8B }, If { - cond_var: Variable, // 4B - expr_var: Variable, // 4B - branches: PoolVec<(Expr2, Expr2)>, // 8B - final_else: NodeId, // 4B + cond_var: Variable, // 4B + expr_var: Variable, // 4B + branches: PoolVec<(NodeId, NodeId)>, // 8B + final_else: NodeId, // 4B }, When { cond_var: Variable, // 4B diff --git a/editor/src/lang/expr.rs b/editor/src/lang/expr.rs index cd227fcf3f..6bd59b09ac 100644 --- a/editor/src/lang/expr.rs +++ b/editor/src/lang/expr.rs @@ -516,7 +516,7 @@ pub fn to_expr2<'a>( output.references.union_mut(cond_output.references); output.references.union_mut(then_output.references); - new_branches.push((cond, then_expr)); + new_branches.push((env.pool.add(cond), env.pool.add(then_expr))); } let (else_expr, else_output) = From 2e4696c3dfaa39dd3870948910d2fd60aaf0ef57 Mon Sep 17 00:00:00 2001 From: rvcas Date: Fri, 28 May 2021 13:03:01 -0400 Subject: [PATCH 08/16] chore: bring a type into scope --- editor/src/lang/constrain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/src/lang/constrain.rs b/editor/src/lang/constrain.rs index 2832cef8ac..af351606b8 100644 --- a/editor/src/lang/constrain.rs +++ b/editor/src/lang/constrain.rs @@ -13,7 +13,7 @@ use roc_module::{ident::TagName, symbol::Symbol}; use roc_region::all::{Located, Region}; use roc_types::{ subs::Variable, - types, + types::{self, AnnotationSource}, types::{Category, Reason}, }; From 4a93bbde18e8bf9bd6cef6a4f3eb471b24a1efcc Mon Sep 17 00:00:00 2001 From: rvcas Date: Fri, 28 May 2021 13:04:51 -0400 Subject: [PATCH 09/16] feat: implement if constraints --- editor/src/lang/constrain.rs | 151 +++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/editor/src/lang/constrain.rs b/editor/src/lang/constrain.rs index af351606b8..8150d76638 100644 --- a/editor/src/lang/constrain.rs +++ b/editor/src/lang/constrain.rs @@ -479,6 +479,157 @@ pub fn constrain_expr<'a>( exists(arena, flex_vars, And(and_constraints)) } + Expr2::If { + cond_var, + expr_var, + branches, + final_else, + } => { + let expect_bool = |region| { + let bool_type = Type2::Variable(Variable::BOOL); + Expected::ForReason(Reason::IfCondition, bool_type, region) + }; + + let mut branch_cons = BumpVec::with_capacity_in(2 * branches.len() + 3, arena); + + // TODO why does this cond var exist? is it for error messages? + // let first_cond_region = branches[0].0.region; + let cond_var_is_bool_con = Eq( + Type2::Variable(*cond_var), + expect_bool(region), + Category::If, + region, + ); + + branch_cons.push(cond_var_is_bool_con); + + let final_else_expr = env.pool.get(*final_else); + + let mut flex_vars = BumpVec::with_capacity_in(2, arena); + + flex_vars.push(*cond_var); + flex_vars.push(*expr_var); + + match expected { + Expected::FromAnnotation(name, arity, _, tipe) => { + let num_branches = branches.len() + 1; + + for (index, branch_id) in branches.iter_node_ids().enumerate() { + let (cond_id, body_id) = env.pool.get(branch_id); + + let cond = env.pool.get(*cond_id); + let body = env.pool.get(*body_id); + + let cond_con = + constrain_expr(arena, env, cond, expect_bool(region), region); + + let then_con = constrain_expr( + arena, + env, + body, + Expected::FromAnnotation( + name.clone(), + arity, + AnnotationSource::TypedIfBranch { + index: Index::zero_based(index), + num_branches, + }, + tipe.shallow_clone(), + ), + region, + ); + + branch_cons.push(cond_con); + branch_cons.push(then_con); + } + + let else_con = constrain_expr( + arena, + env, + final_else_expr, + Expected::FromAnnotation( + name, + arity, + AnnotationSource::TypedIfBranch { + index: Index::zero_based(branches.len()), + num_branches, + }, + tipe.shallow_clone(), + ), + region, + ); + + let ast_con = Eq( + Type2::Variable(*expr_var), + Expected::NoExpectation(tipe), + Category::Storage(std::file!(), std::line!()), + region, + ); + + branch_cons.push(ast_con); + branch_cons.push(else_con); + + exists(arena, flex_vars, And(branch_cons)) + } + _ => { + for (index, branch_id) in branches.iter_node_ids().enumerate() { + let (cond_id, body_id) = env.pool.get(branch_id); + + let cond = env.pool.get(*cond_id); + let body = env.pool.get(*body_id); + + let cond_con = + constrain_expr(arena, env, cond, expect_bool(region), region); + + let then_con = constrain_expr( + arena, + env, + body, + Expected::ForReason( + Reason::IfBranch { + index: Index::zero_based(index), + total_branches: branches.len(), + }, + Type2::Variable(*expr_var), + // should be from body + region, + ), + region, + ); + + branch_cons.push(cond_con); + branch_cons.push(then_con); + } + + let else_con = constrain_expr( + arena, + env, + final_else_expr, + Expected::ForReason( + Reason::IfBranch { + index: Index::zero_based(branches.len()), + total_branches: branches.len() + 1, + }, + Type2::Variable(*expr_var), + // should come from final_else + region, + ), + region, + ); + + branch_cons.push(Eq( + Type2::Variable(*expr_var), + expected, + Category::Storage(std::file!(), std::line!()), + region, + )); + + branch_cons.push(else_con); + + exists(arena, flex_vars, And(branch_cons)) + } + } + } _ => todo!("implement constaints for {:?}", expr), } } From a4d3f96f255abd7bb1f2d668db60334897b0d028 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Fri, 28 May 2021 17:03:59 -0700 Subject: [PATCH 10/16] Run build script instead of zig build on big sur --- .envrc | 2 +- compiler/builtins/bitcode/build.sh | 5 + compiler/builtins/build.rs | 44 +++++-- shell.nix | 198 ++++++++++++++--------------- 4 files changed, 141 insertions(+), 108 deletions(-) create mode 100755 compiler/builtins/bitcode/build.sh diff --git a/.envrc b/.envrc index 45097a203e..daafe18d9a 100644 --- a/.envrc +++ b/.envrc @@ -93,7 +93,7 @@ use_nix() { fi log_status "use nix: updating cache" - nix-shell --pure "${drv}" --show-trace --run "$(join_args "$direnv" dump bash)" > "${dump}" + nix-shell "${drv}" --show-trace --run "$(join_args "$direnv" dump bash)" > "${dump}" if [[ "${?}" -ne 0 ]] || [[ ! -f "${dump}" ]] || ! grep -q IN_NIX_SHELL "${dump}"; then rm -rf "${wd}" fail "use nix: was not able to update the cache of the environment. Please run 'direnv reload' to try again." diff --git a/compiler/builtins/bitcode/build.sh b/compiler/builtins/bitcode/build.sh new file mode 100755 index 0000000000..e863770c8e --- /dev/null +++ b/compiler/builtins/bitcode/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -euxo pipefail + +zig build-obj src/main.zig -O ReleaseFast -femit-llvm-ir=builtins.ll -femit-bin=builtins.o --strip diff --git a/compiler/builtins/build.rs b/compiler/builtins/build.rs index b6a4e41f14..57ec6d7a71 100644 --- a/compiler/builtins/build.rs +++ b/compiler/builtins/build.rs @@ -10,15 +10,29 @@ use std::str; fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); + let big_sur_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib"; + let use_build_script = Path::new(big_sur_path).exists(); + // "." is relative to where "build.rs" is let build_script_dir_path = fs::canonicalize(Path::new(".")).unwrap(); let bitcode_path = build_script_dir_path.join("bitcode"); let src_obj_path = bitcode_path.join("builtins.o"); let src_obj = src_obj_path.to_str().expect("Invalid src object path"); - println!("Compiling zig object to: {}", src_obj); - run_command(&bitcode_path, "zig", &["build", "object", "-Drelease=true"]); + let dest_ir_path = bitcode_path.join("builtins.ll"); + let dest_ir = dest_ir_path.to_str().expect("Invalid dest ir path"); + + if use_build_script { + println!("Compiling zig object & ir to: {} and {}", src_obj, dest_ir); + run_command_with_no_args(&bitcode_path, "./build.sh"); + } else { + println!("Compiling zig object to: {}", src_obj); + run_command(&bitcode_path, "zig", &["build", "object", "-Drelease=true"]); + + println!("Compiling ir to: {}", dest_ir); + run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]); + } let dest_obj_path = Path::new(&out_dir).join("builtins.o"); let dest_obj = dest_obj_path.to_str().expect("Invalid dest object path"); @@ -26,12 +40,6 @@ fn main() { run_command(&bitcode_path, "mv", &[src_obj, dest_obj]); - let dest_ir_path = bitcode_path.join("builtins.ll"); - let dest_ir = dest_ir_path.to_str().expect("Invalid dest ir path"); - println!("Compiling ir to: {}", dest_ir); - - run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]); - let dest_bc_path = bitcode_path.join("builtins.bc"); let dest_bc = dest_bc_path.to_str().expect("Invalid dest bc path"); println!("Compiling bitcode to: {}", dest_bc); @@ -78,6 +86,26 @@ where } } +fn run_command_with_no_args>(path: P, command_str: &str) +{ + let output_result = Command::new(OsStr::new(&command_str)) + .current_dir(path) + .output(); + match output_result { + Ok(output) => match output.status.success() { + true => (), + false => { + let error_str = match str::from_utf8(&output.stderr) { + Ok(stderr) => stderr.to_string(), + Err(_) => format!("Failed to run \"{}\"", command_str), + }; + panic!("{} failed: {}", command_str, error_str); + } + }, + Err(reason) => panic!("{} failed: {}", command_str, reason), + } +} + fn get_zig_files(dir: &Path, cb: &dyn Fn(&Path)) -> io::Result<()> { if dir.is_dir() { for entry in fs::read_dir(dir)? { diff --git a/shell.nix b/shell.nix index 10c965b2e8..7b7d61fd55 100644 --- a/shell.nix +++ b/shell.nix @@ -1,116 +1,116 @@ -{ }: +{}: let splitSystem = builtins.split "-" builtins.currentSystem; currentArch = builtins.elemAt splitSystem 0; currentOS = builtins.elemAt splitSystem 2; -in with { - # Look here for information about how pin version of nixpkgs - # → https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs - pkgs = import (builtins.fetchGit { - name = "nixpkgs-2021-04-23"; - url = "https://github.com/nixos/nixpkgs/"; - ref = "refs/heads/nixpkgs-unstable"; - rev = "8d0340aee5caac3807c58ad7fa4ebdbbdd9134d6"; - }) { }; - - isMacOS = currentOS == "darwin"; - isLinux = currentOS == "linux"; - isAarch64 = currentArch == "aarch64"; -}; - -with (pkgs); - -let - darwin-inputs = - if isMacOS then - with pkgs.darwin.apple_sdk.frameworks; [ - AppKit - CoreFoundation - CoreServices - CoreVideo - Foundation - Metal - Security - ] - else - [ ]; - - linux-inputs = - if isLinux then - [ - valgrind - vulkan-headers - vulkan-loader - vulkan-tools - vulkan-validation-layers - xorg.libX11 - xorg.libXcursor - xorg.libXrandr - xorg.libXi - xorg.libxcb - ] - else - [ ]; - - nixos-env = - if isLinux && builtins.pathExists /etc/nixos/configuration.nix then - { XDG_DATA_DIRS = "/run/opengl-driver/share:$XDG_DATA_DIRS"; +in + with { + # Look here for information about how pin version of nixpkgs + # → https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs + pkgs = import ( + builtins.fetchGit { + # name = "nixpkgs-2021-04-23"; + url = "https://github.com/nixos/nixpkgs/"; + ref = "refs/heads/nixpkgs-unstable"; + rev = "8d0340aee5caac3807c58ad7fa4ebdbbdd9134d6"; } - else - { }; + ) {}; - llvmPkgs = pkgs.llvmPackages_10; - zig = import ./nix/zig.nix { inherit pkgs isMacOS isAarch64; }; - inputs = [ - # build libraries - rustc - cargo - clippy - rustfmt - cmake - git - python3 - llvmPkgs.llvm - llvmPkgs.clang - pkg-config - zig - # lib deps - llvmPkgs.libcxx - llvmPkgs.libcxxabi - libffi - libunwind - libxml2 - ncurses - zlib - libiconv - # faster builds - see https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker - llvmPkgs.lld - # dev tools - # rust-analyzer - # (import ./nix/zls.nix { inherit pkgs zig; }) - ]; + isMacOS = currentOS == "darwin"; + isLinux = currentOS == "linux"; + isAarch64 = currentArch == "aarch64"; + }; -in mkShell (nixos-env // { - buildInputs = inputs ++ darwin-inputs ++ linux-inputs; + with (pkgs); - # Additional Env vars - LLVM_SYS_100_PREFIX = "${llvmPkgs.llvm}"; - LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath - ([ + let + darwin-inputs = + if isMacOS then + with pkgs.darwin.apple_sdk.frameworks; [ + AppKit + CoreFoundation + CoreServices + CoreVideo + Foundation + Metal + Security + ] + else + []; + + linux-inputs = + if isLinux then + [ + valgrind + vulkan-headers + vulkan-loader + vulkan-tools + vulkan-validation-layers + xorg.libX11 + xorg.libXcursor + xorg.libXrandr + xorg.libXi + xorg.libxcb + ] + else + []; + + llvmPkgs = pkgs.llvmPackages_10; + zig = import ./nix/zig.nix { inherit pkgs isMacOS isAarch64; }; + inputs = [ + # build libraries + rustc + cargo + clippy + rustfmt + cmake + git + python3 + llvmPkgs.llvm + llvmPkgs.clang pkg-config - stdenv.cc.cc.lib + zig + # lib deps llvmPkgs.libcxx llvmPkgs.libcxxabi - libunwind libffi + libunwind + libxml2 ncurses zlib - ] ++ linux-inputs); + libiconv + # faster builds - see https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker + llvmPkgs.lld + # dev tools + # rust-analyzer + # (import ./nix/zls.nix { inherit pkgs zig; }) + ]; - # Aliases don't work cross shell, so we do this - shellHook = '' - export PATH="$PATH:$PWD/nix/bin" - ''; -}) + in + mkShell ( + { + buildInputs = inputs ++ darwin-inputs ++ linux-inputs; + # Additional Env vars + LLVM_SYS_100_PREFIX = "${llvmPkgs.llvm}"; + LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath + ( + [ + pkg-config + stdenv.cc.cc.lib + llvmPkgs.libcxx + llvmPkgs.libcxxabi + libunwind + libffi + ncurses + zlib + ] ++ linux-inputs + ); + + # Aliases don't work cross shell, so we do this + shellHook = '' + export PATH="$PATH:$PWD/nix/bin" + ''; + } + ) From 3105f09b2f97854f9c0ddc4ddc19ebe487cf21e7 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 29 May 2021 20:44:53 +0200 Subject: [PATCH 11/16] use empty tag union for tag union with no members --- compiler/mono/src/layout.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/mono/src/layout.rs b/compiler/mono/src/layout.rs index e7af14e26e..5a266857ad 100644 --- a/compiler/mono/src/layout.rs +++ b/compiler/mono/src/layout.rs @@ -276,7 +276,8 @@ impl<'a> LambdaSet<'a> { use UnionVariant::*; match variant { - Never | Unit | UnitWithArguments => Layout::Struct(&[]), + Never => Layout::Union(UnionLayout::NonRecursive(&[])), + Unit | UnitWithArguments => Layout::Struct(&[]), BoolUnion { .. } => Layout::Builtin(Builtin::Int1), ByteUnion(_) => Layout::Builtin(Builtin::Int8), Unwrapped(_tag_name, layouts) => Layout::Struct(layouts.into_bump_slice()), From a77b5504d832b0182788541fdc92866b9fa853ef Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 29 May 2021 20:48:57 +0200 Subject: [PATCH 12/16] force imported thunks when used --- compiler/mono/src/ir.rs | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 4bedd2dae6..02e66bd79e 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -5928,35 +5928,48 @@ fn reuse_function_symbol<'a>( ) -> Stmt<'a> { match procs.partial_procs.get(&original) { None => { - let is_imported = env.is_imported_symbol(original); - match arg_var { - Some(arg_var) if is_imported => { + Some(arg_var) if env.is_imported_symbol(original) => { let layout = layout_cache .from_var(env.arena, arg_var, env.subs) .expect("creating layout does not fail"); - let top_level = TopLevelFunctionLayout::from_layout(env.arena, layout); + if procs.imported_module_thunks.contains(&original) { + let top_level = TopLevelFunctionLayout::new(env.arena, &[], layout); + procs.insert_passed_by_name( + env, + arg_var, + original, + top_level, + layout_cache, + ); - procs.insert_passed_by_name(env, arg_var, original, top_level, layout_cache); + force_thunk(env, original, layout, symbol, env.arena.alloc(result)) + } else { + let top_level = TopLevelFunctionLayout::from_layout(env.arena, layout); + procs.insert_passed_by_name( + env, + arg_var, + original, + top_level, + layout_cache, + ); - // an imported symbol is either a function, or a top-level 0-argument thunk - // it never has closure data, so we use the empty struct - return let_empty_struct(symbol, env.arena.alloc(result)); + let_empty_struct(symbol, env.arena.alloc(result)) + } } _ => { // danger: a foreign symbol may not be specialized! debug_assert!( - !is_imported, + !env.is_imported_symbol(original), "symbol {:?} while processing module {:?}", original, (env.home, &arg_var), ); + result } } - - result } Some(partial_proc) => { From 551c9355a66a601c3a46995f979973ad03d1f6e7 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 29 May 2021 20:57:27 +0200 Subject: [PATCH 13/16] run rustfmt --- compiler/builtins/build.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/compiler/builtins/build.rs b/compiler/builtins/build.rs index 57ec6d7a71..c621196cb9 100644 --- a/compiler/builtins/build.rs +++ b/compiler/builtins/build.rs @@ -24,14 +24,14 @@ fn main() { let dest_ir = dest_ir_path.to_str().expect("Invalid dest ir path"); if use_build_script { - println!("Compiling zig object & ir to: {} and {}", src_obj, dest_ir); - run_command_with_no_args(&bitcode_path, "./build.sh"); + println!("Compiling zig object & ir to: {} and {}", src_obj, dest_ir); + run_command_with_no_args(&bitcode_path, "./build.sh"); } else { - println!("Compiling zig object to: {}", src_obj); - run_command(&bitcode_path, "zig", &["build", "object", "-Drelease=true"]); + println!("Compiling zig object to: {}", src_obj); + run_command(&bitcode_path, "zig", &["build", "object", "-Drelease=true"]); - println!("Compiling ir to: {}", dest_ir); - run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]); + println!("Compiling ir to: {}", dest_ir); + run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]); } let dest_obj_path = Path::new(&out_dir).join("builtins.o"); @@ -86,8 +86,7 @@ where } } -fn run_command_with_no_args>(path: P, command_str: &str) -{ +fn run_command_with_no_args>(path: P, command_str: &str) { let output_result = Command::new(OsStr::new(&command_str)) .current_dir(path) .output(); From 3636e18a181319546fee8afb1e01c895c3865ad3 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 29 May 2021 21:46:33 +0200 Subject: [PATCH 14/16] centralize inkwell imports --- Cargo.lock | 347 +++++++++++++++++++---------------- Cargo.toml | 1 + cli/Cargo.toml | 19 +- compiler/build/Cargo.toml | 19 +- compiler/gen/Cargo.toml | 19 +- compiler/test_gen/Cargo.toml | 19 +- vendor/inkwell/Cargo.toml | 31 ++++ vendor/inkwell/src/lib.rs | 4 + 8 files changed, 225 insertions(+), 234 deletions(-) create mode 100644 vendor/inkwell/Cargo.toml create mode 100644 vendor/inkwell/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 17ae544bde..0323839957 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "ab_glyph" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a933731feda8b460bdad9a9e43bb386baba6ec593d2bc19716ef3c75c09085c" +checksum = "af0ac006645f86f20f6c6fa4dcaef920bf803df819123626f9440e35835e7d80" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser 0.12.0", @@ -18,9 +18,9 @@ checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff" [[package]] name = "addr2line" -version = "0.14.1" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" dependencies = [ "gimli", ] @@ -39,20 +39,20 @@ checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "ahash" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" dependencies = [ - "getrandom 0.2.2", + "getrandom 0.2.3", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] @@ -153,15 +153,16 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.56" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ "addr2line", + "cc", "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.23.0", + "object", "rustc-demangle", ] @@ -233,9 +234,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "lazy_static", "memchr", @@ -245,9 +246,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" [[package]] name = "byte-tools" @@ -270,7 +271,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -299,18 +300,18 @@ dependencies = [ [[package]] name = "cast" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc38c385bfd7e444464011bb24820f40dd1c76bcdfa1b78611cb7c2e5cafab75" +checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" dependencies = [ "rustc_version", ] [[package]] name = "cc" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" dependencies = [ "jobserver", ] @@ -378,7 +379,7 @@ source = "git+https://github.com/rtfeldman/clap?branch=master#e1d83a78804a271b05 dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -457,7 +458,7 @@ dependencies = [ [[package]] name = "confy" version = "0.4.0" -source = "git+https://github.com/rust-cli/confy#0f0c452d652e85674348d9ad6e54bbdebbbd848a" +source = "git+https://github.com/rust-cli/confy#6ae700bb0e6e2f9f7138d0c1871f604013c8f59f" dependencies = [ "directories-next", "serde", @@ -479,9 +480,9 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29c36c619c422113552db4eb28cddba8faa757e33f758cc3415bd2885977b591" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", - "unicode-xid 0.2.1", + "unicode-xid 0.2.2", ] [[package]] @@ -588,9 +589,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec1028182c380cc45a2e2c5ec841134f2dfd0f8f5f0a5bcd68004f81b5efdf4" +checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" dependencies = [ "libc", ] @@ -671,7 +672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", ] [[package]] @@ -692,8 +693,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.3", - "crossbeam-utils 0.8.3", + "crossbeam-epoch 0.9.4", + "crossbeam-utils 0.8.4", ] [[package]] @@ -713,14 +714,14 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +checksum = "52fb27eab85b17fbb9f6fd667089e07d6a2eb8743d02639ee7f6a7a7729c9c94" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", "lazy_static", - "memoffset 0.6.3", + "memoffset 0.6.4", "scopeguard", ] @@ -748,9 +749,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" dependencies = [ "autocfg 1.0.1", "cfg-if 1.0.0", @@ -818,7 +819,7 @@ checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "strsim", "syn 1.0.72", @@ -841,7 +842,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -1053,9 +1054,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253" +checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" dependencies = [ "futures-channel", "futures-core", @@ -1068,9 +1069,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25" +checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" dependencies = [ "futures-core", "futures-sink", @@ -1078,15 +1079,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" +checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" [[package]] name = "futures-executor" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d" +checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79" dependencies = [ "futures-core", "futures-task", @@ -1095,40 +1096,42 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04" +checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" [[package]] name = "futures-macro" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b" +checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" dependencies = [ + "autocfg 1.0.1", "proc-macro-hack", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] [[package]] name = "futures-sink" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23" +checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" [[package]] name = "futures-task" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" +checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" [[package]] name = "futures-util" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025" +checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" dependencies = [ + "autocfg 1.0.1", "futures-channel", "futures-core", "futures-io", @@ -1184,9 +1187,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1341,9 +1344,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" [[package]] name = "glow" @@ -1398,9 +1401,9 @@ dependencies = [ [[package]] name = "gpu-alloc" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76088804bb65a6f3b880bea9306fdaeffb25ebb453105fafa691282ee9fdba" +checksum = "cbc1b6ca374e81862526786d9cb42357ce03706ed1b8761730caafd02ab91f3a" dependencies = [ "bitflags", "gpu-alloc-types", @@ -1456,7 +1459,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.2", + "ahash 0.7.4", "bumpalo", ] @@ -1513,7 +1516,7 @@ dependencies = [ "bitmaps", "rand_core 0.5.1", "rand_xoshiro", - "sized-chunks 0.6.4", + "sized-chunks 0.6.5", "typenum", "version_check", ] @@ -1541,7 +1544,7 @@ dependencies = [ "bitmaps", "rand_core 0.5.1", "rand_xoshiro", - "sized-chunks 0.6.4", + "sized-chunks 0.6.5", "typenum", "version_check", ] @@ -1582,12 +1585,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", "unindent", ] +[[package]] +name = "inkwell" +version = "0.1.0" +dependencies = [ + "inkwell 0.1.0 (git+https://github.com/rtfeldman/inkwell?tag=llvm10-0.release4)", +] + [[package]] name = "inkwell" version = "0.1.0" @@ -1607,7 +1617,7 @@ name = "inkwell_internals" version = "0.3.0" source = "git+https://github.com/rtfeldman/inkwell?tag=llvm10-0.release4#9ae45f072645165885b2f347a4c0cc5ce9e22c80" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -1674,9 +1684,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" dependencies = [ "libc", ] @@ -1730,9 +1740,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" +checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" [[package]] name = "libloading" @@ -1770,14 +1780,14 @@ dependencies = [ "lazy_static", "libc", "regex", - "semver", + "semver 0.9.0", ] [[package]] name = "lock_api" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" dependencies = [ "scopeguard", ] @@ -1814,9 +1824,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memmap2" @@ -1838,9 +1848,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg 1.0.1", ] @@ -1922,9 +1932,9 @@ dependencies = [ [[package]] name = "naga" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f470a97eafcdd0dbea43d5e1a8ef3557aa31f49ba643d9430dbbf911c162b24c" +checksum = "c8d74f2c7ace793a760165ac0679d6830809ad4e85f6886f72e4f8c4aa4291c5" dependencies = [ "bit-set", "bitflags", @@ -1971,7 +1981,7 @@ checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" dependencies = [ "darling", "proc-macro-crate", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -2082,7 +2092,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -2126,12 +2136,6 @@ dependencies = [ "objc", ] -[[package]] -name = "object" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" - [[package]] name = "object" version = "0.24.0" @@ -2169,11 +2173,12 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "ordered-float" -version = "2.1.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766f840da25490628d8e63e529cd21c014f6600c6b8517add12a6fa6167a6218" +checksum = "809348965973b261c3e504c8d0434e465274f78c880e10039914f2c5dcf49461" dependencies = [ "num-traits", + "rand 0.8.3", ] [[package]] @@ -2200,7 +2205,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a3c7a20e3f122223e68eef6ca58e39bc1ea8a1d83418ba4c2c1ba189d2ee355" dependencies = [ - "ttf-parser 0.12.0", + "ttf-parser 0.12.1", ] [[package]] @@ -2232,7 +2237,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b4b5f600e60dd3a147fb57b4547033d382d1979eb087af310e91cb45a63b1f4" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -2259,7 +2264,7 @@ dependencies = [ "instant", "libc", "petgraph", - "redox_syscall 0.2.5", + "redox_syscall 0.2.8", "smallvec", "thread-id", "winapi 0.3.9", @@ -2298,7 +2303,7 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -2458,7 +2463,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", "version_check", @@ -2470,7 +2475,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", "syn-mid", @@ -2500,11 +2505,11 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ - "unicode-xid 0.2.1", + "unicode-xid 0.2.2", ] [[package]] @@ -2564,7 +2569,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -2584,7 +2589,7 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", ] [[package]] @@ -2692,7 +2697,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ - "getrandom 0.2.2", + "getrandom 0.2.3", ] [[package]] @@ -2810,9 +2815,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg 1.0.1", "crossbeam-deque 0.8.0", @@ -2822,13 +2827,13 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel 0.5.1", "crossbeam-deque 0.8.0", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", "lazy_static", "num_cpus", ] @@ -2850,9 +2855,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" dependencies = [ "bitflags", ] @@ -2863,15 +2868,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.2", - "redox_syscall 0.2.5", + "getrandom 0.2.3", + "redox_syscall 0.2.8", ] [[package]] name = "regex" -version = "1.4.5" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", @@ -2889,9 +2894,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "remove_dir_all" @@ -2910,7 +2915,7 @@ dependencies = [ "im 14.3.0", "im-rc 14.3.0", "indoc 0.3.6", - "inkwell", + "inkwell 0.1.0", "inlinable_string", "libloading 0.6.7", "maplit", @@ -2985,7 +2990,7 @@ dependencies = [ "im 14.3.0", "im-rc 14.3.0", "indoc 0.3.6", - "inkwell", + "inkwell 0.1.0", "inlinable_string", "libc", "libloading 0.6.7", @@ -3147,7 +3152,7 @@ dependencies = [ "im 14.3.0", "im-rc 14.3.0", "indoc 0.3.6", - "inkwell", + "inkwell 0.1.0", "inlinable_string", "libc", "maplit", @@ -3186,7 +3191,7 @@ dependencies = [ "libc", "libloading 0.6.7", "maplit", - "object 0.24.0", + "object", "pretty_assertions 0.5.1", "quickcheck 0.8.5", "quickcheck_macros 0.8.0", @@ -3420,9 +3425,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" [[package]] name = "rustc-hash" @@ -3432,11 +3437,11 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" -version = "0.2.3" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver", + "semver 0.11.0", ] [[package]] @@ -3509,7 +3514,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser", + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", ] [[package]] @@ -3519,10 +3533,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] -name = "serde" -version = "1.0.125" +name = "semver-parser" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" dependencies = [ "serde_derive", ] @@ -3551,11 +3574,11 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -3600,7 +3623,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -3619,9 +3642,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f6b75b17576b792bef0db1bcc4b8b8bcdf9506744cf34b974195487af6cff2" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", @@ -3648,9 +3671,9 @@ dependencies = [ [[package]] name = "sized-chunks" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e65d6a9f13cd78f361ea5a2cf53a45d67cdda421ba0316b9be101560f3d207" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" dependencies = [ "bitmaps", "typenum", @@ -3658,9 +3681,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" [[package]] name = "slotmap" @@ -3720,7 +3743,7 @@ version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -3793,9 +3816,9 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", - "unicode-xid 0.2.1", + "unicode-xid 0.2.2", ] [[package]] @@ -3804,7 +3827,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -3815,10 +3838,10 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", - "unicode-xid 0.2.1", + "unicode-xid 0.2.2", ] [[package]] @@ -3836,7 +3859,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "rand 0.8.3", - "redox_syscall 0.2.5", + "redox_syscall 0.2.8", "remove_dir_all", "winapi 0.3.9", ] @@ -3859,7 +3882,7 @@ dependencies = [ "im 14.3.0", "im-rc 14.3.0", "indoc 0.3.6", - "inkwell", + "inkwell 0.1.0", "inlinable_string", "libc", "libloading 0.6.7", @@ -3898,20 +3921,20 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", ] @@ -3974,9 +3997,9 @@ checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc" [[package]] name = "ttf-parser" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e00391c1f3d171490a3f8bd79999b0002ae38d3da0d6a3a306c754b053d71b" +checksum = "2fc71742ead70703a55d184f82087302f2f9ffa3793e64db46a78bf75dd723f4" [[package]] name = "twox-hash" @@ -4036,9 +4059,9 @@ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unindent" @@ -4153,7 +4176,7 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", "wasm-bindgen-shared", @@ -4187,7 +4210,7 @@ version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "syn 1.0.72", "wasm-bindgen-backend", @@ -4257,7 +4280,7 @@ version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "389d680d7bd67512dc9c37f39560224327038deb0f0e8d33f870900441b68720" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "quote 1.0.9", "xml-rs", ] @@ -4458,9 +4481,9 @@ dependencies = [ [[package]] name = "x11-clipboard" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5e937afd03b64b7be4f959cc044e09260a47241b71e56933f37db097bf7859d" +checksum = "b397ace6e980510de59a4fe3d4c758dffab231d6d747ce9fa1aba6b6035d5f32" dependencies = [ "xcb", ] @@ -4539,7 +4562,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d498dbd1fd7beb83c86709ae1c33ca50942889473473d287d56ce4770a18edfb" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2 1.0.27", "syn 1.0.72", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 8343f413ed..9edcc5aeb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ members = [ "compiler/arena_pool", "compiler/test_gen", "vendor/ena", + "vendor/inkwell", "vendor/pathfinding", "vendor/pretty", "editor", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 007d67b699..fd4b35aa7a 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -62,24 +62,7 @@ inlinable_string = "0.1" libc = "0.2" libloading = "0.6" -# NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything. -# -# The reason for this fork is that the way Inkwell is designed, you have to use -# a particular branch (e.g. "llvm8-0") in Cargo.toml. That would be fine, except that -# breaking changes get pushed directly to that branch, which breaks our build -# without warning. -# -# We tried referencing a specific rev on TheDan64/inkwell directly (instead of branch), -# but although that worked locally, it did not work on GitHub Actions. (After a few -# hours of investigation, gave up trying to figure out why.) So this is the workaround: -# having an immutable tag on the rtfeldman/inkwell fork which points to -# a particular "release" of Inkwell. -# -# When we want to update Inkwell, we can sync up rtfeldman/inkwell to the latest -# commit of TheDan64/inkwell, push a new tag which points to the latest commit, -# change the tag value in this Cargo.toml to point to that tag, and `cargo update`. -# This way, GitHub Actions works and nobody's builds get broken. -inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release4", features = [ "llvm10-0" ] } +inkwell = { path = "../vendor/inkwell" } target-lexicon = "0.10" tempfile = "3.1.0" diff --git a/compiler/build/Cargo.toml b/compiler/build/Cargo.toml index a7f173d2e2..aa3a13f3d8 100644 --- a/compiler/build/Cargo.toml +++ b/compiler/build/Cargo.toml @@ -28,24 +28,7 @@ inlinable_string = "0.1.0" libloading = "0.6" tempfile = "3.1.0" serde_json = "1.0" -# NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything. -# -# The reason for this fork is that the way Inkwell is designed, you have to use -# a particular branch (e.g. "llvm8-0") in Cargo.toml. That would be fine, except that -# breaking changes get pushed directly to that branch, which breaks our build -# without warning. -# -# We tried referencing a specific rev on TheDan64/inkwell directly (instead of branch), -# but although that worked locally, it did not work on GitHub Actions. (After a few -# hours of investigation, gave up trying to figure out why.) So this is the workaround: -# having an immutable tag on the rtfeldman/inkwell fork which points to -# a particular "release" of Inkwell. -# -# When we want to update Inkwell, we can sync up rtfeldman/inkwell to the latest -# commit of TheDan64/inkwell, push a new tag which points to the latest commit, -# change the tag value in this Cargo.toml to point to that tag, and `cargo update`. -# This way, GitHub Actions works and nobody's builds get broken. -inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release4", features = [ "llvm10-0" ] } +inkwell = { path = "../../vendor/inkwell" } target-lexicon = "0.10" [dev-dependencies] diff --git a/compiler/gen/Cargo.toml b/compiler/gen/Cargo.toml index e6ad3aaf21..685b00fa3a 100644 --- a/compiler/gen/Cargo.toml +++ b/compiler/gen/Cargo.toml @@ -20,24 +20,7 @@ im-rc = "14" # im and im-rc should always have the same version! bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" either = "1.6.1" -# NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything. -# -# The reason for this fork is that the way Inkwell is designed, you have to use -# a particular branch (e.g. "llvm8-0") in Cargo.toml. That would be fine, except that -# breaking changes get pushed directly to that branch, which breaks our build -# without warning. -# -# We tried referencing a specific rev on TheDan64/inkwell directly (instead of branch), -# but although that worked locally, it did not work on GitHub Actions. (After a few -# hours of investigation, gave up trying to figure out why.) So this is the workaround: -# having an immutable tag on the rtfeldman/inkwell fork which points to -# a particular "release" of Inkwell. -# -# When we want to update Inkwell, we can sync up rtfeldman/inkwell to the latest -# commit of TheDan64/inkwell, push a new tag which points to the latest commit, -# change the tag value in this Cargo.toml to point to that tag, and `cargo update`. -# This way, GitHub Actions works and nobody's builds get broken. -inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release4", features = [ "llvm10-0" ] } +inkwell = { path = "../../vendor/inkwell" } target-lexicon = "0.10" [dev-dependencies] diff --git a/compiler/test_gen/Cargo.toml b/compiler/test_gen/Cargo.toml index 61058dd120..7300d3ee57 100644 --- a/compiler/test_gen/Cargo.toml +++ b/compiler/test_gen/Cargo.toml @@ -30,24 +30,7 @@ inlinable_string = "0.1" either = "1.6.1" indoc = "0.3.3" libc = "0.2" -# NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything. -# -# The reason for this fork is that the way Inkwell is designed, you have to use -# a particular branch (e.g. "llvm8-0") in Cargo.toml. That would be fine, except that -# breaking changes get pushed directly to that branch, which breaks our build -# without warning. -# -# We tried referencing a specific rev on TheDan64/inkwell directly (instead of branch), -# but although that worked locally, it did not work on GitHub Actions. (After a few -# hours of investigation, gave up trying to figure out why.) So this is the workaround: -# having an immutable tag on the rtfeldman/inkwell fork which points to -# a particular "release" of Inkwell. -# -# When we want to update Inkwell, we can sync up rtfeldman/inkwell to the latest -# commit of TheDan64/inkwell, push a new tag which points to the latest commit, -# change the tag value in this Cargo.toml to point to that tag, and `cargo update`. -# This way, GitHub Actions works and nobody's builds get broken. -inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release4", features = [ "llvm10-0" ] } +inkwell = { path = "../../vendor/inkwell" } target-lexicon = "0.10" libloading = "0.6" diff --git a/vendor/inkwell/Cargo.toml b/vendor/inkwell/Cargo.toml new file mode 100644 index 0000000000..0aecbc592d --- /dev/null +++ b/vendor/inkwell/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "inkwell" +version = "0.1.0" +authors = ["The Roc Contributors"] +license = "UPL-1.0" +edition = "2018" + +[dependencies] +# NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything. +# +# The reason for this fork is that the way Inkwell is designed, you have to use +# a particular branch (e.g. "llvm8-0") in Cargo.toml. That would be fine, except that +# breaking changes get pushed directly to that branch, which breaks our build +# without warning. +# +# We tried referencing a specific rev on TheDan64/inkwell directly (instead of branch), +# but although that worked locally, it did not work on GitHub Actions. (After a few +# hours of investigation, gave up trying to figure out why.) So this is the workaround: +# having an immutable tag on the rtfeldman/inkwell fork which points to +# a particular "release" of Inkwell. +# +# When we want to update Inkwell, we can sync up rtfeldman/inkwell to the latest +# commit of TheDan64/inkwell, push a new tag which points to the latest commit, +# change the tag value in this Cargo.toml to point to that tag, and `cargo update`. +# This way, GitHub Actions works and nobody's builds get broken. +inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release4", features = [ "llvm10-0" ] } + +[features] +target-arm = [] +target-aarch64 = [] +target-webassembly = [] diff --git a/vendor/inkwell/src/lib.rs b/vendor/inkwell/src/lib.rs new file mode 100644 index 0000000000..8136cc5eae --- /dev/null +++ b/vendor/inkwell/src/lib.rs @@ -0,0 +1,4 @@ +#![cfg(not(doctest))] +// re-export all inkwell members. This way we can switch +// inkwell versions by making changes in just one place. +pub use inkwell::*; From 22a4df0e5ea9ace9427e830114de99002322fd59 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 30 May 2021 16:48:42 +0200 Subject: [PATCH 15/16] add test_mono_macros crate --- Cargo.lock | 27 ++++++++++++++++ Cargo.toml | 1 + compiler/test_mono_macros/Cargo.toml | 36 ++++++++++++++++++++++ compiler/test_mono_macros/src/lib.rs | 46 ++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 compiler/test_mono_macros/Cargo.toml create mode 100644 compiler/test_mono_macros/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 0323839957..d3570eaf93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3910,6 +3910,33 @@ dependencies = [ "tokio", ] +[[package]] +name = "test_mono_macros" +version = "0.1.0" +dependencies = [ + "darling", + "indoc 0.3.6", + "maplit", + "pretty_assertions 0.5.1", + "proc-macro2 1.0.27", + "quickcheck 0.8.5", + "quickcheck_macros 0.8.0", + "quote 1.0.9", + "roc_builtins", + "roc_can", + "roc_collections", + "roc_load", + "roc_module", + "roc_mono", + "roc_parse", + "roc_problem", + "roc_region", + "roc_solve", + "roc_types", + "roc_unify", + "syn 1.0.72", +] + [[package]] name = "textwrap" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index 9edcc5aeb9..59e32522ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "compiler/reporting", "compiler/fmt", "compiler/mono", + "compiler/test_mono_macros", "compiler/load", "compiler/gen", "compiler/gen_dev", diff --git a/compiler/test_mono_macros/Cargo.toml b/compiler/test_mono_macros/Cargo.toml new file mode 100644 index 0000000000..d5243127b6 --- /dev/null +++ b/compiler/test_mono_macros/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "test_mono_macros" +version = "0.1.0" +authors = ["The Roc Contributors"] +license = "UPL-1.0" +edition = "2018" + +[lib] +proc-macro = true + +[dependencies] +roc_collections = { path = "../collections" } +roc_region = { path = "../region" } +roc_module = { path = "../module" } +roc_types = { path = "../types" } +roc_can = { path = "../can" } +roc_unify = { path = "../unify" } +roc_solve = { path = "../solve" } +roc_problem = { path = "../problem" } +roc_mono = { path = "../mono" } + +syn = { version = "1.0.39", features = ["full", "extra-traits"] } +quote = "1.0.7" +darling = "0.10.2" +proc-macro2 = "1.0.24" + +[dev-dependencies] +roc_load= { path = "../load" } +roc_builtins = { path = "../builtins" } +roc_parse = { path = "../parse" } +roc_solve = { path = "../solve" } +pretty_assertions = "0.5.1" +maplit = "1.0.1" +indoc = "0.3.3" +quickcheck = "0.8" +quickcheck_macros = "0.8" diff --git a/compiler/test_mono_macros/src/lib.rs b/compiler/test_mono_macros/src/lib.rs new file mode 100644 index 0000000000..978c922117 --- /dev/null +++ b/compiler/test_mono_macros/src/lib.rs @@ -0,0 +1,46 @@ +#![warn(clippy::dbg_macro)] +// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. +#![allow(clippy::large_enum_variant)] +// we actually want to compare against the literal float bits +#![allow(clippy::clippy::float_cmp)] + +extern crate proc_macro; + +use proc_macro::{Span, TokenStream}; +use quote::{format_ident, quote}; +use syn::spanned::Spanned; + +// pub mod gen_compare; +// pub mod gen_dict; +// pub mod gen_hash; +// pub mod gen_list; +// pub mod gen_num; +// pub mod gen_primitives; +// pub mod gen_records; +// pub mod gen_result; +// pub mod gen_set; +// pub mod gen_str; +// pub mod gen_tags; +// mod helpers; + +#[proc_macro_attribute] +pub fn mono_test(args: TokenStream, item: TokenStream) -> TokenStream { + let macro_args = syn::parse_macro_input!(args as syn::AttributeArgs); + let task_fn = syn::parse_macro_input!(item as syn::ItemFn); + + let mut arg_names: syn::punctuated::Punctuated = + syn::punctuated::Punctuated::new(); + let mut args = task_fn.sig.inputs.clone(); + + let name = task_fn.sig.ident.clone(); + let body = task_fn.block.clone(); + + let visibility = &task_fn.vis; + + let result = quote! { + #visibility fn #name(#args) { + println!( #body); + } + }; + result.into() +} From 54057c90b8d87fdc80cab59af5846a928ff0d31b Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 30 May 2021 18:09:41 +0200 Subject: [PATCH 16/16] new mono testing mechanism --- Cargo.lock | 27 ++- Cargo.toml | 1 + compiler/test_mono/Cargo.toml | 40 ++++ compiler/test_mono/generated/ir_int_add.txt | 25 +++ .../test_mono/generated/ir_int_literal.txt | 3 + compiler/test_mono/src/lib.rs | 184 ++++++++++++++++++ compiler/test_mono_macros/Cargo.toml | 21 -- compiler/test_mono_macros/src/lib.rs | 38 +--- 8 files changed, 284 insertions(+), 55 deletions(-) create mode 100644 compiler/test_mono/Cargo.toml create mode 100644 compiler/test_mono/generated/ir_int_add.txt create mode 100644 compiler/test_mono/generated/ir_int_literal.txt create mode 100644 compiler/test_mono/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d3570eaf93..b933971a45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3911,29 +3911,46 @@ dependencies = [ ] [[package]] -name = "test_mono_macros" +name = "test_mono" version = "0.1.0" dependencies = [ - "darling", + "bumpalo", + "either", + "im 14.3.0", + "im-rc 14.3.0", "indoc 0.3.6", - "maplit", + "inlinable_string", + "libc", + "libloading 0.6.7", "pretty_assertions 0.5.1", - "proc-macro2 1.0.27", "quickcheck 0.8.5", "quickcheck_macros 0.8.0", - "quote 1.0.9", + "roc_build", "roc_builtins", "roc_can", "roc_collections", + "roc_constrain", "roc_load", "roc_module", "roc_mono", "roc_parse", "roc_problem", "roc_region", + "roc_reporting", "roc_solve", "roc_types", "roc_unify", + "target-lexicon", + "test_mono_macros", +] + +[[package]] +name = "test_mono_macros" +version = "0.1.0" +dependencies = [ + "darling", + "proc-macro2 1.0.27", + "quote 1.0.9", "syn 1.0.72", ] diff --git a/Cargo.toml b/Cargo.toml index 59e32522ff..258be502a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ members = [ "compiler/fmt", "compiler/mono", "compiler/test_mono_macros", + "compiler/test_mono", "compiler/load", "compiler/gen", "compiler/gen_dev", diff --git a/compiler/test_mono/Cargo.toml b/compiler/test_mono/Cargo.toml new file mode 100644 index 0000000000..60f3c78a33 --- /dev/null +++ b/compiler/test_mono/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "test_mono" +version = "0.1.0" +authors = ["The Roc Contributors"] +license = "UPL-1.0" +edition = "2018" + +[dependencies] +roc_collections = { path = "../collections" } +roc_region = { path = "../region" } +roc_module = { path = "../module" } +roc_problem = { path = "../problem" } +roc_types = { path = "../types" } +roc_builtins = { path = "../builtins" } +roc_constrain = { path = "../constrain" } +roc_unify = { path = "../unify" } +roc_solve = { path = "../solve" } +roc_reporting = { path = "../reporting" } +roc_load = { path = "../load" } +roc_can = { path = "../can" } +roc_parse = { path = "../parse" } +roc_build = { path = "../build" } +roc_mono = { path = "../mono" } +test_mono_macros = { path = "../test_mono_macros" } +im = "14" # im and im-rc should always have the same version! +im-rc = "14" # im and im-rc should always have the same version! +bumpalo = { version = "3.6.1", features = ["collections"] } +inlinable_string = "0.1" +either = "1.6.1" +indoc = "0.3.3" +libc = "0.2" +target-lexicon = "0.10" +libloading = "0.6" + +[dev-dependencies] +pretty_assertions = "0.5.1" +indoc = "0.3.3" +quickcheck = "0.8" +quickcheck_macros = "0.8" +bumpalo = { version = "3.6.1", features = ["collections"] } diff --git a/compiler/test_mono/generated/ir_int_add.txt b/compiler/test_mono/generated/ir_int_add.txt new file mode 100644 index 0000000000..4b427ffaee --- /dev/null +++ b/compiler/test_mono/generated/ir_int_add.txt @@ -0,0 +1,25 @@ +procedure List.7 (#Attr.2): + let Test.6 = lowlevel ListLen #Attr.2; + ret Test.6; + +procedure Num.24 (#Attr.2, #Attr.3): + let Test.5 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Test.5; + +procedure Test.0 (): + let Test.11 = 1i64; + let Test.12 = 2i64; + let Test.1 = Array [Test.11, Test.12]; + let Test.9 = 5i64; + let Test.10 = 4i64; + invoke Test.7 = CallByName Num.24 Test.9 Test.10 catch + dec Test.1; + unreachable; + let Test.8 = 3i64; + invoke Test.3 = CallByName Num.24 Test.7 Test.8 catch + dec Test.1; + unreachable; + let Test.4 = CallByName List.7 Test.1; + dec Test.1; + let Test.2 = CallByName Num.24 Test.3 Test.4; + ret Test.2; diff --git a/compiler/test_mono/generated/ir_int_literal.txt b/compiler/test_mono/generated/ir_int_literal.txt new file mode 100644 index 0000000000..755d390183 --- /dev/null +++ b/compiler/test_mono/generated/ir_int_literal.txt @@ -0,0 +1,3 @@ +procedure Test.0 (): + let Test.1 = 5i64; + ret Test.1; diff --git a/compiler/test_mono/src/lib.rs b/compiler/test_mono/src/lib.rs new file mode 100644 index 0000000000..757d473f06 --- /dev/null +++ b/compiler/test_mono/src/lib.rs @@ -0,0 +1,184 @@ +#![cfg(test)] +#![warn(clippy::dbg_macro)] +// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. +#![allow(clippy::large_enum_variant)] +// we actually want to compare against the literal float bits +#![allow(clippy::clippy::float_cmp)] + +#[macro_use] +extern crate pretty_assertions; + +use test_mono_macros::*; + +use roc_can::builtins::builtin_defs_map; +use roc_collections::all::MutMap; +use roc_module::symbol::Symbol; +use roc_mono::ir::Proc; + +use roc_mono::ir::TopLevelFunctionLayout; + +fn promote_expr_to_module(src: &str) -> String { + let mut buffer = String::from("app \"test\" provides [ main ] to \"./platform\"\n\nmain =\n"); + + for line in src.lines() { + // indent the body! + buffer.push_str(" "); + buffer.push_str(line); + buffer.push('\n'); + } + + buffer +} + +fn compiles_to_ir(test_name: &str, src: &str) { + use bumpalo::Bump; + use std::path::{Path, PathBuf}; + + let arena = &Bump::new(); + + // let stdlib = roc_builtins::unique::uniq_stdlib(); + let stdlib = roc_builtins::std::standard_stdlib(); + let filename = PathBuf::from("Test.roc"); + let src_dir = Path::new("fake/test/path"); + + let module_src; + let temp; + if src.starts_with("app") { + // this is already a module + module_src = src; + } else { + // this is an expression, promote it to a module + temp = promote_expr_to_module(src); + module_src = &temp; + } + + let exposed_types = MutMap::default(); + + let loaded = roc_load::file::load_and_monomorphize_from_str( + arena, + filename, + &module_src, + &stdlib, + src_dir, + exposed_types, + 8, + builtin_defs_map, + ); + + let mut loaded = match loaded { + Ok(x) => x, + Err(roc_load::file::LoadingProblem::FormattedReport(report)) => { + println!("{}", report); + panic!(); + } + Err(e) => panic!("{:?}", e), + }; + + use roc_load::file::MonomorphizedModule; + let MonomorphizedModule { + module_id: home, + procedures, + exposed_to_host, + .. + } = loaded; + + let can_problems = loaded.can_problems.remove(&home).unwrap_or_default(); + let type_problems = loaded.type_problems.remove(&home).unwrap_or_default(); + let mono_problems = loaded.mono_problems.remove(&home).unwrap_or_default(); + + if !can_problems.is_empty() { + println!("Ignoring {} canonicalization problems", can_problems.len()); + } + + assert_eq!(type_problems, Vec::new()); + assert_eq!(mono_problems, Vec::new()); + + debug_assert_eq!(exposed_to_host.len(), 1); + + let main_fn_symbol = exposed_to_host.keys().copied().next().unwrap(); + + verify_procedures(test_name, procedures, main_fn_symbol); +} + +#[cfg(debug_assertions)] +fn verify_procedures( + test_name: &str, + procedures: MutMap<(Symbol, TopLevelFunctionLayout<'_>), Proc<'_>>, + main_fn_symbol: Symbol, +) { + let index = procedures + .keys() + .position(|(s, _)| *s == main_fn_symbol) + .unwrap(); + + let mut procs_string = procedures + .values() + .map(|proc| proc.to_pretty(200)) + .collect::>(); + + let main_fn = procs_string.swap_remove(index); + + procs_string.sort(); + procs_string.push(main_fn); + + let result = procs_string.join("\n"); + + let path = format!("generated/{}.txt", test_name); + std::fs::create_dir_all("generated").unwrap(); + std::fs::write(&path, result).unwrap(); + + use std::process::Command; + let is_tracked = Command::new("git") + .args(&["ls-files", "--error-unmatch", &path]) + .output() + .unwrap(); + + if !is_tracked.status.success() { + panic!( + "The file {:?} is not tracked by git. Try using `git add` on it", + &path + ); + } + + let has_changes = Command::new("git") + .args(&["diff", "--color=always", &path]) + .output() + .unwrap(); + + if !has_changes.status.success() { + eprintln!("`git diff {:?}` failed", &path); + unreachable!(); + } + + if !has_changes.stdout.is_empty() { + println!("{}", std::str::from_utf8(&has_changes.stdout).unwrap()); + panic!("Output changed: resolve conflicts and `git add` the file."); + } +} + +// NOTE because the Show instance of module names is different in --release mode, +// these tests would all fail. In the future, when we do interesting optimizations, +// we'll likely want some tests for --release too. +#[cfg(not(debug_assertions))] +fn verify_procedures( + _expected: &str, + _procedures: MutMap<(Symbol, TopLevelFunctionLayout<'_>), Proc<'_>>, + _main_fn_symbol: Symbol, +) { + // Do nothing +} + +#[mono_test] +fn ir_int_literal() { + r#" + 5 + "# +} + +#[mono_test] +fn ir_int_add() { + r#" + x = [ 1,2 ] + 5 + 4 + 3 + List.len x + "# +} diff --git a/compiler/test_mono_macros/Cargo.toml b/compiler/test_mono_macros/Cargo.toml index d5243127b6..24ddaa408b 100644 --- a/compiler/test_mono_macros/Cargo.toml +++ b/compiler/test_mono_macros/Cargo.toml @@ -9,28 +9,7 @@ edition = "2018" proc-macro = true [dependencies] -roc_collections = { path = "../collections" } -roc_region = { path = "../region" } -roc_module = { path = "../module" } -roc_types = { path = "../types" } -roc_can = { path = "../can" } -roc_unify = { path = "../unify" } -roc_solve = { path = "../solve" } -roc_problem = { path = "../problem" } -roc_mono = { path = "../mono" } - syn = { version = "1.0.39", features = ["full", "extra-traits"] } quote = "1.0.7" darling = "0.10.2" proc-macro2 = "1.0.24" - -[dev-dependencies] -roc_load= { path = "../load" } -roc_builtins = { path = "../builtins" } -roc_parse = { path = "../parse" } -roc_solve = { path = "../solve" } -pretty_assertions = "0.5.1" -maplit = "1.0.1" -indoc = "0.3.3" -quickcheck = "0.8" -quickcheck_macros = "0.8" diff --git a/compiler/test_mono_macros/src/lib.rs b/compiler/test_mono_macros/src/lib.rs index 978c922117..e6646e4e36 100644 --- a/compiler/test_mono_macros/src/lib.rs +++ b/compiler/test_mono_macros/src/lib.rs @@ -1,45 +1,25 @@ -#![warn(clippy::dbg_macro)] -// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. -#![allow(clippy::large_enum_variant)] -// we actually want to compare against the literal float bits -#![allow(clippy::clippy::float_cmp)] - extern crate proc_macro; -use proc_macro::{Span, TokenStream}; -use quote::{format_ident, quote}; -use syn::spanned::Spanned; - -// pub mod gen_compare; -// pub mod gen_dict; -// pub mod gen_hash; -// pub mod gen_list; -// pub mod gen_num; -// pub mod gen_primitives; -// pub mod gen_records; -// pub mod gen_result; -// pub mod gen_set; -// pub mod gen_str; -// pub mod gen_tags; -// mod helpers; +use proc_macro::TokenStream; +use quote::quote; #[proc_macro_attribute] -pub fn mono_test(args: TokenStream, item: TokenStream) -> TokenStream { - let macro_args = syn::parse_macro_input!(args as syn::AttributeArgs); +pub fn mono_test(_args: TokenStream, item: TokenStream) -> TokenStream { let task_fn = syn::parse_macro_input!(item as syn::ItemFn); - let mut arg_names: syn::punctuated::Punctuated = - syn::punctuated::Punctuated::new(); - let mut args = task_fn.sig.inputs.clone(); + let args = task_fn.sig.inputs.clone(); let name = task_fn.sig.ident.clone(); + let name_str = name.to_string(); let body = task_fn.block.clone(); let visibility = &task_fn.vis; let result = quote! { - #visibility fn #name(#args) { - println!( #body); + #[test] + #visibility fn #name(#args) -> () { + compiles_to_ir(#name_str, #body); + } }; result.into()