This is an archive of the discontinued LLVM Phabricator instance.

Implement --start-lib and --end-lib.
ClosedPublic

Authored by ruiu on Apr 5 2016, 9:00 PM.

Details

Reviewers
ruiu
rafael
Summary

Implement --start-lib and --end-lib.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 52763.Apr 5 2016, 9:00 PM
ruiu retitled this revision from to Implement --start-lib and --end-lib..
ruiu updated this object.
ruiu added a reviewer: ruiu.

General idea sounds reasonable, but we have to make sure it works with bitcode too.

ELF/InputFiles.cpp
285

Why do you need this?

ELF/InputFiles.h
44

So, --start-lib foo.bc --end-lib should work. This suggests that it should be a flag in the class saying that it is lazy, not a new type.

164

It should be possible to use bitcode files in --start-lib/--end-lib, so this should inherit from InputFile, like ArchiveFile does

It can then have two subclasses or just know that it can be wrapping a .o or a .bc.

silvas added a subscriber: silvas.Apr 6 2016, 2:00 PM

Have you tried adding a debug mode that internally translates regular archives into --start-lib/--end-lib and see which tests fail?

ruiu edited edge metadata.Apr 6 2016, 2:12 PM

That's a good idea. I'll try.

ruiu updated this revision to Diff 52867.Apr 6 2016, 4:29 PM
ruiu edited edge metadata.

Updated as per review comments.

ELF/InputFiles.cpp
285

Removed.

ELF/InputFiles.h
44

Reusing the existing File classes for lazy files was not easy as I expected. For example, the existing parse function takes a list of COMDAT group names. When creating lazy files, we don't want to read or write the list because parsing a lazy file should have any semantic meaning. Therefore, it seems to be easier to keep LazyObjectFile as a separate class than making a flag.

164

Done.

ruiu added a comment.Apr 6 2016, 4:36 PM

This patch worked when I made a change to handle each file in an archive file using LazyObjectFile instead of ArchiveFile (with a few exception related to error messages containing an archive file name), so it looks like it's working fine for regular object files and bitcode files.

rafael accepted this revision.Apr 7 2016, 11:09 AM
rafael added a reviewer: rafael.

This is looking really nice. If needed we can try optimizing not parsing symbols twice in the future.

LGTM with some nits and a bitcode test added.

ELF/InputFiles.cpp
585

Can you use Syms.slice(FirstNonLocal)?

599

You probably want to use BitcodeFile::shouldSkip.

ELF/SymbolTable.h
90

Why change this?

This revision is now accepted and ready to land.Apr 7 2016, 11:09 AM
ruiu added a comment.Apr 7 2016, 12:30 PM

Submitted as r265710 with an additional test for bitcode input files.

ELF/InputFiles.cpp
585

Done.

599

Done.

ELF/SymbolTable.h
90

That was a mistake. Reverted.

ruiu closed this revision.Apr 7 2016, 12:39 PM