File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
117117
118118 let mut entries = Vec :: new ( ) ;
119119
120- for ( entry_name, entry) in self . entries {
120+ for ( mut entry_name, entry) in self . entries {
121121 // FIXME only read the symbol table of the object files to avoid having to keep all
122122 // object files in memory at once, or read them twice.
123123 let data = match entry {
@@ -140,6 +140,23 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
140140 } ;
141141
142142 if !self . no_builtin_ranlib {
143+ if symbol_table. contains_key ( & entry_name) {
144+ // The ar crate can't handle creating a symbol table in case of multiple archive
145+ // members with the same name. Work around this by prepending a number until we
146+ // get a unique name.
147+ for i in 1 .. {
148+ let new_name = format ! ( "{}_" , i)
149+ . into_bytes ( )
150+ . into_iter ( )
151+ . chain ( entry_name. iter ( ) . copied ( ) )
152+ . collect :: < Vec < _ > > ( ) ;
153+ if !symbol_table. contains_key ( & new_name) {
154+ entry_name = new_name;
155+ break ;
156+ }
157+ }
158+ }
159+
143160 match object:: File :: parse ( & * data) {
144161 Ok ( object) => {
145162 symbol_table. insert (
You can’t perform that action at this time.
0 commit comments