mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
auto merge of #11215 : alexcrichton/rust/metadata-filename, r=pcwalton
Right now if you have concurrent builds of two libraries in the same directory (such as rustc's bootstrapping process), it's possible that two libraries will stomp over each others' metadata, producing corrupt rlibs. By placing the metadata file in a tempdir we're guranteed to not conflict with ay other builds happening concurrently. Normally this isn't a problem because output filenames are scoped to the name of the crate, but metadata is special in that it has the same name across all crates.
This commit is contained in:
commit
03b510297c
@ -879,8 +879,11 @@ fn link_rlib(sess: Session,
|
||||
match trans {
|
||||
Some(trans) => {
|
||||
// Instead of putting the metadata in an object file section, rlibs
|
||||
// contain the metadata in a separate file.
|
||||
let metadata = obj_filename.with_filename(METADATA_FILENAME);
|
||||
// contain the metadata in a separate file. We use a temp directory
|
||||
// here so concurrent builds in the same directory don't try to use
|
||||
// the same filename for metadata (stomping over one another)
|
||||
let tmpdir = TempDir::new("rustc").expect("needs a temp dir");
|
||||
let metadata = tmpdir.path().join(METADATA_FILENAME);
|
||||
fs::File::create(&metadata).write(trans.metadata);
|
||||
a.add_file(&metadata, false);
|
||||
fs::unlink(&metadata);
|
||||
|
Loading…
Reference in New Issue
Block a user