mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Link macOS hosts
This commit is contained in:
parent
a33386a905
commit
34251f84db
1 changed files with 30 additions and 9 deletions
|
@ -15,23 +15,18 @@ pub fn link(
|
||||||
architecture: Architecture::X86_64,
|
architecture: Architecture::X86_64,
|
||||||
operating_system: OperatingSystem::Linux,
|
operating_system: OperatingSystem::Linux,
|
||||||
..
|
..
|
||||||
} => link_linux(
|
} => link_linux(target, binary_path, host_input_path, dest_filename),
|
||||||
arch_str(target),
|
|
||||||
binary_path,
|
|
||||||
host_input_path,
|
|
||||||
dest_filename,
|
|
||||||
),
|
|
||||||
Triple {
|
Triple {
|
||||||
architecture: Architecture::X86_64,
|
architecture: Architecture::X86_64,
|
||||||
operating_system: OperatingSystem::Darwin,
|
operating_system: OperatingSystem::Darwin,
|
||||||
..
|
..
|
||||||
} => todo!("link macos"),
|
} => link_macos(target, binary_path, host_input_path, dest_filename),
|
||||||
_ => panic!("TODO gracefully handle unsupported target: {:?}", target),
|
_ => panic!("TODO gracefully handle unsupported target: {:?}", target),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_linux(
|
fn link_linux(
|
||||||
arch: &str,
|
target: &Triple,
|
||||||
binary_path: &Path,
|
binary_path: &Path,
|
||||||
host_input_path: &Path,
|
host_input_path: &Path,
|
||||||
dest_filename: &Path,
|
dest_filename: &Path,
|
||||||
|
@ -39,7 +34,7 @@ fn link_linux(
|
||||||
Command::new("ld")
|
Command::new("ld")
|
||||||
.args(&[
|
.args(&[
|
||||||
"-arch",
|
"-arch",
|
||||||
arch,
|
arch_str(target),
|
||||||
"/usr/lib/x86_64-linux-gnu/crti.o",
|
"/usr/lib/x86_64-linux-gnu/crti.o",
|
||||||
"/usr/lib/x86_64-linux-gnu/crtn.o",
|
"/usr/lib/x86_64-linux-gnu/crtn.o",
|
||||||
"/usr/lib/x86_64-linux-gnu/Scrt1.o",
|
"/usr/lib/x86_64-linux-gnu/Scrt1.o",
|
||||||
|
@ -64,3 +59,29 @@ fn link_linux(
|
||||||
])
|
])
|
||||||
.spawn()
|
.spawn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn link_macos(
|
||||||
|
target: &Triple,
|
||||||
|
binary_path: &Path,
|
||||||
|
host_input_path: &Path,
|
||||||
|
dest_filename: &Path,
|
||||||
|
) -> io::Result<Child> {
|
||||||
|
Command::new("ld")
|
||||||
|
.args(&[
|
||||||
|
"-arch",
|
||||||
|
target.architecture.to_string().as_str(),
|
||||||
|
// Libraries - see https://github.com/rtfeldman/roc/pull/554#discussion_r496392274
|
||||||
|
// for discussion and further references
|
||||||
|
"-lSystem",
|
||||||
|
// "-lrt", // TODO shouldn't we need this?
|
||||||
|
// "-lc_nonshared", // TODO sho
|
||||||
|
// "-lc++", // TODO shouldn't we need this?
|
||||||
|
// "-lgcc", // TODO will eventually need compiler_rt from gcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840
|
||||||
|
// "-lunwind", // TODO will eventually need this, see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840
|
||||||
|
"-o",
|
||||||
|
binary_path.to_str().unwrap(), // app
|
||||||
|
host_input_path.to_str().unwrap(), // host.o
|
||||||
|
dest_filename.to_str().unwrap(), // roc_app.o
|
||||||
|
])
|
||||||
|
.spawn()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue