summaryrefslogtreecommitdiff
path: root/tools/llvm-ar
AgeCommit message (Collapse)Author
2017-12-13Remove redundant includes from tools.Michael Zolotukhin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03[llvm-ar] Support an options string that start with a dashMartin Storsjo
Some projects call $AR like "$AR -crs output input1 input2". Differential Revision: https://reviews.llvm.org/D39538 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317358 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02[tools] Add option to install binutils symlinksShoaib Meenai
The LLVM tools can be used as a replacement for binutils, in which case it's convenient to create symlinks with the binutils names. Add support for these symlinks in the build system. As with any other llvm tool symlinks, the user can limit the installed symlinks by only adding the desired ones to `LLVM_TOOLCHAIN_TOOLS`. Differential Revision: https://reviews.llvm.org/D39530 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317272 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-21Convert the archive writer to use Error.Rafael Espindola
This found one place in lld that was not checking the error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313937 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07Don't call exit from cl::PrintHelpMessage.Rafael Espindola
Most callers were not expecting the exit(0) and trying to exit with a different value. This also adds back the call to cl::PrintHelpMessage in llvm-ar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312761 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07llvm-ar: exit with 1 if there is an error.Rafael Espindola
This is pr34396. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312752 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-30Simplify writeArchive return type.Rui Ueyama
writeArchive returned a pair, but the first element of the pair is always its first argument on failure, so it doesn't make sense to return it from the function. This patch change the return type so that it does't return it. Differential Revision: https://reviews.llvm.org/D37313 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312177 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18llvm: add llvm-dlltool support to the archiverMartell Malone
A PE COFF spec compliant import library generator. Intended to be used with mingw-w64. Supports: PE COFF spec (section 8, Import Library Format) PE COFF spec (Aux Format 3: Weak Externals) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D29892 This reapplies rL308329, which was reverted in rL308374 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308379 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18Revert r308329: llvm: add llvm-dlltool support to the archiverRui Ueyama
This reverts commit r308329 because it broke buildbots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308374 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18llvm: add llvm-dlltool support to the archiverMartell Malone
A PE COFF spec compliant import library generator. Intended to be used with mingw-w64. Supports: PE COFF spec (section 8, Import Library Format) PE COFF spec (Aux Format 3: Weak Externals) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D29892 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308329 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-12[llvm-ar] Make llvm-lib behave more like the MSVC archiverReid Kleckner
Summary: Use the filepath used to open the archive member as the archive member name instead of the file basename. This path might be absolute or relative. This is important because the archive member name will show up in the PDB, and we want our PDBs to look as much like MSVC's as possible. This also helps avoid an issue in our PDB module descriptor writing code, which assumes that all module names are unique. Relative paths still aren't guaranteed to be unique, but they're much better than basenames, which definitely aren't unique. Reviewers: ruiu, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33575 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305223 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-12[llvm-ar] Fix AddNewMember typo in enumReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305209 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-13Move lib/LibDriver -> lib/ToolDrivers/llvm-lib. NFCI.Peter Collingbourne
This reorganisation prevents us from cluttering up the top-level lib directory with more driver libraries such as llvm-dlltool (see D29892). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302995 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-05[llvm-ar] Remove unneeded std::, NFCI.Davide Italiano
This makes it more consistent with other exit() calls in llvm-ar (and the tools in general). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299549 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-05[llvm-ar] errors go on stderr and not on stdout.Davide Italiano
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299548 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31[llvm-ar] Extract objects to their basename in the CWDReid Kleckner
This is helpful when extracting objects from archives produced by MSVC's lib.exe, which users absolute paths to describe the archive members. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299264 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21Don't modify archive members unless really needed.Rafael Espindola
For whatever reason ld64 requires that member headers (not the member themselves) should be aligned. The only way to do that is to edit the previous member so that it ends at an aligned boundary. Since modifying data put in an archive is an undesirable property, llvm-ar should only do it when it is absolutely necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295765 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-04Always use / as the path separator.Rafael Espindola
It is not clear if it is worth the complexity to use \ on windows. This should fix the bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288616 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-04Prefix path when displaying thin archives.Rafael Espindola
Patch by Mark Santaniello. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288615 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-18[CMake] llvm-ar depends on intrinsics_genChris Bieneman
llvm-ar.cpp has the following include chain: llvm/IR/Module.h llvm/IR/Function.h llvm/IR/Argument.h llvm/IR/Attributes.h llvm/IR/Attributes.gen This means llvm-ar needs to depend on intrinsics_gen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287395 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11Make the Error class constructor protectedMehdi Amini
This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286561 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24[Object] Replace TimeValue with std::chronoPavel Labath
Summary: Most of the changes are very straight-forward. The only choice I had to make was to use second-precision time points in the Archive classes. I did this because the archive files use that precision in the on-disk representation anyway. Reviewers: rafael, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25773 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284974 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24Remove TimeValue usage from llvm/SupportPavel Labath
Summary: This is a follow-up to D25416. It removes all usages of TimeValue from llvm/Support library (except for the actual TimeValue declaration), and replaces them with appropriate usages of std::chrono. To facilitate this, I have added small utility functions for converting time points and durations into appropriate OS-specific types (FILETIME, struct timespec, ...). Reviewers: zturner, mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25730 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284966 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini
template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283671 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12Use the range variant of find_if instead of unpacking begin/endDavid Majnemer
No functionality change is intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278443 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11Use the range variant of find instead of unpacking begin/endDavid Majnemer
If the result of the find is only used to compare against end(), just use is_contained instead. No functionality change is intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278433 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03Clean up of libObject/Archive interfaces and change the last three uses of ↵Kevin Enderby
ErrorOr<> changing them to Expected<> to allow them to pass through llvm Errors. No functional change. This commit by itself will break the next lld builds.  I’ll be committing the matching change for lld immediately next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277656 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03Reapply "More fixes to get good error messages for bad archives."Vedant Kumar
This reverts commit the revert commit r277627. The build errors mentioned in r277627 were likely caused by an unclean build directory. Sorry for the noise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277630 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03Revert "More fixes to get good error messages for bad archives."Vedant Kumar
This reverts commit r277540. It breaks the build with: ../lib/Object/Archive.cpp:264:41: error: return type of out-of-line definition of 'llvm::object::ArchiveMemberHeader::getUID' differs from that in the declaration Expected<unsigned> ArchiveMemberHeader::getUID() const { ~~~~~~~~~~~~~~~~~~ ^ include/llvm/Object/Archive.h:53:12: note: previous declaration is here unsigned getUID() const; ~~~~~~~~ ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277627 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02More fixes to get good error messages for bad archives.Kevin Enderby
Fixed the last incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277540 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29The next step along the way to getting good error messages for bad archives.Kevin Enderby
As mentioned in commit log for r276686 this next step is adding a new method in the ArchiveMemberHeader class to get the full name that does proper error checking, and can be use for error messages. To do this the name of ArchiveMemberHeader::getName() is changed to ArchiveMemberHeader::getRawName() to be consistent with Archive::Child::getRawName(). Then the “new” method is the addition of a new implementation of ArchiveMemberHeader::getName() which gets the full name and provides proper error checking. Which is mostly a rewrite of what was Archive::Child::getName() and cleaning up incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. Then Archive::Child::getName() is changed to return Expected<> and use the new implementation of ArchiveMemberHeader::getName() . Also needed to change Archive::getMemoryBufferRef() with these changes to return Expected<> as well to propagate Errors up. As well as changing Archive::isThinMember() to return Expected<> . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277177 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22[llvm-ar] Document 'T' thin archive modifier (NFC)Teresa Johnson
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276457 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19Next step along the way to getting good error messages for bad archives.Kevin Enderby
This step builds on Lang Hames work to change Archive::child_iterator for better interoperation with Error/Expected. Building on that it is now possible to return an error message when the size field of an archive contains non-decimal characters. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276025 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14[Object] Re-apply r275316 now that I have the corresponding LLD patch ready.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275361 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14[Object] Revert r275316, Archive::child_iterator changes, while I update lld.Lang Hames
Should fix the bots broken by r275316. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275353 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13[Object] Change Archive::child_iterator for better interop with Error/Expected.Lang Hames
See http://reviews.llvm.org/D22079 Changes the Archive::child_begin and Archive::children to require a reference to an Error. If iterator increment fails (because the archive header is damaged) the iterator will be set to 'end()', and the error stored in the given Error&. The Error value should be checked by the user immediately after the loop. E.g.: Error Err; for (auto &C : A->children(Err)) { // Do something with archive child C. } // Check the error immediately after the loop. if (Err) return Err; Failure to check the Error will result in an abort() when the Error goes out of scope (as guaranteed by the Error class). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275316 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29Object: Replace NewArchiveIterator with a simpler NewArchiveMember class. NFCI.Peter Collingbourne
The NewArchiveIterator class has a problem: it requires too much context. Any memory buffers added to the archive must be stored within an Archive::Member, which must have an associated Archive. This makes it harder than necessary to create new archive members (or new archives entirely) from scratch using memory buffers. This patch replaces NewArchiveIterator with a NewArchiveMember class that stores just the memory buffer and the information that goes into the archive member header. Differential Revision: http://reviews.llvm.org/D21721 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274183 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29Change Archive::create() from ErrorOr<...> to Expected<...> and updateKevin Enderby
its clients. This commit will break the next lld builds. I’ll be committing the matching change for lld next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274160 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27[llvm-ar] Ignore -plugin option.Davide Italiano
binutils ar uses -plugin to specify the LTO plugin, but LLVM doesn't need this as it doesn't use a plugin for LTO. Accepting (and ignoring) the option allows interoperability with existing build systems and make downstream consumers life much easier. No objections from Rafael on this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273938 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22llvm-ar: reduce some duplication, NFCSaleem Abdulrasool
Improve the previous change by using a local function to reduce the duplication of the object file scanning. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273429 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22llvm-ar: be more clever about default formatSaleem Abdulrasool
Try to be more clever about selecting the default format. When an existing archive is used, use the type of the archive to determine the format. When existing members are present, use the first member's format to determine the format to use. If we are creating an empty archive (MRI mode) or are adding non-object members, default to the current behaviour of using the host type due to the lack of a better alternative. This aids in cross-compilation on Darwin to non-Darwin platforms which rely on GNU format archives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273373 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21llvm-ar: correct typoSaleem Abdulrasool
Default was misspelt. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273287 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith
looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272232 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-09Fix bug where temporary file would be left behind every time an archive was ↵Rafael Espindola
updated. When updating an existing archive, llvm-ar opens the old archive into a `MemoryBuffer`, does its thing, and writes the results to a temporary file. That file is then renamed to the original archive filename, thus replacing it with the updated contents. However, on Windows at least, what would happen is that the `MemoryBuffer` for the old archive would actually be an mmap'ed view of the file, so when it came time to do the rename via Win32's `ReplaceFile`, it would succeed but would be unable to fully replace the file since there would still be a handle open on it; instead, the old version got renamed to a random temporary name and left behind. Patch by Cameron! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268916 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-02Simplify. NFC.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268326 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-02Don't try to create thin bsd archives.Rafael Espindola
Not such variant has been specified yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268305 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08Fix formatting and wording of llvm-ranlib error message. NFC.Sunil Srivastava
Patch by Douglas Yung! Reviewed by Rafael Espindola git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265753 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26Remove autoconf supportChris Bieneman
Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258861 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-14[llvm-ar] Use failIfError/fail helpers.Davide Italiano
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253141 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-14[llvm-ar] Use fail() helper to reduce duplication.Davide Italiano
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253139 91177308-0d34-0410-b5e6-96231b3b80d8