This is an archive of the discontinued LLVM Phabricator instance.

[llvm-lib] Correctly handle .lib input files
ClosedPublic

Authored by ruiu on Sep 30 2019, 2:26 AM.

Details

Summary

If archive files are passed as input files, llvm-lib needs to append
the members of the input archive files to the output file. This patch
implements that behavior.

This patch splits an existing function into smaller functions.
Effectively, the new code is only `if (Magic == file_magic::archive)
{ ... }` part.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32674

Event Timeline

ruiu created this revision.Sep 30 2019, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2019, 2:26 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
ruiu edited the summary of this revision. (Show Details)Sep 30 2019, 2:29 AM
MaskRay accepted this revision.Oct 1 2019, 5:37 AM
MaskRay added inline comments.
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
329

Full stop

335

Full stop

llvm/test/tools/llvm-lib/nest.test
12

What if %t/foo.lib is specified twice? It may worth a test.

This revision is now accepted and ready to land.Oct 1 2019, 5:37 AM
ruiu marked an inline comment as done.Oct 1 2019, 10:06 PM
ruiu added inline comments.
llvm/test/tools/llvm-lib/nest.test
12

Good point. Looks like llvm-ar doesn't work correctly for duplicated command line arguments. If you specify the same file more than once, only the first occurrence of the file is recognized and the remaining arguments are ignored. We need to implement that behavior.

Since that's not a new bug, I'll address that in another patch.

This revision was automatically updated to reflect the committed changes.