Commit Graph

87 Commits

Author SHA1 Message Date
Rui Ueyama d0371f4736 Fix component build
b11386f9be broke lld build
if `-DBUILD_SHARED_LIBS=ON` is passed to CMake.
2019-11-19 11:20:52 +09:00
Rui Ueyama b11386f9be Make it possible to redirect not only errs() but also outs()
This change is for those who use lld as a library. Context:
https://reviews.llvm.org/D70287

This patch adds a new parmeter to lld::*::link() so that we can pass
an raw_ostream object representing stdout. Previously, lld::*::link()
took only an stderr object.

Justification for making stdoutOS and stderrOS mandatory: I wanted to
make link() functions to take stdout and stderr in that order.
However, if we change the function signature from

  bool link(ArrayRef<const char *> args, bool canExitEarly,
            raw_ostream &stderrOS = llvm::errs());

to

  bool link(ArrayRef<const char *> args, bool canExitEarly,
            raw_ostream &stdoutOS = llvm::outs(),
            raw_ostream &stderrOS = llvm::errs());

, then the meaning of existing code that passes stderrOS silently
changes (stderrOS would be interpreted as stdoutOS). So, I chose to
make existing code not to compile, so that developers can fix their
code.

Differential Revision: https://reviews.llvm.org/D70292
2019-11-18 11:18:06 +09:00
Jonas Devlieghere 6ba7992031 [LLD] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368936
2019-08-14 22:28:17 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Fangrui Song c505e06134 Remove \brief commands from doxygen comments.
Summary: This is similar to D46290 D46320.

Reviewers: ruiu, grimar

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D46861

llvm-svn: 332372
2018-05-15 16:40:54 +00:00
Rui Ueyama 3f851704c1 Move new lld's code to Common subdirectory.
New lld's files are spread under lib subdirectory, and it isn't easy
to find which files are actually maintained. This patch moves maintained
files to Common subdirectory.

Differential Revision: https://reviews.llvm.org/D37645

llvm-svn: 314719
2017-10-02 21:00:41 +00:00
Zachary Turner 264b5d9e88 Move Object format code to lib/BinaryFormat.
This creates a new library called BinaryFormat that has all of
the headers from llvm/Support containing structure and layout
definitions for various types of binary formats like dwarf, coff,
elf, etc as well as the code for identifying a file from its
magic.

Differential Revision: https://reviews.llvm.org/D33843

llvm-svn: 304864
2017-06-07 03:48:56 +00:00
Mehdi Amini c1edf566b9 Prevent at compile time converting from Error::success() to Expected<T>
This would trigger an assertion at runtime otherwise.

Differential Revision: https://reviews.llvm.org/D26482

llvm-svn: 286562
2016-11-11 04:29:25 +00:00
Kevin Enderby 0fa9fd0f28 Needed change to lld for the changes to libObject/Archive interfaces now returning Expected<>
for the llvm trunk change in r277656

llvm-svn: 277657
2016-08-03 21:58:48 +00:00
Kevin Enderby 01e41f11a7 Matching change needed to lld for llvm trunk change r277177.
Where Archive::getMemoryBufferRef() was changed to return Expected<>

llvm-svn: 277183
2016-07-29 17:56:00 +00:00
Lang Hames 622ef17f5d [lld] Update LLD for Archive::child_iterator change in LLVM r275361.
llvm-svn: 275362
2016-07-14 02:35:18 +00:00
Kevin Enderby b9e053cfd7 Matching change for lld for the llvm change of Archive::create() from ErrorOr<...> to Expected<...> in r274160.
llvm-svn: 274161
2016-06-29 20:36:11 +00:00
Eugene Zelenko a7a55c4d27 Fix builds broken in r267008.
llvm-svn: 267010
2016-04-21 17:27:04 +00:00
Eugene Zelenko 1a299eab32 Fix Clang-tidy misc-unused-using-decls and Include What You Use warnings.
Differential revision: http://reviews.llvm.org/D19348

llvm-svn: 267008
2016-04-21 17:14:10 +00:00
Rui Ueyama 46a8e29587 Remove dead flags.
searchArchivesToOverrideTentativeDefinitions and
searchSharedLibrariesToOverrideTentativeDefinitions are always false.
For the dead flags, we have a fairly large amount of code which is
never be executed.

http://reviews.llvm.org/D17791

llvm-svn: 264653
2016-03-28 20:59:47 +00:00
Kevin Enderby 2112b2c07d Add the needed lld change for r264187 in llvm.
Sorry had this fixed in my check out but failed mention it in my
commit message for r264187.

llvm-svn: 264188
2016-03-23 20:37:23 +00:00
Pete Cooper 8ad55fb2d0 Use owning pointers instead of raw pointers for Atom's to fix leaks.
This is a re-commit of r264022 with a fix for MSVC.  The issue there was
that the code was running DefinedAtom::~Atom() for some value and instead
needed to cast to Atom before running ~Atom.  Original commit message follows.

Currently each File contains an BumpPtrAllocator in which Atom's are
allocated.  Some Atom's contain data structures like std::vector which
leak as we don't run ~Atom when they are BumpPtrAllocate'd.

Now each File actually owns its Atom's using an OwningAtomPtr.  This
is analygous to std::unique_ptr and may be replaced by it if possible.

An Atom can therefore only be owned by a single File, so the Resolver now
moves them from one File to another.  The MachOLinkingContext owns the File's
and so clears all the Atom's in ~MachOLinkingContext, then delete's all the
File's.  This makes sure all Atom's have been destructed before any of the
BumpPtrAllocator's in which they run have gone away.

Should hopefully fix the remaining leaks.  Will keep an eye on the bots to
make sure.

llvm-svn: 264067
2016-03-22 17:15:50 +00:00
Pete Cooper 3e4d732dd0 Revert "Use owning pointers instead of raw pointers for Atom's to fix leaks."
This reverts commit r264022.

This breaks the Window's bots which don't like that i'm calling ~Atom when
the this pointer is a sublcass of Atom.

Reverting for now until I try find a better fix.  I tried using std::unique_ptr with
a custom deleter as a quick fix, but it didn't work well in the YAML parser.

llvm-svn: 264023
2016-03-22 04:00:41 +00:00
Pete Cooper 572a87e2aa Use owning pointers instead of raw pointers for Atom's to fix leaks.
Currently each File contains an BumpPtrAllocator in which Atom's are
allocated.  Some Atom's contain data structures like std::vector which
leak as we don't run ~Atom when they are BumpPtrAllocate'd.

Now each File actually owns its Atom's using an OwningAtomPtr.  This
is analygous to std::unique_ptr and may be replaced by it if possible.

An Atom can therefore only be owned by a single File, so the Resolver now
moves them from one File to another.  The MachOLinkingContext owns the File's
and so clears all the Atom's in ~MachOLinkingContext, then delete's all the
File's.  This makes sure all Atom's have been destructed before any of the
BumpPtrAllocator's in which they run have gone away.

Should hopefully fix the remaining leaks.  Will keep an eye on the bots to
make sure.

llvm-svn: 264022
2016-03-22 03:44:32 +00:00
Rui Ueyama ca5e90f83c Remove dead code.
llvm-svn: 262436
2016-03-02 00:43:37 +00:00
Rui Ueyama 947648f502 Make a few utility functions file-scoped.
makeErrorFile and parseMemberFiles are now used only in DarwinLdDriver.cpp.
This patch moves them to that file.

llvm-svn: 262423
2016-03-01 23:52:04 +00:00
Rui Ueyama 8cca07eacf Remove dead code for ELF.
The preload feature was buggy that we had disabled it even for ELF.

llvm-svn: 262194
2016-02-28 21:22:44 +00:00
Rui Ueyama 701c3250e5 Remove remaining code for COFF.
llvm-svn: 262193
2016-02-28 21:22:40 +00:00
Kevin Enderby 35dfc95efe These are the matching changes needed to the lld project for the changes to llvm
in r252192 that changed the Archive and Child interfaces in libObject. These include
Rafael Espindola’s many suggested updates.

llvm-svn: 252193
2015-11-05 19:25:47 +00:00
Rui Ueyama 1392d8b5fe Fix memory leak in FileArchive::find().
Patch from George Rimar!

llvm-svn: 248525
2015-09-24 18:59:26 +00:00
Rafael Espindola 9170a17377 Update for llvm api change.
llvm-svn: 242216
2015-07-14 22:19:09 +00:00
Rafael Espindola dbb40ab8b7 Update for upcoming llvm change.
llvm-svn: 241746
2015-07-08 22:14:36 +00:00
Rafael Espindola cd55286893 Update for llvm changes.
llvm-svn: 241298
2015-07-02 20:55:28 +00:00
Rafael Espindola bb50727e94 Update for llvm changes.
llvm-svn: 240781
2015-06-26 13:19:38 +00:00
Rafael Espindola 6759319c3c Use MemoryBufferRef instead of MemoryBuffer&. NFC.
This just reduces the noise from another patch.

llvm-svn: 235776
2015-04-24 21:10:50 +00:00
Rafael Espindola 773a159116 Simplify now that there is only one file. NFC.
llvm-svn: 235747
2015-04-24 19:01:30 +00:00
Rafael Espindola ab5696ba82 Return ErrorOr<std::unique_ptr<File>>. NFC.
llvm-svn: 235744
2015-04-24 18:51:30 +00:00
Rafael Espindola dedab912c3 Return an ErrorOr<std::unique_ptr<File>>. NFC.
llvm-svn: 235741
2015-04-24 18:33:50 +00:00
Rafael Espindola c08ab8e6e4 Delete unnecessary generality in loadFile.
loadFile could load mulitple files just because yaml has a feature for
putting multiple documents in one file.

Designing a linker around what yaml can do seems like a bad idea to
me. This patch changes it to read a single file.

There are further improvements to be done to the api and they
will follow shortly.

llvm-svn: 235724
2015-04-24 15:51:45 +00:00
Rui Ueyama de40bd4cf9 Rename atom_collection -> AtomVector.
Type names should start with an uppercase letter in the LLVM coding style.

llvm-svn: 234452
2015-04-08 23:05:59 +00:00
Rui Ueyama 142877f450 Remove unused vectors from FileArchive.
Archive files don't have any symbols (their members do).
The vectors deleted here were always empty.

llvm-svn: 234368
2015-04-07 22:32:19 +00:00
Rui Ueyama 55f5b2b277 Remove a parameter for file extension from canParse.
canParse took three parameters -- file magic, filename extension and
memory buffer. All but YAMLReader ignored the second parameter.
This patch removes the parameter.

llvm-svn: 234080
2015-04-04 02:44:36 +00:00
Rui Ueyama 394d10e34d Make File non-const in the resolver.
File objects are not really const in the resolver. We set ordinals to
them and call beforeLink hooks. Also, File's member functions marked
as const are not really const. ArchiveFile never returns the same
member file twice, so it remembers files returned before. find() has
side effects.

In order to deal with the inconsistencies, we sprinkled const_casts
and marked member varaibles as mutable.

This patch removes const from there to reflect the reality.

llvm-svn: 231212
2015-03-04 04:36:46 +00:00
Rui Ueyama cf8b003314 Revert "temporary"
This reverts accidental commit r231205.

llvm-svn: 231208
2015-03-04 02:12:55 +00:00
Rui Ueyama 5cc41029a2 Simplify FileArchive. NFC.
This patch moves local variable definitions so that their scope get narrower.
Also uses range-based loop. Both are for readability.

llvm-svn: 231206
2015-03-04 02:09:22 +00:00
Rui Ueyama f810b554ab temporary
llvm-svn: 231205
2015-03-04 02:09:21 +00:00
Rui Ueyama 302119effc Make a private function private.
llvm-svn: 231196
2015-03-04 01:26:32 +00:00
Rui Ueyama 791db5f0a3 Implement our own future and use that for FileArchive::preload().
std::promise and std::future in old version of libstdc++ are buggy.
I think that's the reason why LLD tests were flaky on Ubuntu 13
buildbots until we disabled file preloading.

In this patch, I implemented very simple future and used that in
FileArchive. Compared to std::promise and std::future, it lacks
many features, but should serve our purpose.

http://reviews.llvm.org/D8025

llvm-svn: 231153
2015-03-03 22:19:46 +00:00
Rui Ueyama dbd7f2740c Make ArchiveLibraryFile::~ArchiveLibraryFile virtual.
"virtual" was present at a wrong place. FileArchive is a subclass of
ArchiveLibraryFile, and a FileArchive can be deleted through a
pointer of ArchiveLibraryFile. We want to make the destructor of the
base class virtual.

llvm-svn: 231033
2015-03-02 23:03:33 +00:00
Rui Ueyama f038a52542 Add methods to get archive file name from member file.
Previously we only have File::path() to get the path name of a file.
If a file was a member of an archive file, path() returns a concatenated
string of the file name in the archive and the archive file name.
If we wanted to get a file name or an archive file name, we had to
parse that string. That's of course not good.

This patch adds new member functions, archivePath and memberPath, to File.

http://reviews.llvm.org/D7447

llvm-svn: 228352
2015-02-05 22:51:36 +00:00
Rui Ueyama 3a8d7e2f10 [PATCH] Speculatively instantiate archive members
LLD parses archive file index table only at first. When it finds a symbol
it is looking for is defined in a member file in an archive file, it actually
reads the member from the archive file. That's done in the core linker.

That's a single-thread process since the core linker is single threaded.
If your command line contains a few object files and a lot of archive files
(which is quite often the case), LLD hardly utilizes hardware parallelism.

This patch improves parallelism by speculatively instantiating archive
file members. At the beginning of the core linking, we first create a map
containing all symbols defined in all members, and each time we find a
new undefined symbol, we instantiate a member file containing the
symbol (if such file exists). File instantiation is side effect free, so this
should not affect correctness.

This is a quick benchmark result. Time to link self-link LLD executable:

Linux   9.78s -> 8.50s (0.86x)
Windows 6.18s -> 4.51s (0.73x)

http://reviews.llvm.org/D7015

llvm-svn: 226336
2015-01-16 22:44:50 +00:00
Rui Ueyama df230b21e3 Re-commit r225674: Convert other drivers to use WrapperNode.
The original commit had an issue with Mac OS dylib files. It didn't
handle fat binary dylib files correctly. This patch includes a fix.
A test for that case has already been committed in r225764.

llvm-svn: 226123
2015-01-15 04:34:31 +00:00
Rui Ueyama cfb2534ef8 Revert "Convert other drivers to use WrapperNode" and subsequent commits.
r225764 broke a basic functionality on Mac OS. This change reverts
r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832.

llvm-svn: 225859
2015-01-14 00:21:34 +00:00
Rui Ueyama e8ecb2b144 Convert other drivers to use WrapperNode.
llvm-svn: 225764
2015-01-13 04:33:07 +00:00
Rui Ueyama c1eeb310d4 Remove dead code.
This field was not even initialized properly.

llvm-svn: 224236
2014-12-15 07:22:29 +00:00