Skip to content

Commit 5a431e6

Browse files
committed
link: use METADATA_FILENAME instead of hardcoding ".metadata".
1 parent acda771 commit 5a431e6

File tree

1 file changed

+5
-5
lines changed
  • crates/rustc_codegen_spirv/src

1 file changed

+5
-5
lines changed

crates/rustc_codegen_spirv/src/link.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
use rspirv::binary::Assemble;
66
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
77
use rustc_codegen_ssa::back::write::CodegenContext;
8-
use rustc_codegen_ssa::{CodegenResults, NativeLib};
8+
use rustc_codegen_ssa::{CodegenResults, NativeLib, METADATA_FILENAME};
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1010
use rustc_data_structures::owning_ref::OwningRef;
1111
use rustc_data_structures::rustc_erase_owner;
@@ -443,13 +443,13 @@ fn create_archive(files: &[&Path], metadata: &[u8], out_filename: &Path) {
443443
let mut builder = Builder::new(file);
444444
{
445445
let mut header = Header::new_gnu();
446-
header.set_path(".metadata").unwrap();
446+
header.set_path(METADATA_FILENAME).unwrap();
447447
header.set_size(metadata.len() as u64);
448448
header.set_cksum();
449449
builder.append(&header, metadata).unwrap();
450450
}
451451
let mut filenames = FxHashSet::default();
452-
filenames.insert(OsStr::new(".metadata"));
452+
filenames.insert(OsStr::new(METADATA_FILENAME));
453453
for file in files {
454454
assert!(
455455
filenames.insert(file.file_name().unwrap()),
@@ -467,7 +467,7 @@ pub fn read_metadata(rlib: &Path) -> Result<MetadataRef, String> {
467467
fn read_metadata_internal(rlib: &Path) -> Result<Option<MetadataRef>, std::io::Error> {
468468
for entry in Archive::new(File::open(rlib)?).entries()? {
469469
let mut entry = entry?;
470-
if entry.path()? == Path::new(".metadata") {
470+
if entry.path()? == Path::new(METADATA_FILENAME) {
471471
let mut bytes = Vec::new();
472472
entry.read_to_end(&mut bytes)?;
473473
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(bytes);
@@ -509,7 +509,7 @@ fn do_link(
509509
for rlib in rlibs {
510510
for entry in Archive::new(File::open(rlib).unwrap()).entries().unwrap() {
511511
let mut entry = entry.unwrap();
512-
if entry.path().unwrap() != Path::new(".metadata") {
512+
if entry.path().unwrap() != Path::new(METADATA_FILENAME) {
513513
// std::fs::read adds 1 to the size, so do the same here - see comment:
514514
// https://github.com/rust-lang/rust/blob/72868e017bdade60603a25889e253f556305f996/library/std/src/fs.rs#L200-L202
515515
let mut bytes = Vec::with_capacity(entry.size() as usize + 1);

0 commit comments

Comments
 (0)