@@ -226,10 +226,13 @@ impl<'a> ArchiveBuilder<'a> {
226226 }
227227
228228 fn build_with_llvm ( & mut self , kind : ArchiveKind ) -> io:: Result < ( ) > {
229- let mut archives = Vec :: new ( ) ;
229+ let removals = mem:: replace ( & mut self . removals , Vec :: new ( ) ) ;
230+ let mut additions = mem:: replace ( & mut self . additions , Vec :: new ( ) ) ;
230231 let mut strings = Vec :: new ( ) ;
231232 let mut members = Vec :: new ( ) ;
232- let removals = mem:: replace ( & mut self . removals , Vec :: new ( ) ) ;
233+
234+ let dst = CString :: new ( self . config . dst . to_str ( ) . unwrap ( ) ) ?;
235+ let should_update_symbols = self . should_update_symbols ;
233236
234237 unsafe {
235238 if let Some ( archive) = self . src_archive ( ) {
@@ -250,18 +253,18 @@ impl<'a> ArchiveBuilder<'a> {
250253 strings. push ( name) ;
251254 }
252255 }
253- for addition in mem :: replace ( & mut self . additions , Vec :: new ( ) ) {
256+ for addition in & mut additions {
254257 match addition {
255258 Addition :: File { path, name_in_archive } => {
256259 let path = CString :: new ( path. to_str ( ) . unwrap ( ) ) ?;
257- let name = CString :: new ( name_in_archive) ?;
260+ let name = CString :: new ( name_in_archive. clone ( ) ) ?;
258261 members. push ( llvm:: LLVMRustArchiveMemberNew ( path. as_ptr ( ) ,
259262 name. as_ptr ( ) ,
260263 None ) ) ;
261264 strings. push ( path) ;
262265 strings. push ( name) ;
263266 }
264- Addition :: Archive { archive, mut skip } => {
267+ Addition :: Archive { archive, skip } => {
265268 for child in archive. iter ( ) {
266269 let child = child. map_err ( string_to_io_error) ?;
267270 if !is_relevant_child ( & child) {
@@ -288,17 +291,14 @@ impl<'a> ArchiveBuilder<'a> {
288291 members. push ( m) ;
289292 strings. push ( name) ;
290293 }
291- archives. push ( archive) ;
292294 }
293295 }
294296 }
295297
296- let dst = self . config . dst . to_str ( ) . unwrap ( ) . as_bytes ( ) ;
297- let dst = CString :: new ( dst) ?;
298298 let r = llvm:: LLVMRustWriteArchive ( dst. as_ptr ( ) ,
299299 members. len ( ) as libc:: size_t ,
300- members. as_ptr ( ) ,
301- self . should_update_symbols ,
300+ members. as_ptr ( ) as * const & _ ,
301+ should_update_symbols,
302302 kind) ;
303303 let ret = if r. into_result ( ) . is_err ( ) {
304304 let err = llvm:: LLVMRustGetLastError ( ) ;
0 commit comments