The hosted stdlib is identical for every VM-execution test, so compile and assemble it exactly once for the whole suite and link each user program against the cached object. This avoids ~40 redundant stdlib compiles.
()
| 20 | // for the suite. This avoids about 40 redundant stdlib compiles. |
| 21 | fn cached_stdlib_objs() -> &'static [(String, AssembledOutput)] { |
| 22 | static STDLIB: OnceLock<Vec<(String, AssembledOutput)>> = OnceLock::new(); |
| 23 | STDLIB.get_or_init(|| { |
| 24 | CompilationPipeline::compile_stdlib_objects(TargetMode::Hosted) |
| 25 | .expect("stdlib compile failed") |
| 26 | }) |
| 27 | } |
| 28 | |
| 29 | // The cached stdlib objects plus the user object, as a link module list. |
| 30 | fn link_with_stdlib<'a>(user: &'a AssembledOutput) -> Vec<(&'a str, &'a AssembledOutput)> { |
| 31 | let mut modules: Vec<(&str, &AssembledOutput)> = cached_stdlib_objs() |