mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 23:37:56 +03:00
Merge pull request #1344 from rtfeldman/bitcode
Include builtins.bc in the roc binary
This commit is contained in:
commit
df75a01cf6
@ -32,7 +32,7 @@ fn main() {
|
|||||||
|
|
||||||
run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]);
|
run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]);
|
||||||
|
|
||||||
let dest_bc_path = Path::new(&out_dir).join("builtins.bc");
|
let dest_bc_path = bitcode_path.join("builtins.bc");
|
||||||
let dest_bc = dest_bc_path.to_str().expect("Invalid dest bc path");
|
let dest_bc = dest_bc_path.to_str().expect("Invalid dest bc path");
|
||||||
println!("Compiling bitcode to: {}", dest_bc);
|
println!("Compiling bitcode to: {}", dest_bc);
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ fn main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
println!("cargo:rustc-env=BUILTINS_BC={}", dest_bc);
|
|
||||||
println!("cargo:rustc-env=BUILTINS_O={}", dest_obj);
|
println!("cargo:rustc-env=BUILTINS_O={}", dest_obj);
|
||||||
get_zig_files(bitcode_path.as_path(), &|path| {
|
get_zig_files(bitcode_path.as_path(), &|path| {
|
||||||
let path: &Path = path;
|
let path: &Path = path;
|
||||||
|
@ -1,26 +1,12 @@
|
|||||||
use std::fs::File;
|
|
||||||
use std::io::prelude::Read;
|
|
||||||
use std::vec::Vec;
|
|
||||||
|
|
||||||
const BC_PATH: &str = env!(
|
|
||||||
"BUILTINS_BC",
|
|
||||||
"Env var BUILTINS_BC not found. Is there a problem with the build script?"
|
|
||||||
);
|
|
||||||
|
|
||||||
pub const OBJ_PATH: &str = env!(
|
pub const OBJ_PATH: &str = env!(
|
||||||
"BUILTINS_O",
|
"BUILTINS_O",
|
||||||
"Env var BUILTINS_O not found. Is there a problem with the build script?"
|
"Env var BUILTINS_O not found. Is there a problem with the build script?"
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn get_bytes() -> Vec<u8> {
|
pub fn as_bytes() -> &'static [u8] {
|
||||||
// In the build script for the builtins module, we compile the builtins bitcode and set
|
// In the build script for the builtins module,
|
||||||
// BUILTINS_BC to the path to the compiled output.
|
// we compile the builtins into LLVM bitcode
|
||||||
let mut builtins_bitcode = File::open(BC_PATH).expect("Unable to find builtins bitcode source");
|
include_bytes!("../bitcode/builtins.bc")
|
||||||
let mut buffer = Vec::new();
|
|
||||||
builtins_bitcode
|
|
||||||
.read_to_end(&mut buffer)
|
|
||||||
.expect("Unable to read builtins bitcode");
|
|
||||||
buffer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const NUM_ASIN: &str = "roc_builtins.num.asin";
|
pub const NUM_ASIN: &str = "roc_builtins.num.asin";
|
||||||
|
@ -353,7 +353,7 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Module<'ctx> {
|
pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Module<'ctx> {
|
||||||
let bitcode_bytes = bitcode::get_bytes();
|
let bitcode_bytes = bitcode::as_bytes();
|
||||||
|
|
||||||
let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name);
|
let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user