This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Rewrite the symbol table when it is invalid.
AbandonedPublic

Authored by rupprecht on Feb 7 2019, 7:28 PM.

Details

Summary

As an optimization, llvm-ar skips writing the symbol table when it already exists. This is a workaround for build systems that needlessly run ar/ranlib to create a symbol table, even if it already exists.

However, some tools manipulate the archive, and then use ar/ranlib to fix up the symbol table. (Nvidia's nvprune does this). This patch adds a heuristic to determine if the symbol table is invalid, and if so, will rewrite it. This still achieves the goal of the common case, avoiding needless writes when the symbol table is valid, although at the cost of a few more reads (iterating over all members of the symbol table instead of just checking that it exists).

Event Timeline

rupprecht created this revision.Feb 7 2019, 7:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2019, 7:28 PM
ruiu added inline comments.Feb 7 2019, 7:53 PM
llvm/lib/Object/Archive.cpp
997

It seems that this function detect certain type of breakage. What kind of breakage does this logic can catch? Is that that common and no other types of breakage uncmmon?

rupprecht abandoned this revision.Feb 21 2019, 11:20 AM

This workaround is no longer needed for now -- I can revive it if we have some other use case for it.