Change:
Given this code: I get this output from rustc: The most recent archive no longer has the "read" permission bit set for group/world owners. This ended up breaking because our files are built in a container with a different user and aren't then readable outside of the container. There's no particular reason we do this and we can work around this, but I also suspected that the change in permissions here probably wasn't intentional. I think this is due to (cc specifically . I haven't dug too deeply but my guess is that temp files specifically turn off other permission bits
reverted back to the LLVM archive writer to fix another regression. Still I think this issuw should be kept open as a reminder to fix the new archive writer before it becomes the default again.
cc , which also needs to be fixed before relanding the archive writer change. BTW is there a tracking issue for that somewhere? I see the original PR linked to , but it hasn't been reopened.
I have kept all issues that need to be fixed before it can land again in my github notifications. There is currently no tracking issue, but feel free to open one. It did probably be a good idea to ensure no issue is forgotten about.

Discussion:
use tempfile::Builder as TempFileBuilder; use std::error::Error; <del> use std::fs::File; </del> <ins> use std::fs::{self, File}; </ins> use std::io::{self, Write}; use std::path::{Path, PathBuf};

// This prevents programs (including rustc) from attempting to read a partial archive. // It also enables writing an archive with the same filename as a dependency on Windows as // required by a test. <del> let mut archive_tmpfile = TempFileBuilder::new() </del> <ins> // The tempfile crate currently uses 0o600 as mode for the temporary files and directories // it creates. We need it to be the default mode for back compat reasons however. (See // #107495) To handle this we are telling tempfile to create a temporary directory instead // and then inside this directory create a file using File::create. let archive_tmpdir = TempFileBuilder::new() </ins> .suffix(".temp-archive") <del> .tempfile_in(output.parent().unwrap_or_else(|| Path::new(""))) .map_err(|err| io_error_context("couldn't create a temp file", err))?; </del> <ins> .tempdir_in(output.parent().unwrap_or_else(|| Path::new(""))) .map_err(|err| { io_error_context("couldn't create a directory for the temp file", err) })?; let archive_tmpfile_path = archive_tmpdir.path().join("tmp.a"); let mut archive_tmpfile = File::create_new(&archive_tmpfile_path) .map_err(|err| io_error_context("couldn't create the temp file", err))?; </ins> <del> write_archive_to_stream(archive_tmpfile.as_file_mut(), &entries, archive_kind, false)?; </del> <ins> write_archive_to_stream(&mut archive_tmpfile, &entries, archive_kind, false)?; </ins> let any_entries = !entries.is_empty(); drop(entries);

// output archive to the same location as an input archive on Windows. drop(self.src_archives); <del> archive_tmpfile .persist(output) .map_err(|err| io_error_context("failed to rename archive file", err.error))?; </del> <ins> fs::rename(archive_tmpfile_path, output) .map_err(|err| io_error_context("failed to rename archive file", err))?; archive_tmpdir .close() .map_err(|err| io_error_context("failed to remove temporary directory", err))?; </ins> Ok(any_entries) }

<ins> #![feature(rustc_private)] #[cfg(unix)] extern crate libc; extern crate run_make_support; use run_make_support::{aux_build, tmp_dir}; use std::fs; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::Path; fn main() { #[cfg(unix)] unsafe { libc::umask(0o002); } aux_build().arg("foo.rs").run(); verify(&tmp_dir().join("libfoo.rlib")); } fn verify(path: &Path) { let perm = fs::metadata(path).unwrap().permissions(); assert!(!perm.readonly()); // Check that the file is readable for everyone #[cfg(unix)] assert_eq!(perm.mode(), 0o100664); } </ins>