File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
174
174
BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( & self . config . dst ) . unwrap ( ) ) )
175
175
} ;
176
176
177
+ let has_any_object_files = self . entries . iter ( ) . any ( |( name, _) | name. ends_with ( ".o" ) ) ;
178
+
177
179
// Add all files
178
180
for ( entry_name, entry) in self . entries . into_iter ( ) {
179
181
match entry {
@@ -220,14 +222,16 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
220
222
// Finalize archive
221
223
std:: mem:: drop ( builder) ;
222
224
223
- // Run ranlib to be able to link the archive
224
- let status = std:: process:: Command :: new ( "ranlib" )
225
- . arg ( self . config . dst )
226
- . status ( )
227
- . expect ( "Couldn't run ranlib" ) ;
225
+ if has_any_object_files {
226
+ // Run ranlib to be able to link the archive
227
+ let status = std:: process:: Command :: new ( "ranlib" )
228
+ . arg ( self . config . dst )
229
+ . status ( )
230
+ . expect ( "Couldn't run ranlib" ) ;
228
231
229
- if !status. success ( ) {
230
- self . config . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
232
+ if !status. success ( ) {
233
+ self . config . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
234
+ }
231
235
}
232
236
}
233
237
}
You can’t perform that action at this time.
0 commit comments