Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP replace cli flag --prebuilt-platform with --build-host #6859

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
fix: building valgrind surgical host
  • Loading branch information
lukewilliamboswell committed Jul 9, 2024
commit 753cfb4285b1306c5323630e354ca9c38fe71796
45 changes: 39 additions & 6 deletions crates/valgrind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 19,41 @@ fn build_host() {
std::env::set_var("NO_AVX512", "1");
}

// build a legacy host
roc_build::link::rebuild_host(
roc_mono::ir::OptLevel::Normal,
let stub_dll_symbols = roc_linker::ExposedSymbols {
top_level_values: vec![String::from("mainForHost")],
exported_closure_types: vec![],
}
.stub_dll_symbols();

let opt_level = roc_mono::ir::OptLevel::Normal;

let stub_lib = roc_linker::generate_stub_lib_from_loaded(
target,
platform_main_roc.as_path(),
stub_dll_symbols.as_slice(),
);

debug_assert!(stub_lib.exists());

let host_dest = roc_build::link::rebuild_host(
opt_level,
target,
platform_main_roc.as_path(),
None,
Some(&stub_lib),
);

let preprocessed_path = platform_main_roc.with_file_name(format!("{}.rh", target));
let metadata_path = platform_main_roc.with_file_name(roc_linker::metadata_file_name(target));

roc_linker::preprocess_host(
target,
host_dest.as_path(),
metadata_path.as_path(),
preprocessed_path.as_path(),
&stub_lib,
false,
false,
)
}

fn valgrind_test(source: &str) {
Expand Down Expand Up @@ -88,8 116,13 @@ fn valgrind_test_linux(source: &str) {
let app_module_path = temp_dir.path().join("app.roc");

let arena = bumpalo::Bump::new();
let res_binary_path =
roc_build::program::build_str_test(&arena, &app_module_path, &app_module_source, true);
let assume_prebuilt = true;
let res_binary_path = roc_build::program::build_str_test(
&arena,
&app_module_path,
&app_module_source,
assume_prebuilt,
);

match res_binary_path {
Ok(BuiltFile {
Expand Down