mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Change preprocessedhost filename
This commit is contained in:
parent
7f617c87bf
commit
062ecce84c
5 changed files with 17 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_build::{
|
use roc_build::{
|
||||||
link::{
|
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,
|
rebuild_host, LinkType, LinkingStrategy,
|
||||||
},
|
},
|
||||||
program::{self, CodeGenOptions, Problems},
|
program::{self, CodeGenOptions, Problems},
|
||||||
|
@ -165,7 +165,7 @@ pub fn build_file<'a>(
|
||||||
|
|
||||||
let preprocessed_host_path = match linking_strategy {
|
let preprocessed_host_path = match linking_strategy {
|
||||||
LinkingStrategy::Surgical | LinkingStrategy::Additive => {
|
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
|
LinkingStrategy::Legacy => host_input_path
|
||||||
.with_file_name(legacy_host_filename(target, code_gen_options.opt_level).unwrap()),
|
.with_file_name(legacy_host_filename(target, code_gen_options.opt_level).unwrap()),
|
||||||
|
|
|
@ -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)
|
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 {
|
match target {
|
||||||
Triple {
|
Triple {
|
||||||
operating_system: OperatingSystem::Linux,
|
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<String> {
|
pub fn legacy_host_filename(target: &Triple, opt_level: OptLevel) -> Option<String> {
|
||||||
let ext = legacy_host_filename_ext(target, opt_level)?;
|
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 {
|
fn find_zig_str_path() -> PathBuf {
|
||||||
|
|
|
@ -1517,6 +1517,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
use roc_build::link::preprocessed_host_filename;
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
|
|
||||||
const ELF64_DYNHOST: &[u8] = include_bytes!("../dynhost_benchmarks_elf64") as &[_];
|
const ELF64_DYNHOST: &[u8] = include_bytes!("../dynhost_benchmarks_elf64") as &[_];
|
||||||
|
@ -1669,17 +1670,19 @@ mod tests {
|
||||||
panic!("zig build-exe failed");
|
panic!("zig build-exe failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let preprocessed_host_filename = dir.join(preprocessed_host_filename(target).unwrap());
|
||||||
|
|
||||||
preprocess_elf(
|
preprocess_elf(
|
||||||
target_lexicon::Endianness::Little,
|
target_lexicon::Endianness::Little,
|
||||||
&dir.join("host"),
|
&dir.join("host"),
|
||||||
&dir.join("metadata"),
|
&dir.join("metadata"),
|
||||||
&dir.join("preprocessedhost"),
|
&preprocessed_host_filename,
|
||||||
&dir.join("libapp.so"),
|
&dir.join("libapp.so"),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
std::fs::copy(&dir.join("preprocessedhost"), &dir.join("final")).unwrap();
|
std::fs::copy(&preprocessed_host_filename, &dir.join("final")).unwrap();
|
||||||
|
|
||||||
surgery_elf(
|
surgery_elf(
|
||||||
&roc_app,
|
&roc_app,
|
||||||
|
|
|
@ -77,7 +77,7 @@ pub fn build_and_preprocess_host(
|
||||||
generate_dynamic_lib(target, &stub_dll_symbols, &stub_lib);
|
generate_dynamic_lib(target, &stub_dll_symbols, &stub_lib);
|
||||||
rebuild_host(opt_level, target, host_input_path, Some(&stub_lib));
|
rebuild_host(opt_level, target, host_input_path, Some(&stub_lib));
|
||||||
let metadata = host_input_path.with_file_name("metadata");
|
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(
|
preprocess(
|
||||||
target,
|
target,
|
||||||
|
|
|
@ -1358,6 +1358,8 @@ mod test {
|
||||||
use object::{pe, LittleEndian as LE, Object};
|
use object::{pe, LittleEndian as LE, Object};
|
||||||
|
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
use roc_build::link::preprocessed_host_filename;
|
||||||
|
use target_lexicon::Triple;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -1708,17 +1710,20 @@ mod test {
|
||||||
panic!("zig build-exe failed: {}", command_str);
|
panic!("zig build-exe failed: {}", command_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let preprocessed_host_filename =
|
||||||
|
dir.join(preprocessed_host_filename(&Triple::host()).unwrap());
|
||||||
|
|
||||||
preprocess_windows(
|
preprocess_windows(
|
||||||
&dir.join("host.exe"),
|
&dir.join("host.exe"),
|
||||||
&dir.join("metadata"),
|
&dir.join("metadata"),
|
||||||
&dir.join("preprocessedhost"),
|
&preprocessed_host_filename,
|
||||||
&names,
|
&names,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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);
|
surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &roc_app);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue