Add builtins to precompiled host

This commit is contained in:
Brendan Hansknecht 2021-09-18 16:29:26 -07:00
parent d1021d652d
commit e546ec0c37

View file

@ -1,6 +1,7 @@
use crate::target::arch_str; use crate::target::arch_str;
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
use libloading::{Error, Library}; use libloading::{Error, Library};
use roc_builtins::bitcode;
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
use roc_mono::ir::OptLevel; use roc_mono::ir::OptLevel;
use std::collections::HashMap; use std::collections::HashMap;
@ -93,7 +94,12 @@ pub fn build_zig_host_native(
.env("PATH", env_path) .env("PATH", env_path)
.env("HOME", env_home); .env("HOME", env_home);
if let Some(shared_lib_path) = shared_lib_path { if let Some(shared_lib_path) = shared_lib_path {
command.args(&["build-exe", "-fPIE", shared_lib_path.to_str().unwrap()]); command.args(&[
"build-exe",
"-fPIE",
shared_lib_path.to_str().unwrap(),
bitcode::OBJ_PATH,
]);
} else { } else {
command.args(&["build-obj", "-fPIC"]); command.args(&["build-obj", "-fPIC"]);
} }
@ -109,7 +115,6 @@ pub fn build_zig_host_native(
// include libc // include libc
"--library", "--library",
"c", "c",
"--strip",
// cross-compile? // cross-compile?
"-target", "-target",
target, target,
@ -178,7 +183,12 @@ pub fn build_zig_host_native(
.env("PATH", &env_path) .env("PATH", &env_path)
.env("HOME", &env_home); .env("HOME", &env_home);
if let Some(shared_lib_path) = shared_lib_path { if let Some(shared_lib_path) = shared_lib_path {
command.args(&["build-exe", "-fPIE", shared_lib_path.to_str().unwrap()]); command.args(&[
"build-exe",
"-fPIE",
shared_lib_path.to_str().unwrap(),
bitcode::OBJ_PATH,
]);
} else { } else {
command.args(&["build-obj", "-fPIC"]); command.args(&["build-obj", "-fPIC"]);
} }
@ -197,7 +207,6 @@ pub fn build_zig_host_native(
// include libc // include libc
"--library", "--library",
"c", "c",
"--strip",
]); ]);
if matches!(opt_level, OptLevel::Optimize) { if matches!(opt_level, OptLevel::Optimize) {
command.args(&["-O", "ReleaseSafe"]); command.args(&["-O", "ReleaseSafe"]);
@ -274,6 +283,7 @@ pub fn build_c_host_native(
if let Some(shared_lib_path) = shared_lib_path { if let Some(shared_lib_path) = shared_lib_path {
command.args(&[ command.args(&[
shared_lib_path.to_str().unwrap(), shared_lib_path.to_str().unwrap(),
bitcode::OBJ_PATH,
"-fPIE", "-fPIE",
"-pie", "-pie",
"-lm", "-lm",