Skip to content

Commit

Permalink
warn on duplicate entries in archives; #2619
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Jan 25, 2015
1 parent 80d92c0 commit bbc0c8d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,17 @@ def get_archive_contents(f):
safe_ensure_dirs(temp_dir)
os.chdir(temp_dir)
contents = filter(lambda x: len(x) > 0, Popen([LLVM_AR, 't', f], stdout=PIPE).communicate()[0].split('\n'))
# llvm-ar appears to just use basenames inside archives. as a result, files with the same basename
# will trample each other when we extract them. to help warn of such situations, we warn if there
# are duplicate entries in the archive
if len(contents) != len(set(contents)):
logging.warning('loading from archive %s, which has duplicate entries (files with identical names). this is dangerous as only the last will be taken into account, and you may see surprising undefined symbols later. run |llvm-ar t archive.a| to see the list of entries' % f)
warned = set()
for i in range(len(contents)):
curr = contents[i]
if curr not in warned and curr in contents[i+1:]:
logging.warning(' duplicate: %s' % curr)
warned.add(curr)
if len(contents) == 0:
logging.debug('Archive %s appears to be empty (recommendation: link an .so instead of .a)' % f)
else:
Expand Down

0 comments on commit bbc0c8d

Please sign in to comment.