mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Merge branch 'main' of github.com:roc-lang/roc into simplify_examples
This commit is contained in:
commit
076190a217
61 changed files with 1913 additions and 1004 deletions
|
@ -133,6 +133,7 @@ pub fn build_zig_host_native(
|
|||
command.args(&[
|
||||
"build-exe",
|
||||
"-fPIE",
|
||||
"-rdynamic", // make sure roc_alloc and friends are exposed
|
||||
shared_lib_path.to_str().unwrap(),
|
||||
&builtins_obj,
|
||||
]);
|
||||
|
@ -392,7 +393,9 @@ pub fn build_zig_host_wasm32(
|
|||
command.output().unwrap()
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn build_c_host_native(
|
||||
target: &Triple,
|
||||
env_path: &str,
|
||||
env_home: &str,
|
||||
env_cpath: &str,
|
||||
|
@ -410,17 +413,38 @@ pub fn build_c_host_native(
|
|||
.args(sources)
|
||||
.args(&["-o", dest]);
|
||||
if let Some(shared_lib_path) = shared_lib_path {
|
||||
command.args(&[
|
||||
shared_lib_path.to_str().unwrap(),
|
||||
&bitcode::get_builtins_host_obj_path(),
|
||||
"-fPIE",
|
||||
"-pie",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
"-ldl",
|
||||
"-lrt",
|
||||
"-lutil",
|
||||
]);
|
||||
match target.operating_system {
|
||||
OperatingSystem::Windows => {
|
||||
// just use zig as a C compiler
|
||||
|
||||
// I think we only ever have one C source file in practice
|
||||
assert_eq!(sources.len(), 1);
|
||||
|
||||
return build_zig_host_native(
|
||||
env_path,
|
||||
env_home,
|
||||
&format!("-femit-bin={}", dest),
|
||||
sources[0],
|
||||
find_zig_str_path().to_str().unwrap(),
|
||||
"x86_64-windows-gnu",
|
||||
opt_level,
|
||||
Some(shared_lib_path),
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
command.args(&[
|
||||
shared_lib_path.to_str().unwrap(),
|
||||
&bitcode::get_builtins_host_obj_path(),
|
||||
"-fPIE",
|
||||
"-pie",
|
||||
"-lm",
|
||||
"-lpthread",
|
||||
"-ldl",
|
||||
"-lrt",
|
||||
"-lutil",
|
||||
]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
command.args(&["-fPIC", "-c"]);
|
||||
}
|
||||
|
@ -432,6 +456,7 @@ pub fn build_c_host_native(
|
|||
command.output().unwrap()
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn build_swift_host_native(
|
||||
env_path: &str,
|
||||
env_home: &str,
|
||||
|
@ -440,16 +465,25 @@ pub fn build_swift_host_native(
|
|||
opt_level: OptLevel,
|
||||
shared_lib_path: Option<&Path>,
|
||||
objc_header_path: Option<&str>,
|
||||
arch: Architecture,
|
||||
) -> Output {
|
||||
if shared_lib_path.is_some() {
|
||||
unimplemented!("Linking a shared library to Swift not yet implemented");
|
||||
}
|
||||
|
||||
let mut command = Command::new("xcrun"); // xcrun helps swiftc to find the right header files
|
||||
let mut command = Command::new("arch");
|
||||
command
|
||||
.env_clear()
|
||||
.env("PATH", &env_path)
|
||||
.env("HOME", &env_home)
|
||||
.env("HOME", &env_home);
|
||||
|
||||
match arch {
|
||||
Architecture::Aarch64(_) => command.arg("-arm64"),
|
||||
_ => command.arg(format!("-{}", arch)),
|
||||
};
|
||||
|
||||
command
|
||||
.arg("xcrun") // xcrun helps swiftc to find the right header files
|
||||
.arg("swiftc")
|
||||
.args(sources)
|
||||
.arg("-emit-object")
|
||||
|
@ -634,6 +668,7 @@ pub fn rebuild_host(
|
|||
// Cargo hosts depend on a c wrapper for the api. Compile host.c as well.
|
||||
|
||||
let output = build_c_host_native(
|
||||
target,
|
||||
&env_path,
|
||||
&env_home,
|
||||
&env_cpath,
|
||||
|
@ -686,6 +721,7 @@ pub fn rebuild_host(
|
|||
if shared_lib_path.is_some() {
|
||||
// If compiling to executable, let c deal with linking as well.
|
||||
let output = build_c_host_native(
|
||||
target,
|
||||
&env_path,
|
||||
&env_home,
|
||||
&env_cpath,
|
||||
|
@ -700,6 +736,7 @@ pub fn rebuild_host(
|
|||
validate_output("host.c", "clang", output);
|
||||
} else {
|
||||
let output = build_c_host_native(
|
||||
target,
|
||||
&env_path,
|
||||
&env_home,
|
||||
&env_cpath,
|
||||
|
@ -736,6 +773,7 @@ pub fn rebuild_host(
|
|||
} else if c_host_src.exists() {
|
||||
// Compile host.c, if it exists
|
||||
let output = build_c_host_native(
|
||||
target,
|
||||
&env_path,
|
||||
&env_home,
|
||||
&env_cpath,
|
||||
|
@ -757,6 +795,7 @@ pub fn rebuild_host(
|
|||
swift_host_header_src
|
||||
.exists()
|
||||
.then(|| swift_host_header_src.to_str().unwrap()),
|
||||
target.architecture,
|
||||
);
|
||||
validate_output("host.swift", "swiftc", output);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue