Use include_bytes! so builtin hosts live in binary

This commit is contained in:
Richard Feldman 2022-11-21 22:30:34 -05:00
parent a90d9d465d
commit e97a5fe7f6
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
11 changed files with 72 additions and 65 deletions

View file

@ -193,17 +193,16 @@ pub fn helper(
.expect("failed to build output object");
std::fs::write(&app_o_file, module_out).expect("failed to write object to file");
// std::fs::copy(&app_o_file, "/tmp/app.o").unwrap();
let builtins_host_file = tempfile::tempfile().unwrap();
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
.expect("failed to write host builtins object to tempfile");
let (mut child, dylib_path) = link(
&target,
app_o_file.clone(),
// Long term we probably want a smarter way to link in zig builtins.
// With the current method all methods are kept and it adds about 100k to all outputs.
&[
app_o_file.to_str().unwrap(),
&bitcode::get_builtins_host_obj_path(),
],
&[app_o_file.to_str().unwrap(), &builtins_host_file.path()],
LinkType::Dylib,
)
.expect("failed to link dynamic library");