Find libraries in prebuilts

They no longer seem to be built in a core build, at least.

Change-Id: I08ba77463c9e4e3f473c83587efa7fa9dba1e034
Reviewed-on: https://fuchsia-review.googlesource.com/c/fargo/+/568784
Reviewed-by: Marc Khouri <mnck@google.com>
diff --git a/src/package.rs b/src/package.rs
index a36a6ae..dccb50b 100644
--- a/src/package.rs
+++ b/src/package.rs
@@ -5,10 +5,9 @@
 use crate::{
     get_user_libc_path,
     sdk::{
-        amber_path, cmc_path, fuchsia_dir, package_manager_path, shared_libraries_path,
-        FuchsiaConfig, TargetOptions,
+        amber_path, clang_target_lib_path, cmc_path, fuchsia_dir, package_manager_path,
+        shared_libraries_path, FuchsiaConfig, TargetOptions,
     },
-    target_out_dir,
     utils::{strip_binary, target_crate_path},
     RunCargoOptions,
 };
@@ -240,8 +239,8 @@
         println!("write_manifest_file: target = {:#?}", target);
     }
     let mut manifest = File::create(&target)?;
-    let target_out_path = target_out_dir(target_options.config)?;
-    let target_out_path_str = target_out_path.to_string_lossy();
+    let target_lib_path = clang_target_lib_path(target_options)?;
+    let target_lib_path_str = target_lib_path.to_string_lossy();
     let shared_lib_path = shared_libraries_path(target_options)?;
     let shared_lib_str = shared_lib_path.to_string_lossy();
     let libc_path = format!("{}/libc.so", get_user_libc_path(target_options)?.to_string_lossy());
@@ -249,12 +248,9 @@
     let libsyslog_path = format!("{}/libsyslog.so", shared_lib_str);
     let libtraceengine_path = format!("{}/libtrace-engine.so", shared_lib_str);
     let libasync_path = format!("{}/libasync-default.so", shared_lib_str);
-    let libcpp2_path =
-        format!("{}/obj/build/images/fuchsia.zbi/bootfs/lib/libc++.so.2", target_out_path_str,);
-    let libcpp1abi_path =
-        format!("{}/obj/build/images/fuchsia.zbi/bootfs/lib/libc++abi.so.1", target_out_path_str,);
-    let libunwind_path =
-        format!("{}/obj/build/images/fuchsia.zbi/bootfs/lib/libunwind.so.1", target_out_path_str,);
+    let libcpp2_path = format!("{}/libc++.so.2", target_lib_path_str);
+    let libcpp1abi_path = format!("{}/libc++abi.so.1", target_lib_path_str);
+    let libunwind_path = format!("{}/libunwind.so.1", target_lib_path_str);
 
     let additional_libs: Vec<String> = run_cargo_options
         .fargo_manifest
diff --git a/src/sdk.rs b/src/sdk.rs
index 6fed023..39d563d 100644
--- a/src/sdk.rs
+++ b/src/sdk.rs
@@ -2,8 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-use crate::utils::is_mac;
-use crate::X64;
+use crate::{get_triple_cpu, utils::is_mac, X64};
 use failure::{bail, Error, ResultExt};
 use std::path::PathBuf;
 use std::process::Command;
@@ -171,6 +170,14 @@
     Ok(prebuilt_path()?.join("third_party/clang").join(platform_name()))
 }
 
+pub fn clang_lib_path() -> Result<PathBuf, Error> {
+    Ok(clang_base_path()?.join("lib"))
+}
+
+pub fn clang_target_lib_path(options: &TargetOptions<'_, '_>) -> Result<PathBuf, Error> {
+    Ok(clang_lib_path()?.join(format!("{}-unknown-fuchsia", get_triple_cpu(options))))
+}
+
 pub fn clang_c_compiler_path() -> Result<PathBuf, Error> {
     Ok(clang_base_path()?.join("bin").join("clang"))
 }