mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Merge branch 'precompiled-legacy' into https-packages
This commit is contained in:
commit
f5cb2d73a1
96 changed files with 4063 additions and 1334 deletions
|
@ -1576,7 +1576,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn zig_host_app_help(dir: &Path) {
|
||||
fn zig_host_app_help(dir: &Path, target: &Triple) {
|
||||
let host_zig = indoc!(
|
||||
r#"
|
||||
const std = @import("std");
|
||||
|
@ -1670,8 +1670,7 @@ mod tests {
|
|||
panic!("zig build-exe failed");
|
||||
}
|
||||
|
||||
let preprocessed_host_filename =
|
||||
dir.join(preprocessed_host_filename(&Triple::host()).unwrap());
|
||||
let preprocessed_host_filename = dir.join(preprocessed_host_filename(target).unwrap());
|
||||
|
||||
preprocess_elf(
|
||||
target_lexicon::Endianness::Little,
|
||||
|
@ -1697,10 +1696,12 @@ mod tests {
|
|||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn zig_host_app() {
|
||||
use std::str::FromStr;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let dir = dir.path();
|
||||
|
||||
zig_host_app_help(dir);
|
||||
zig_host_app_help(dir, &Triple::from_str("x86_64-unknown-linux-musl").unwrap());
|
||||
|
||||
let output = std::process::Command::new(&dir.join("final"))
|
||||
.current_dir(dir)
|
||||
|
|
|
@ -4,19 +4,17 @@ use roc_error_macros::internal_error;
|
|||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use target_lexicon::Triple;
|
||||
use tempfile::Builder;
|
||||
|
||||
// TODO: Eventually do this from scratch and in memory instead of with ld.
|
||||
pub fn create_dylib_macho(
|
||||
custom_names: &[String],
|
||||
triple: &Triple,
|
||||
) -> object::read::Result<Vec<u8>> {
|
||||
let dummy_obj_file = Builder::new()
|
||||
let dummy_obj_file = tempfile::Builder::new()
|
||||
.prefix("roc_lib")
|
||||
.suffix(".o")
|
||||
.tempfile()
|
||||
.unwrap_or_else(|e| internal_error!("{}", e));
|
||||
let dummy_obj_file = dummy_obj_file.path();
|
||||
let tmp = tempfile::tempdir().unwrap_or_else(|e| internal_error!("{}", e));
|
||||
let dummy_lib_file = tmp.path().to_path_buf().with_file_name("libapp.so");
|
||||
|
||||
|
@ -47,7 +45,7 @@ pub fn create_dylib_macho(
|
|||
}
|
||||
|
||||
std::fs::write(
|
||||
dummy_obj_file,
|
||||
dummy_obj_file.path(),
|
||||
out_object.write().expect("failed to build output object"),
|
||||
)
|
||||
.expect("failed to write object to file");
|
||||
|
@ -70,13 +68,17 @@ pub fn create_dylib_macho(
|
|||
.args([
|
||||
ld_flag_soname,
|
||||
dummy_lib_file.file_name().unwrap().to_str().unwrap(),
|
||||
dummy_obj_file.to_str().unwrap(),
|
||||
dummy_obj_file.path().to_str().unwrap(),
|
||||
"-o",
|
||||
dummy_lib_file.to_str().unwrap(),
|
||||
])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
// Extend the lifetime of the tempfile so it doesn't get dropped
|
||||
// (and thus deleted) before the linker process is done using it!
|
||||
let _ = dummy_obj_file;
|
||||
|
||||
if !output.status.success() {
|
||||
match std::str::from_utf8(&output.stderr) {
|
||||
Ok(stderr) => panic!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue