mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
fixes to make default.nix work
This commit is contained in:
parent
11fd062a86
commit
43f9e2a7c3
11 changed files with 100 additions and 69 deletions
|
@ -3,6 +3,7 @@ use libloading::{Error, Library};
|
|||
use roc_builtins::bitcode;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_mono::ir::OptLevel;
|
||||
use roc_utils::get_lib_path;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::io;
|
||||
|
@ -66,12 +67,13 @@ pub fn link(
|
|||
|
||||
fn find_zig_str_path() -> PathBuf {
|
||||
// First try using the lib path relative to the executable location.
|
||||
let exe_relative_str_path = std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|path| Some(path.parent()?.join("lib").join("str.zig")));
|
||||
if let Some(exe_relative_str_path) = exe_relative_str_path {
|
||||
if std::path::Path::exists(&exe_relative_str_path) {
|
||||
return exe_relative_str_path;
|
||||
let lib_path_opt = get_lib_path();
|
||||
|
||||
if let Some(lib_path) = lib_path_opt {
|
||||
let zig_str_path = lib_path.join("str.zig");
|
||||
|
||||
if std::path::Path::exists(&zig_str_path) {
|
||||
return zig_str_path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +89,7 @@ fn find_zig_str_path() -> PathBuf {
|
|||
return zig_str_path;
|
||||
}
|
||||
|
||||
panic!("cannot find `str.zig`. Launch me from either the root of the roc repo or one level down(roc/examples, roc/cli...)")
|
||||
panic!("cannot find `str.zig`. Check the source code in find_zig_str_path() to show all the paths I tried.")
|
||||
}
|
||||
|
||||
fn find_wasi_libc_path() -> PathBuf {
|
||||
|
@ -123,7 +125,7 @@ pub fn build_zig_host_native(
|
|||
"build-exe",
|
||||
"-fPIE",
|
||||
shared_lib_path.to_str().unwrap(),
|
||||
bitcode::BUILTINS_HOST_OBJ_PATH,
|
||||
&bitcode::get_builtins_host_obj_path(),
|
||||
]);
|
||||
} else {
|
||||
command.args(&["build-obj", "-fPIC"]);
|
||||
|
@ -340,7 +342,7 @@ pub fn build_c_host_native(
|
|||
if let Some(shared_lib_path) = shared_lib_path {
|
||||
command.args(&[
|
||||
shared_lib_path.to_str().unwrap(),
|
||||
bitcode::BUILTINS_HOST_OBJ_PATH,
|
||||
&bitcode::get_builtins_host_obj_path(),
|
||||
"-fPIE",
|
||||
"-pie",
|
||||
"-lm",
|
||||
|
@ -1172,7 +1174,7 @@ pub fn preprocess_host_wasm32(host_input_path: &Path, preprocessed_host_path: &P
|
|||
let mut command = Command::new(&zig_executable());
|
||||
let args = &[
|
||||
"wasm-ld",
|
||||
bitcode::BUILTINS_WASM32_OBJ_PATH,
|
||||
&bitcode::get_builtins_wasm32_obj_path(),
|
||||
host_input,
|
||||
WASI_LIBC_PATH,
|
||||
WASI_COMPILER_RT_PATH, // builtins need __multi3, __udivti3, __fixdfti
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue