Make link paths generic and add libgcc_s

This commit is contained in:
Brendan Hansknecht 2020-10-11 12:36:12 -07:00
parent f02515c0d1
commit 6e130d51bc
2 changed files with 10 additions and 4 deletions

View file

@ -122,6 +122,11 @@ fn link_linux(
host_input_path: &Path, host_input_path: &Path,
dest_filename: &Path, dest_filename: &Path,
) -> io::Result<Child> { ) -> io::Result<Child> {
let lib_path = if Path::new("/usr/lib/x86_64-linux-gnu").exists() {
Path::new("/usr/lib/x86_64-linux-gnu")
} else {
Path::new("/usr/lib")
};
// NOTE: order of arguments to `ld` matters here! // NOTE: order of arguments to `ld` matters here!
// The `-l` flags should go after the `.o` arguments // The `-l` flags should go after the `.o` arguments
Command::new("ld") Command::new("ld")
@ -130,9 +135,9 @@ fn link_linux(
.args(&[ .args(&[
"-arch", "-arch",
arch_str(target), arch_str(target),
"/usr/lib/x86_64-linux-gnu/crti.o", lib_path.join("crti.o").to_str().unwrap(),
"/usr/lib/x86_64-linux-gnu/crtn.o", lib_path.join("crtn.o").to_str().unwrap(),
"/usr/lib/x86_64-linux-gnu/Scrt1.o", lib_path.join("Scrt1.o").to_str().unwrap(),
"-dynamic-linker", "-dynamic-linker",
"/lib64/ld-linux-x86-64.so.2", "/lib64/ld-linux-x86-64.so.2",
// Inputs // Inputs
@ -149,7 +154,7 @@ fn link_linux(
"-lc_nonshared", "-lc_nonshared",
"-lc++", "-lc++",
"-lunwind", "-lunwind",
// "-lgcc", // TODO will eventually need compiler_rt from gcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840 "/usr/lib/libgcc_s.so.1",
// Output // Output
"-o", "-o",
binary_path.to_str().unwrap(), // app binary_path.to_str().unwrap(), // app

1
examples/.gitignore vendored
View file

@ -1,2 +1,3 @@
app app
host.o host.o
c_host.o