only generate roc panic if running tests

This commit is contained in:
Luke Boswell 2023-09-03 20:16:29 +10:00 committed by Folkert
parent cec6d7424e
commit 1856695b0b
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
2 changed files with 25 additions and 14 deletions

View File

@ -45,6 +45,13 @@ impl AssemblyBackendMode {
AssemblyBackendMode::Test => true,
}
}
fn generate_roc_panic(self) -> bool {
match self {
AssemblyBackendMode::Binary => false,
AssemblyBackendMode::Test => true,
}
}
}
pub struct Env<'a> {

View File

@ -1,5 +1,5 @@
use crate::generic64::{aarch64, new_backend_64bit, x86_64};
use crate::{Backend, Env, Relocation};
use crate::{AssemblyBackendMode, Backend, Env, Relocation};
use bumpalo::collections::Vec;
use object::write::{self, SectionId, SymbolId};
use object::write::{Object, StandardSection, StandardSegment, Symbol, SymbolSection};
@ -312,11 +312,13 @@ fn build_object<'a, B: Backend<'a>>(
);
*/
define_setlongjmp_buffer(&mut output);
if backend.env().mode.generate_roc_panic() {
define_setlongjmp_buffer(&mut output);
generate_roc_panic(&mut backend, &mut output);
generate_setjmp(&mut backend, &mut output);
generate_longjmp(&mut backend, &mut output);
generate_roc_panic(&mut backend, &mut output);
generate_setjmp(&mut backend, &mut output);
generate_longjmp(&mut backend, &mut output);
}
if backend.env().mode.generate_allocators() {
generate_wrapper(
@ -402,15 +404,17 @@ fn build_object<'a, B: Backend<'a>>(
// println!("{}", test_helper.to_pretty(backend.interner(), 200, true));
build_proc_symbol(
&mut output,
&mut layout_ids,
&mut procs,
&mut backend,
layout,
test_helper,
Exposed::TestMain,
);
if let AssemblyBackendMode::Test = backend.env().mode {
build_proc_symbol(
&mut output,
&mut layout_ids,
&mut procs,
&mut backend,
layout,
test_helper,
Exposed::TestMain,
);
}
build_proc_symbol(
&mut output,