mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Merge pull request #4565 from roc-lang/more-standalone
Use include_bytes! so builtin hosts live in binary
This commit is contained in:
commit
099ab4938f
14 changed files with 146 additions and 72 deletions
|
@ -17,7 +17,6 @@ use roc_target::TargetInfo;
|
|||
use std::time::{Duration, Instant};
|
||||
use std::{path::PathBuf, thread::JoinHandle};
|
||||
use target_lexicon::Triple;
|
||||
use tempfile::Builder;
|
||||
|
||||
fn report_timing(buf: &mut String, label: &str, duration: Duration) {
|
||||
use std::fmt::Write;
|
||||
|
@ -331,7 +330,7 @@ pub fn build_file<'a>(
|
|||
problems
|
||||
}
|
||||
(LinkingStrategy::Legacy, _) => {
|
||||
let app_o_file = Builder::new()
|
||||
let app_o_file = tempfile::Builder::new()
|
||||
.prefix("roc_app")
|
||||
.suffix(&format!(".{}", app_extension))
|
||||
.tempfile()
|
||||
|
@ -345,20 +344,35 @@ pub fn build_file<'a>(
|
|||
app_o_file.to_str().unwrap(),
|
||||
];
|
||||
|
||||
let str_host_obj_path = bitcode::get_builtins_host_obj_path();
|
||||
let builtins_host_tempfile = {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
bitcode::host_unix_tempfile()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
bitcode::host_windows_tempfile()
|
||||
}
|
||||
}
|
||||
.expect("failed to write host builtins object to tempfile");
|
||||
|
||||
if matches!(code_gen_options.backend, program::CodeGenBackend::Assembly) {
|
||||
inputs.push(&str_host_obj_path);
|
||||
inputs.push(builtins_host_tempfile.path().to_str().unwrap());
|
||||
}
|
||||
|
||||
let (mut child, _) = // TODO use lld
|
||||
link(target, binary_path.clone(), &inputs, link_type)
|
||||
.map_err(|_| todo!("gracefully handle `ld` failing to spawn."))?;
|
||||
link(target, binary_path.clone(), &inputs, link_type)
|
||||
.map_err(|_| todo!("gracefully handle `ld` failing to spawn."))?;
|
||||
|
||||
let exit_status = child
|
||||
.wait()
|
||||
.map_err(|_| todo!("gracefully handle error after `ld` spawned"))?;
|
||||
|
||||
// Extend the lifetime of the tempfile so it doesn't get dropped
|
||||
// (and thus deleted) before the child process is done using it!
|
||||
let _ = builtins_host_tempfile;
|
||||
|
||||
if exit_status.success() {
|
||||
problems
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue