Merge remote-tracking branch 'origin/trunk' into windows-linking

This commit is contained in:
Folkert de Vries 2022-08-02 14:11:02 +02:00
commit 19159d170a
45 changed files with 1849 additions and 991 deletions

View file

@ -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 {
@ -124,7 +126,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"]);
@ -231,7 +233,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"]);
@ -343,7 +345,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",
@ -1199,7 +1201,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