From b88f3674bb7af66672da1264ef410e185ab5cf38 Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Sun, 11 Oct 2020 16:09:40 -0700 Subject: [PATCH] Add dynamic path for libgcc --- compiler/build/src/link.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index 92642324b1..8e2b98c5b9 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -122,11 +122,18 @@ fn link_linux( host_input_path: &Path, dest_filename: &Path, ) -> io::Result { - 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") } else { 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! // The `-l` flags should go after the `.o` arguments Command::new("ld") @@ -135,9 +142,9 @@ fn link_linux( .args(&[ "-arch", arch_str(target), - lib_path.join("crti.o").to_str().unwrap(), - lib_path.join("crtn.o").to_str().unwrap(), - lib_path.join("Scrt1.o").to_str().unwrap(), + libcrt_path.join("crti.o").to_str().unwrap(), + libcrt_path.join("crtn.o").to_str().unwrap(), + libcrt_path.join("Scrt1.o").to_str().unwrap(), "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", // Inputs @@ -154,7 +161,7 @@ fn link_linux( "-lc_nonshared", "-lc++", "-lunwind", - "/usr/lib/libgcc_s.so.1", + libgcc_path.to_str().unwrap(), // Output "-o", binary_path.to_str().unwrap(), // app