Add dynamic path for libgcc

This commit is contained in:
Brendan Hansknecht 2020-10-11 16:09:40 -07:00
parent 6e130d51bc
commit b88f3674bb

View File

@ -122,11 +122,18 @@ 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() { let libcrt_path = if Path::new("/usr/lib/x86_64-linux-gnu").exists() {
Path::new("/usr/lib/x86_64-linux-gnu") Path::new("/usr/lib/x86_64-linux-gnu")
} else { } else {
Path::new("/usr/lib") Path::new("/usr/lib")
}; };
let libgcc_path = if Path::new("/lib/x86_64-linux-gnu/libgcc_s.so.1").exists() {
Path::new("/lib/x86_64-linux-gnu/libgcc_s.so.1")
} else if Path::new("/usr/lib/x86_64-linux-gnu/libgcc_s.so.1").exists() {
Path::new("/usr/lib/x86_64-linux-gnu/libgcc_s.so.1")
} else {
Path::new("/usr/lib/libgcc_s.so.1")
};
// 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")
@ -135,9 +142,9 @@ fn link_linux(
.args(&[ .args(&[
"-arch", "-arch",
arch_str(target), arch_str(target),
lib_path.join("crti.o").to_str().unwrap(), libcrt_path.join("crti.o").to_str().unwrap(),
lib_path.join("crtn.o").to_str().unwrap(), libcrt_path.join("crtn.o").to_str().unwrap(),
lib_path.join("Scrt1.o").to_str().unwrap(), libcrt_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
@ -154,7 +161,7 @@ fn link_linux(
"-lc_nonshared", "-lc_nonshared",
"-lc++", "-lc++",
"-lunwind", "-lunwind",
"/usr/lib/libgcc_s.so.1", libgcc_path.to_str().unwrap(),
// Output // Output
"-o", "-o",
binary_path.to_str().unwrap(), // app binary_path.to_str().unwrap(), // app