From c8bbb55111748b629919be3627e2938731684f46 Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 17 Oct 2023 20:00:58 +0200 Subject: [PATCH 1/2] switch to only lines for debug info by default --- Cargo.toml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c9b444a606..356f9058054 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -175,16 +175,23 @@ wyhash = "0.5.0" # Optimizations based on https://deterministic.space/high-performance-rust.html [profile.release] codegen-units = 1 - # debug = true # enable when profiling + +[profile.dev] +debug = "line-tables-only" + [profile.bench] codegen-units = 1 lto = "thin" [profile.release-with-debug] -debug = true inherits = "release" +debug = true [profile.release-with-lto] -lto = "thin" # TODO: We could consider full here since this is only used for packaged release on github. inherits = "release" +lto = "thin" # TODO: We could consider full here since this is only used for packaged release on github. + +[profile.debug-full] +inherits = "dev" +debug = true From 47d4335cda5a8012737672b0129f369702a07f6e Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 17 Oct 2023 20:02:00 +0200 Subject: [PATCH 2/2] cleanup test-gen-dev macro code --- crates/compiler/test_gen/src/helpers/dev.rs | 98 ++++++++++++--------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/crates/compiler/test_gen/src/helpers/dev.rs b/crates/compiler/test_gen/src/helpers/dev.rs index edcef7f7b5f..9d90aaa5684 100644 --- a/crates/compiler/test_gen/src/helpers/dev.rs +++ b/crates/compiler/test_gen/src/helpers/dev.rs @@ -316,12 +316,6 @@ fn get_test_main_fn( get_raw_fn("test_main", lib) } -pub(crate) fn run_function(fn_name: &str, lib: &libloading::Library) -> T { - let main = get_raw_fn::(fn_name, lib); - - unsafe { main() } -} - pub(crate) fn run_test_main(lib: &libloading::Library) -> Result { let main = get_test_main_fn::(lib); @@ -336,10 +330,58 @@ impl From> for Result { } } +// only used in tests +pub(crate) fn asm_evals_to( + src: &str, + expected: U, + transform: F, + leak: bool, + lazy_literals: bool, +) where + U: PartialEq + std::fmt::Debug, + F: FnOnce(T) -> U, +{ + use bumpalo::Bump; + + let arena = Bump::new(); + let (_main_fn_name, errors, lib) = + crate::helpers::dev::helper(&arena, src, leak, lazy_literals); + + let result = crate::helpers::dev::run_test_main::(&lib); + + if !errors.is_empty() { + dbg!(&errors); + + assert_eq!( + errors, + std::vec::Vec::new(), + "Encountered errors: {:?}", + errors + ); + } + + match result { + Ok(value) => { + let expected = expected; + #[allow(clippy::redundant_closure_call)] + let given = transform(value); + assert_eq!(&given, &expected, "output is different"); + } + Err((msg, tag)) => match tag { + CrashTag::Roc => panic!(r#"Roc failed with message: "{msg}""#), + CrashTag::User => panic!(r#"User crash with message: "{msg}""#), + }, + } +} + +pub(crate) fn identity(x: T) -> T { + x +} + #[allow(unused_macros)] macro_rules! assert_evals_to { ($src:expr, $expected:expr, $ty:ty) => {{ - assert_evals_to!($src, $expected, $ty, (|val| val)); + assert_evals_to!($src, $expected, $ty, $crate::helpers::dev::identity); }}; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { // Same as above, except with an additional transformation argument. @@ -357,41 +399,13 @@ macro_rules! assert_evals_to { } }; ($src:expr, $expected:expr, $ty:ty, $transform:expr, $leak:expr, $lazy_literals:expr) => { - use bumpalo::Bump; - - let arena = Bump::new(); - let (_main_fn_name, errors, lib) = - $crate::helpers::dev::helper(&arena, $src, $leak, $lazy_literals); - - let result = $crate::helpers::dev::run_test_main::<$ty>(&lib); - - if !errors.is_empty() { - dbg!(&errors); - - assert_eq!( - errors, - std::vec::Vec::new(), - "Encountered errors: {:?}", - errors - ); - } - - match result { - Ok(value) => { - let expected = $expected; - #[allow(clippy::redundant_closure_call)] - let given = $transform(value); - assert_eq!(&given, &expected, "output is different"); - } - Err((msg, tag)) => { - use roc_mono::ir::CrashTag; - - match tag { - CrashTag::Roc => panic!(r#"Roc failed with message: "{msg}""#), - CrashTag::User => panic!(r#"User crash with message: "{msg}""#), - } - } - } + $crate::helpers::dev::asm_evals_to::<$ty, _, _>( + $src, + $expected, + $transform, + $leak, + $lazy_literals, + ); }; }