mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-23 06:25:10 +00:00
split up bitcode building to reduce dependency chains
This commit is contained in:
parent
24c7bded35
commit
d5e191d083
18 changed files with 418 additions and 140 deletions
|
@ -1,73 +1,6 @@
|
|||
use roc_module::symbol::Symbol;
|
||||
use roc_target::TargetInfo;
|
||||
use std::ops::Index;
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
pub const HOST_WASM: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/bitcode/builtins-wasm32.o"));
|
||||
// TODO: in the future, we should use Zig's cross-compilation to generate and store these
|
||||
// for all targets, so that we can do cross-compilation!
|
||||
#[cfg(unix)]
|
||||
pub const HOST_UNIX: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/bitcode/builtins-host.o"));
|
||||
#[cfg(windows)]
|
||||
pub const HOST_WINDOWS: &[u8] = include_bytes!(concat!(
|
||||
env!("OUT_DIR"),
|
||||
"/bitcode/builtins-windows-x86_64.obj"
|
||||
));
|
||||
|
||||
pub fn host_wasm_tempfile() -> std::io::Result<NamedTempFile> {
|
||||
let tempfile = tempfile::Builder::new()
|
||||
.prefix("host_bitcode")
|
||||
.suffix(".wasm")
|
||||
.rand_bytes(8)
|
||||
.tempfile()?;
|
||||
|
||||
std::fs::write(tempfile.path(), HOST_WASM)?;
|
||||
|
||||
Ok(tempfile)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn host_unix_tempfile() -> std::io::Result<NamedTempFile> {
|
||||
let tempfile = tempfile::Builder::new()
|
||||
.prefix("host_bitcode")
|
||||
.suffix(".o")
|
||||
.rand_bytes(8)
|
||||
.tempfile()?;
|
||||
|
||||
std::fs::write(tempfile.path(), HOST_UNIX)?;
|
||||
|
||||
Ok(tempfile)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn host_windows_tempfile() -> std::io::Result<NamedTempFile> {
|
||||
let tempfile = tempfile::Builder::new()
|
||||
.prefix("host_bitcode")
|
||||
.suffix(".obj")
|
||||
.rand_bytes(8)
|
||||
.tempfile()?;
|
||||
|
||||
std::fs::write(tempfile.path(), HOST_WINDOWS)?;
|
||||
|
||||
Ok(tempfile)
|
||||
}
|
||||
|
||||
pub fn host_tempfile() -> std::io::Result<NamedTempFile> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
host_unix_tempfile()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
host_windows_tempfile()
|
||||
}
|
||||
|
||||
#[cfg(not(any(windows, unix)))]
|
||||
{
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct IntrinsicName {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue