@@ -46,11 +46,10 @@ pub fn remove(sess: &Session, path: &Path) {
46
46
/// Performs the linkage portion of the compilation phase. This will generate all
47
47
/// of the requested outputs for this compilation session.
48
48
pub fn link_binary < ' a , B : ArchiveBuilder < ' a > > ( sess : & ' a Session ,
49
- codegen_results : & CodegenResults ,
50
- outputs : & OutputFilenames ,
51
- crate_name : & str ,
52
- target_cpu : & str ) -> Vec < PathBuf > {
53
- let mut out_filenames = Vec :: new ( ) ;
49
+ codegen_results : & CodegenResults ,
50
+ outputs : & OutputFilenames ,
51
+ crate_name : & str ,
52
+ target_cpu : & str ) {
54
53
for & crate_type in sess. crate_types . borrow ( ) . iter ( ) {
55
54
// Ignore executable crates if we have -Z no-codegen, as they will error.
56
55
let output_metadata = sess. opts . output_types . contains_key ( & OutputType :: Metadata ) ;
@@ -64,13 +63,12 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
64
63
bug ! ( "invalid output type `{:?}` for target os `{}`" ,
65
64
crate_type, sess. opts. target_triple) ;
66
65
}
67
- let out_files = link_binary_output :: < B > ( sess,
68
- codegen_results,
69
- crate_type,
70
- outputs,
71
- crate_name,
72
- target_cpu) ;
73
- out_filenames. extend ( out_files) ;
66
+ link_binary_output :: < B > ( sess,
67
+ codegen_results,
68
+ crate_type,
69
+ outputs,
70
+ crate_name,
71
+ target_cpu) ;
74
72
}
75
73
76
74
// Remove the temporary object file and metadata if we aren't saving temps
@@ -97,22 +95,18 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
97
95
}
98
96
}
99
97
}
100
-
101
- out_filenames
102
98
}
103
99
104
100
fn link_binary_output < ' a , B : ArchiveBuilder < ' a > > ( sess : & ' a Session ,
105
- codegen_results : & CodegenResults ,
106
- crate_type : config:: CrateType ,
107
- outputs : & OutputFilenames ,
108
- crate_name : & str ,
109
- target_cpu : & str ) -> Vec < PathBuf > {
101
+ codegen_results : & CodegenResults ,
102
+ crate_type : config:: CrateType ,
103
+ outputs : & OutputFilenames ,
104
+ crate_name : & str ,
105
+ target_cpu : & str ) {
110
106
for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
111
107
check_file_is_writeable ( obj, sess) ;
112
108
}
113
109
114
- let mut out_filenames = vec ! [ ] ;
115
-
116
110
if outputs. outputs . contains_key ( & OutputType :: Metadata ) {
117
111
let out_filename = filename_for_metadata ( sess, crate_name, outputs) ;
118
112
// To avoid races with another rustc process scanning the output directory,
@@ -125,10 +119,15 @@ fn link_binary_output<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
125
119
. tempdir_in ( out_filename. parent ( ) . unwrap ( ) )
126
120
. unwrap_or_else ( |err| sess. fatal ( & format ! ( "couldn't create a temp dir: {}" , err) ) ) ;
127
121
let metadata = emit_metadata ( sess, codegen_results, & metadata_tmpdir) ;
128
- if let Err ( e) = fs:: rename ( metadata, & out_filename) {
129
- sess. fatal ( & format ! ( "failed to write {}: {}" , out_filename. display( ) , e) ) ;
122
+ match fs:: rename ( & metadata, & out_filename) {
123
+ Ok ( _) => {
124
+ if sess. opts . debugging_opts . emit_directives {
125
+ sess. parse_sess . span_diagnostic . maybe_emit_json_directive (
126
+ format ! ( "metadata file written: {}" , out_filename. display( ) ) ) ;
127
+ }
128
+ }
129
+ Err ( e) => sess. fatal ( & format ! ( "failed to write {}: {}" , out_filename. display( ) , e) ) ,
130
130
}
131
- out_filenames. push ( out_filename) ;
132
131
}
133
132
134
133
let tmpdir = TempFileBuilder :: new ( ) . prefix ( "rustc" ) . tempdir ( ) . unwrap_or_else ( |err|
@@ -158,14 +157,11 @@ fn link_binary_output<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
158
157
) ;
159
158
}
160
159
}
161
- out_filenames. push ( out_filename) ;
162
160
}
163
161
164
162
if sess. opts . cg . save_temps {
165
163
let _ = tmpdir. into_path ( ) ;
166
164
}
167
-
168
- out_filenames
169
165
}
170
166
171
167
// The third parameter is for env vars, used on windows to set up the
0 commit comments