diff --git a/crates/cli/src/build.rs b/crates/cli/src/build.rs index bb7b23b6b6..e0310b1234 100644 --- a/crates/cli/src/build.rs +++ b/crates/cli/src/build.rs @@ -1,7 +1,7 @@ use bumpalo::Bump; use roc_build::{ link::{ - legacy_host_filename, link, precompiled_host_filename, preprocess_host_wasm32, + legacy_host_filename, link, preprocess_host_wasm32, preprocessed_host_filename, rebuild_host, LinkType, LinkingStrategy, }, program::{self, CodeGenOptions, Problems}, @@ -165,7 +165,7 @@ pub fn build_file<'a>( let preprocessed_host_path = match linking_strategy { LinkingStrategy::Surgical | LinkingStrategy::Additive => { - host_input_path.with_file_name(precompiled_host_filename(target).unwrap()) + host_input_path.with_file_name(preprocessed_host_filename(target).unwrap()) } LinkingStrategy::Legacy => host_input_path .with_file_name(legacy_host_filename(target, code_gen_options.opt_level).unwrap()), diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index c28f495855..fc6a7b9747 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -119,7 +119,7 @@ const fn legacy_host_filename_ext(target: &Triple, opt_level: OptLevel) -> Optio const PRECOMPILED_HOST_EXT: &str = "rh1"; // Short for "roc host version 1" (so we can change format in the future) -pub const fn precompiled_host_filename(target: &Triple) -> Option<&'static str> { +pub const fn preprocessed_host_filename(target: &Triple) -> Option<&'static str> { match target { Triple { operating_system: OperatingSystem::Linux, @@ -164,7 +164,7 @@ pub const fn precompiled_host_filename(target: &Triple) -> Option<&'static str> pub fn legacy_host_filename(target: &Triple, opt_level: OptLevel) -> Option { let ext = legacy_host_filename_ext(target, opt_level)?; - Some(precompiled_host_filename(target)?.replace(PRECOMPILED_HOST_EXT, ext)) + Some(preprocessed_host_filename(target)?.replace(PRECOMPILED_HOST_EXT, ext)) } fn find_zig_str_path() -> PathBuf { diff --git a/crates/linker/src/elf.rs b/crates/linker/src/elf.rs index ec014396dc..67128cb66c 100644 --- a/crates/linker/src/elf.rs +++ b/crates/linker/src/elf.rs @@ -1517,6 +1517,7 @@ mod tests { use super::*; use indoc::indoc; + use roc_build::link::preprocessed_host_filename; use target_lexicon::Triple; const ELF64_DYNHOST: &[u8] = include_bytes!("../dynhost_benchmarks_elf64") as &[_]; @@ -1669,17 +1670,19 @@ mod tests { panic!("zig build-exe failed"); } + let preprocessed_host_filename = dir.join(preprocessed_host_filename(target).unwrap()); + preprocess_elf( target_lexicon::Endianness::Little, &dir.join("host"), &dir.join("metadata"), - &dir.join("preprocessedhost"), + &preprocessed_host_filename, &dir.join("libapp.so"), false, false, ); - std::fs::copy(&dir.join("preprocessedhost"), &dir.join("final")).unwrap(); + std::fs::copy(&preprocessed_host_filename, &dir.join("final")).unwrap(); surgery_elf( &roc_app, diff --git a/crates/linker/src/lib.rs b/crates/linker/src/lib.rs index 8b35e9cbab..051cb75d21 100644 --- a/crates/linker/src/lib.rs +++ b/crates/linker/src/lib.rs @@ -77,7 +77,7 @@ pub fn build_and_preprocess_host( generate_dynamic_lib(target, &stub_dll_symbols, &stub_lib); rebuild_host(opt_level, target, host_input_path, Some(&stub_lib)); let metadata = host_input_path.with_file_name("metadata"); - // let prehost = host_input_path.with_file_name("preprocessedhost"); + // let prehost = host_input_path.with_file_name(preprocessed_host_filename(target).unwrap()); preprocess( target, diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index a815f391b0..3c42d3b26e 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -1358,6 +1358,8 @@ mod test { use object::{pe, LittleEndian as LE, Object}; use indoc::indoc; + use roc_build::link::preprocessed_host_filename; + use target_lexicon::Triple; use super::*; @@ -1708,17 +1710,20 @@ mod test { panic!("zig build-exe failed: {}", command_str); } + let preprocessed_host_filename = + dir.join(preprocessed_host_filename(&Triple::host()).unwrap()); + preprocess_windows( &dir.join("host.exe"), &dir.join("metadata"), - &dir.join("preprocessedhost"), + &preprocessed_host_filename, &names, false, false, ) .unwrap(); - std::fs::copy(&dir.join("preprocessedhost"), &dir.join("app.exe")).unwrap(); + std::fs::copy(&preprocessed_host_filename, &dir.join("app.exe")).unwrap(); surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &roc_app); }