Skip to content

Commit cddd00a

Browse files
committed
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.
1 parent c01e4ce commit cddd00a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/librustc_codegen_llvm/back/link.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ use std::str;
4747
use syntax::attr;
4848

4949
pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target,
50-
invalid_output_for_target, out_filename, check_file_is_writeable};
50+
invalid_output_for_target, out_filename, check_file_is_writeable,
51+
filename_for_metadata};
5152

5253
// The third parameter is for env vars, used on windows to set up the
5354
// 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 {
218219
false
219220
}
220221

221-
fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf {
222-
let out_filename = outputs.single_output_file.clone()
223-
.unwrap_or(outputs
224-
.out_directory
225-
.join(&format!("lib{}{}.rmeta", crate_name, sess.opts.cg.extra_filename)));
226-
check_file_is_writeable(&out_filename, sess);
227-
out_filename
228-
}
229-
230222
pub(crate) fn each_linked_rlib(sess: &Session,
231223
info: &CrateInfo,
232224
f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> {

src/librustc_codegen_utils/link.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ pub fn find_crate_name(sess: Option<&Session>,
9797
"rust_out".to_string()
9898
}
9999

100+
pub fn filename_for_metadata(sess: &Session,
101+
crate_name: &str,
102+
outputs: &OutputFilenames) -> PathBuf {
103+
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
104+
105+
let out_filename = outputs.single_output_file.clone()
106+
.unwrap_or(outputs.out_directory.join(&format!("lib{}.rmeta", libname)));
107+
108+
check_file_is_writeable(&out_filename, sess);
109+
110+
out_filename
111+
}
112+
100113
pub fn filename_for_input(sess: &Session,
101114
crate_type: config::CrateType,
102115
crate_name: &str,

0 commit comments

Comments
 (0)