@@ -53,6 +53,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
53
53
crate_name : & str ,
54
54
target_cpu : & str ,
55
55
) {
56
+ let _timer = sess. timer ( "link_binary" ) ;
56
57
let output_metadata = sess. opts . output_types . contains_key ( & OutputType :: Metadata ) ;
57
58
for & crate_type in sess. crate_types . borrow ( ) . iter ( ) {
58
59
// Ignore executable crates if we have -Z no-codegen, as they will error.
@@ -71,9 +72,11 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
71
72
) ;
72
73
}
73
74
74
- for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
75
- check_file_is_writeable ( obj, sess) ;
76
- }
75
+ sess. time ( "link_binary_check_files_are_writeable" , || {
76
+ for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
77
+ check_file_is_writeable ( obj, sess) ;
78
+ }
79
+ } ) ;
77
80
78
81
let tmpdir = TempFileBuilder :: new ( )
79
82
. prefix ( "rustc" )
@@ -84,6 +87,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
84
87
let out_filename = out_filename ( sess, crate_type, outputs, crate_name) ;
85
88
match crate_type {
86
89
config:: CrateType :: Rlib => {
90
+ let _timer = sess. timer ( "link_rlib" ) ;
87
91
link_rlib :: < B > (
88
92
sess,
89
93
codegen_results,
@@ -118,29 +122,34 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
118
122
}
119
123
120
124
// Remove the temporary object file and metadata if we aren't saving temps
121
- if !sess. opts . cg . save_temps {
122
- if sess. opts . output_types . should_codegen ( ) && !preserve_objects_for_their_debuginfo ( sess) {
123
- for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
124
- remove ( sess, obj) ;
125
+ sess. time ( "link_binary_remove_temps" , || {
126
+ if !sess. opts . cg . save_temps {
127
+ if sess. opts . output_types . should_codegen ( )
128
+ && !preserve_objects_for_their_debuginfo ( sess)
129
+ {
130
+ for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
131
+ remove ( sess, obj) ;
132
+ }
125
133
}
126
- }
127
- for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. bytecode_compressed . as_ref ( ) ) {
128
- remove ( sess, obj) ;
129
- }
130
- if let Some ( ref metadata_module) = codegen_results. metadata_module {
131
- if let Some ( ref obj) = metadata_module. object {
134
+ for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. bytecode_compressed . as_ref ( ) )
135
+ {
132
136
remove ( sess, obj) ;
133
137
}
134
- }
135
- if let Some ( ref allocator_module ) = codegen_results . allocator_module {
136
- if let Some ( ref obj ) = allocator_module . object {
137
- remove ( sess , obj ) ;
138
+ if let Some ( ref metadata_module ) = codegen_results . metadata_module {
139
+ if let Some ( ref obj ) = metadata_module . object {
140
+ remove ( sess , obj ) ;
141
+ }
138
142
}
139
- if let Some ( ref bc) = allocator_module. bytecode_compressed {
140
- remove ( sess, bc) ;
143
+ if let Some ( ref allocator_module) = codegen_results. allocator_module {
144
+ if let Some ( ref obj) = allocator_module. object {
145
+ remove ( sess, obj) ;
146
+ }
147
+ if let Some ( ref bc) = allocator_module. bytecode_compressed {
148
+ remove ( sess, bc) ;
149
+ }
141
150
}
142
151
}
143
- }
152
+ } ) ;
144
153
}
145
154
146
155
// The third parameter is for env vars, used on windows to set up the
0 commit comments