Fix a couple of preprocessed host bugs

This commit is contained in:
Richard Feldman 2022-11-22 23:34:31 -05:00
parent d9f3e11634
commit c0b065b51a
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
2 changed files with 13 additions and 22 deletions

View file

@ -163,13 +163,8 @@ pub fn build_file<'a>(
})
.collect();
let preprocessed_host_path = match linking_strategy {
LinkingStrategy::Surgical | LinkingStrategy::Additive => {
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()),
};
let preprocessed_host_path =
host_input_path.with_file_name(preprocessed_host_filename(target).unwrap());
// We don't need to spawn a rebuild thread when using a prebuilt host.
let rebuild_thread = if prebuilt {
@ -182,12 +177,6 @@ pub fn build_file<'a>(
std::process::exit(1);
}
if linking_strategy == LinkingStrategy::Surgical {
// Copy preprocessed host to executable location.
// The surgical linker will modify that copy in-place.
std::fs::copy(&preprocessed_host_path, binary_path.as_path()).unwrap();
}
None
} else {
Some(spawn_rebuild_thread(
@ -202,6 +191,12 @@ pub fn build_file<'a>(
))
};
if linking_strategy == LinkingStrategy::Surgical {
// Copy preprocessed host to executable location.
// The surgical linker will modify that copy in-place.
std::fs::copy(&preprocessed_host_path, binary_path.as_path()).unwrap();
}
let buf = &mut String::with_capacity(1024);
let mut it = loaded.timings.iter().peekable();
@ -441,6 +436,9 @@ fn spawn_rebuild_thread(
exported_symbols,
exported_closure_types,
);
// Copy preprocessed host to executable location.
std::fs::copy(preprocessed_host_path, binary_path.as_path()).unwrap();
}
LinkingStrategy::Legacy => {
rebuild_host(
@ -452,14 +450,7 @@ fn spawn_rebuild_thread(
}
}
if linking_strategy == LinkingStrategy::Surgical {
// Copy preprocessed host to executable location.
std::fs::copy(preprocessed_host_path, binary_path.as_path()).unwrap();
}
let rebuild_host_end = rebuild_host_start.elapsed();
rebuild_host_end.as_millis()
rebuild_host_start.elapsed().as_millis()
})
}

View file

@ -134,7 +134,7 @@ pub const fn preprocessed_host_filename(target: &Triple) -> Option<&'static str>
/// Same format as the precompiled host filename, except with a file extension like ".o" or ".obj"
pub fn legacy_host_filename(target: &Triple, opt_level: OptLevel) -> Option<String> {
let os = roc_target::OperatingSystem::new(target.operating_system)?;
let os = roc_target::OperatingSystem::from(target.operating_system);
let ext = legacy_host_filename_ext(os, opt_level);
Some(preprocessed_host_filename(target)?.replace(PRECOMPILED_HOST_EXT, ext))