about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIgor Matuszewski <Xanewok@gmail.com>2018-09-22 22:24:32 +0200
committerIgor Matuszewski <Xanewok@gmail.com>2018-09-28 01:53:59 +0200
commitcddd00a1e60924fd41e2b51cfd22b9756f6145e8 (patch)
tree791b7683e0cac66b3acd6765d15e2abff285feb0
parentc01e4ce74e96737f99492a185e2d170964f11556 (diff)
downloadrust-cddd00a1e60924fd41e2b51cfd22b9756f6145e8.tar.gz
rust-cddd00a1e60924fd41e2b51cfd22b9756f6145e8.zip
Move `filename_for_metadata` to codegen_utils
This function isn't strictly tied to LLVM (it's more of a utility) and
it's now near an analogous, almost identical `filename_for_input` (for
rlibs and so forth).
Also this means not depending on the backend when one wants to know the
accurate .rmeta output filename.
-rw-r--r--src/librustc_codegen_llvm/back/link.rs12
-rw-r--r--src/librustc_codegen_utils/link.rs13
2 files changed, 15 insertions, 10 deletions
diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs
index 8248385c127..ce52fe00b0e 100644
--- a/src/librustc_codegen_llvm/back/link.rs
+++ b/src/librustc_codegen_llvm/back/link.rs
@@ -47,7 +47,8 @@ use std::str;
 use syntax::attr;
 
 pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target,
-                                  invalid_output_for_target, out_filename, check_file_is_writeable};
+                                  invalid_output_for_target, out_filename, check_file_is_writeable,
+                                  filename_for_metadata};
 
 // The third parameter is for env vars, used on windows to set up the
 // path for MSVC to find its DLLs, and gcc to find its bundled
@@ -218,15 +219,6 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
     false
 }
 
-fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf {
-    let out_filename = outputs.single_output_file.clone()
-        .unwrap_or(outputs
-            .out_directory
-            .join(&format!("lib{}{}.rmeta", crate_name, sess.opts.cg.extra_filename)));
-    check_file_is_writeable(&out_filename, sess);
-    out_filename
-}
-
 pub(crate) fn each_linked_rlib(sess: &Session,
                                info: &CrateInfo,
                                f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> {
diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs
index 75f1d614ae7..3d47f91a623 100644
--- a/src/librustc_codegen_utils/link.rs
+++ b/src/librustc_codegen_utils/link.rs
@@ -97,6 +97,19 @@ pub fn find_crate_name(sess: Option<&Session>,
     "rust_out".to_string()
 }
 
+pub fn filename_for_metadata(sess: &Session,
+                             crate_name: &str,
+                             outputs: &OutputFilenames) -> PathBuf {
+    let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
+
+    let out_filename = outputs.single_output_file.clone()
+        .unwrap_or(outputs.out_directory.join(&format!("lib{}.rmeta", libname)));
+
+    check_file_is_writeable(&out_filename, sess);
+
+    out_filename
+}
+
 pub fn filename_for_input(sess: &Session,
                           crate_type: config::CrateType,
                           crate_name: &str,