@@ -28,10 +28,7 @@ use super::command::Command;
2828use super :: linker:: { self , Linker } ;
2929use super :: metadata:: { create_rmeta_file, MetadataPosition } ;
3030use super :: rpath:: { self , RPathConfig } ;
31- use crate :: {
32- looks_like_rust_object_file, CodegenResults , CompiledModule , CrateInfo , NativeLib ,
33- METADATA_FILENAME ,
34- } ;
31+ use crate :: { looks_like_rust_object_file, CodegenResults , CompiledModule , CrateInfo , NativeLib } ;
3532
3633use cc:: windows_registry;
3734use regex:: Regex ;
@@ -237,23 +234,7 @@ pub fn each_linked_rlib(
237234 Ok ( ( ) )
238235}
239236
240- /// We use a temp directory here to avoid races between concurrent rustc processes,
241- /// such as builds in the same directory using the same filename for metadata while
242- /// building an `.rlib` (stomping over one another), or writing an `.rmeta` into a
243- /// directory being searched for `extern crate` (observing an incomplete file).
244- /// The returned path is the temporary file containing the complete metadata.
245- pub fn emit_metadata ( sess : & Session , metadata : & [ u8 ] , tmpdir : & MaybeTempDir ) -> PathBuf {
246- let out_filename = tmpdir. as_ref ( ) . join ( METADATA_FILENAME ) ;
247- let result = fs:: write ( & out_filename, metadata) ;
248-
249- if let Err ( e) = result {
250- sess. fatal ( & format ! ( "failed to write {}: {}" , out_filename. display( ) , e) ) ;
251- }
252-
253- out_filename
254- }
255-
256- /// Create an 'rlib'.
237+ /// Create an 'arlib'.
257238///
258239/// An rlib in its current incarnation is essentially a renamed .a file. The rlib primarily contains
259240/// the object file of the crate, but it also contains all of the object files from native
@@ -276,7 +257,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
276257 RlibFlavor :: Normal => {
277258 let ( metadata, metadata_position) =
278259 create_rmeta_file ( sess, codegen_results. metadata . raw_data ( ) ) ;
279- let metadata = emit_metadata ( sess, & metadata, tmpdir) ;
260+ let metadata = rustc_metadata :: fs :: emit_metadata ( sess, & metadata, tmpdir) ;
280261 match metadata_position {
281262 MetadataPosition :: First => {
282263 // Most of the time metadata in rlib files is wrapped in a "dummy" object
@@ -502,7 +483,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
502483
503484 ab. add_archive ( path, move |fname : & str | {
504485 // Ignore metadata files, no matter the name.
505- if fname == METADATA_FILENAME {
486+ if fname == rustc_metadata :: fs :: METADATA_FILENAME {
506487 return true ;
507488 }
508489
@@ -2474,7 +2455,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
24742455
24752456 let mut archive = <B as ArchiveBuilder >:: new ( sess, & dst) ;
24762457 if let Err ( e) = archive. add_archive ( cratepath, move |f| {
2477- if f == METADATA_FILENAME {
2458+ if f == rustc_metadata :: fs :: METADATA_FILENAME {
24782459 return true ;
24792460 }
24802461
0 commit comments