Skip to content

Avoid leaking file metadata (mtime/UID/GID) in rlibs through the ar crate. #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/rustc_codegen_spirv/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,16 @@ fn create_archive(files: &[&Path], metadata: &[u8], out_filename: &Path) {
"Duplicate filename in archive: {:?}",
file.file_name().unwrap()
);
builder.append_path(file).unwrap();

// NOTE(eddyb) we can't use `append_path` or `append_file`, as they
// record too much metadata by default (mtime/UID/GID, at least),
// which is determintal to reproducible build artifacts, but also
// can misbehave in environments with high UIDs/GIDs (see #889).
let file = File::open(file).unwrap();
let header = Header::new(name.as_bytes().to_vec(), file.metadata().unwrap().len());
// NOTE(eddyb) either `fs::File`, or the result of `fs::read`, could fit
// here, but `fs::File` has specialized file->file copying on some OSes.
builder.append(&header, file).unwrap();
}
builder.into_inner().unwrap();
}
Expand Down