summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-ar/llvm-ar.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert r353424 "[llvm-ar][libObject] Fix relative paths when nesting thin ↵Hans Wennborg2019-02-081-51/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | archives." This broke the Chromium build on Windows, see https://crbug.com/930058 > Summary: > When adding one thin archive to another, we currently chop off the relative path to the flattened members. For instance, when adding `foo/child.a` (which contains `x.txt`) to `parent.a`, whe > lattening it we should add it as `foo/x.txt` (which exists) instead of `x.txt` (which does not exist). > > As a note, this also undoes the `IsNew` parameter of handling relative paths in r288280. The unit test there still passes. > > This was reported as part of testing the kernel build with llvm-ar: https://patchwork.kernel.org/patch/10767545/ (see the second point). > > Reviewers: mstorsjo, pcc, ruiu, davide, david2050 > > Subscribers: hiraditya, llvm-commits > > Tags: #llvm > > Differential Revision: https://reviews.llvm.org/D57842 This reverts commit bf990ab5aab03aa0aac53c9ef47ef264307804ed. llvm-svn: 353507
* [llvm-ar][libObject] Fix relative paths when nesting thin archives.Jordan Rupprecht2019-02-071-6/+51
| | | | | | | | | | | | | | | | | | | Summary: When adding one thin archive to another, we currently chop off the relative path to the flattened members. For instance, when adding `foo/child.a` (which contains `x.txt`) to `parent.a`, when flattening it we should add it as `foo/x.txt` (which exists) instead of `x.txt` (which does not exist). As a note, this also undoes the `IsNew` parameter of handling relative paths in r288280. The unit test there still passes. This was reported as part of testing the kernel build with llvm-ar: https://patchwork.kernel.org/patch/10767545/ (see the second point). Reviewers: mstorsjo, pcc, ruiu, davide, david2050 Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57842 llvm-svn: 353424
* [llvm-ar] Remove leading slash when printing thin archive membersJordan Rupprecht2019-02-061-2/+3
| | | | | | | | | | | | Reviewers: ruiu Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57845 llvm-svn: 353347
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* [llvm-ar] Resubmit recursive thin archive test with fix for full path names ↵Jordan Rupprecht2019-01-151-5/+7
| | | | | | and better error messages llvm-svn: 351256
* [llvm-ar] Flatten thin archives.Jordan Rupprecht2019-01-141-45/+45
| | | | | | | | | | | | | | | | | | | | | | Summary: Normal behavior for GNU ar is to flatten thin archives when adding them to another thin archive, i.e. add the members directly instead of nesting the archive. Some refactoring done as part of this patch to ease things: - Consolidate `addMember`/`addLibMember` methods - Rename `addMember` to `addChildMember` to make it more visibly different at the call site that an archive child is passed instead of a regular member - Pass in a separate vector and splice it back into position instead of passing a vector + optional Pos (which makes expanding libs tricky) This fixes PR37530 as raised by https://github.com/ClangBuiltLinux/linux/issues/279. Reviewers: mstorsjo, pcc, ruiu Reviewed By: mstorsjo Subscribers: llvm-commits, tpimh, nickdesaulniers Differential Revision: https://reviews.llvm.org/D56508 llvm-svn: 351120
* [binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0Jordan Rupprecht2018-12-201-8/+8
| | | | llvm-svn: 349710
* [llvm-ar] Strip trailing \r and formatFangrui Song2018-10-261-1018/+1046
| | | | | | | | | | | | Reviewers: mstorsjo, rupprecht, gbreynoo Reviewed By: rupprecht Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53769 llvm-svn: 345410
* [llvm-ar] Access ADDLIB in llvm-ar via command lineOwen Reynolds2018-10-261-979/+1018
| | | | | | | | | | ADDLIB is called to add the contents of an archive to another archive. Previously this was only accessible through the use of an MRI script. With the use of a new "L" modifier, archive files can treated in the manner above when using quick append. llvm-svn: 345383
* [llvm-ar] Use POSIX-specified timestamps for 'tv'.Jordan Rupprecht2018-10-051-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The POSIX spec says: ``` If the −t option is used with the −v option, the standard output format shall be: "%s %u/%u %u %s %d %d:%d %d %s\n", <member mode>, <user ID>, <group ID>, <number of bytes in member>, <abbreviated month>, <day-of-month>, <hour>, <minute>, <year>, <file> where: ... <abbreviated month> Equivalent to the format of the %b conversion specification format in date. <day-of-month> Equivalent to the format of the %e conversion specification format in date. <hour> Equivalent to the format of the %H conversion specification format in date. <minute> Equivalent to the format of the %M conversion specification format in date. <year> Equivalent to the format of the %Y conversion specification format in date. ``` This actually used to be the format printed by llvm-ar. It was apparently accidentally changed (see r207385 followed by comments in r207387). This makes it conform to GNU ar for easier replacement. Reviewers: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52940 llvm-svn: 343901
* [llvm-ar] Move a variable declaration closer to where it is needed. NFC.Martin Storsjo2018-09-061-1/+1
| | | | | | This was from a missed review comment from D51338. llvm-svn: 341577
* [llvm-ar] Support * as comment char in MRI scriptsMartin Storsjo2018-09-061-1/+6
| | | | | | | | | | | | MRI scripts have two comment chars, * and ;, but only the latter was supported before. Also allow leading spaces before comment chars (and before any command string), and allow comments after a command. Differential Revision: https://reviews.llvm.org/D51338 llvm-svn: 341571
* [Support] NFC: Allow modifying access/modification times independently in ↵Jordan Rupprecht2018-08-131-1/+1
| | | | | | | | | | | | | | | | | sys::fs::setLastModificationAndAccessTime. Summary: Add an overload to sys::fs::setLastModificationAndAccessTime that allows setting last access and modification times separately. This will allow tools to use this API when they want to preserve both the access and modification times from an input file, which may be different. Also note that both the POSIX (futimens/futimes) and Windows (SetFileTime) APIs take the two timestamps in the order of (1) access (2) modification time, so this renames the method to "setLastAccessAndModificationTime" to make it clear which timestamp is which. For existing callers, the 1-arg overload just sets both timestamps to the same thing. Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50521 llvm-svn: 339628
* [llvm-ar] Correct help textBen Dunbobbin2018-08-021-29/+27
| | | | | | | | | | | Corrected and simplified the help text. It was clearly too difficult to maintain before (see e.g. @227296) making it simpler and more consistent it should help people keep it up to date. Differential Revision: https://reviews.llvm.org/D48577 llvm-svn: 338703
* [FileSystem] Split up the OpenFlags enumeration.Zachary Turner2018-06-071-0/+1
| | | | | | | | | | | | | | | | | This breaks the OpenFlags enumeration into two separate enumerations: OpenFlags and CreationDisposition. The first controls the behavior of the API depending on whether or not the target file already exists, and is not a flags-based enum. The second controls more flags-like values. This yields a more easy to understand API, while also allowing flags to be passed to the openForRead api, where most of the values didn't make sense before. This also makes the apis more testable as it becomes easy to enumerate all the configurations which make sense, so I've added many new tests to exercise all the different values. llvm-svn: 334221
* [llvm-ar] Make PositionalArgs static.Fangrui Song2018-05-141-1/+1
| | | | llvm-svn: 332216
* Define InitLLVM to do common initialization all at once.Rui Ueyama2018-04-131-9/+4
| | | | | | | | | | | We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
* Use contains_lower() instead of find_lower() != StringRef::npos. NFC.Rui Ueyama2018-04-101-6/+6
| | | | llvm-svn: 329767
* [llvm-ar] Fix lib.exe detection when running within MSVC toolchainAlexandre Ganea2018-04-101-6/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D44808 llvm-svn: 329658
* [llvm-ar] Support multiple dashed optionsPeter Collingbourne2018-03-281-104/+171
| | | | | | | | | | | | | | | This allows syntax like: $ llvm-ar -c -r -u file.a file.o This is in addition to the other formats that are already supported: $ llvm-ar cru file.a file.o $ llvm-ar -cru file.a file.o Patch by Tom Anderson! Differential Revision: https://reviews.llvm.org/D44452 llvm-svn: 328716
* On Windows expansion of regex file name patterns is the responsibility of eachDmitry Mikulin2018-03-051-4/+10
| | | | | | | | tool. Fix ar to do that. Differential Revision: https://reviews.llvm.org/D43987 llvm-svn: 326734
* Implementation of MRI "delete" command.Dmitry Mikulin2018-03-021-1/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D43989 llvm-svn: 326636
* Remove redundant includes from tools.Michael Zolotukhin2017-12-131-4/+0
| | | | llvm-svn: 320631
* [llvm-ar] Support an options string that start with a dashMartin Storsjo2017-11-031-0/+20
| | | | | | | | Some projects call $AR like "$AR -crs output input1 input2". Differential Revision: https://reviews.llvm.org/D39538 llvm-svn: 317358
* Convert the archive writer to use Error.Rafael Espindola2017-09-211-2/+2
| | | | | | This found one place in lld that was not checking the error. llvm-svn: 313937
* Don't call exit from cl::PrintHelpMessage.Rafael Espindola2017-09-071-2/+1
| | | | | | | | | 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. llvm-svn: 312761
* llvm-ar: exit with 1 if there is an error.Rafael Espindola2017-09-071-20/+14
| | | | | | This is pr34396. llvm-svn: 312752
* Simplify writeArchive return type.Rui Ueyama2017-08-301-2/+2
| | | | | | | | | | 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 llvm-svn: 312177
* llvm: add llvm-dlltool support to the archiverMartell Malone2017-07-181-1/+5
| | | | | | | | | | | | | | | | 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 llvm-svn: 308379
* Revert r308329: llvm: add llvm-dlltool support to the archiverRui Ueyama2017-07-181-5/+1
| | | | | | This reverts commit r308329 because it broke buildbots. llvm-svn: 308374
* llvm: add llvm-dlltool support to the archiverMartell Malone2017-07-181-1/+5
| | | | | | | | | | | | | | | 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 llvm-svn: 308329
* [llvm-ar] Make llvm-lib behave more like the MSVC archiverReid Kleckner2017-06-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 305223
* [llvm-ar] Fix AddNewMember typo in enumReid Kleckner2017-06-121-4/+4
| | | | llvm-svn: 305209
* Move lib/LibDriver -> lib/ToolDrivers/llvm-lib. NFCI.Peter Collingbourne2017-05-131-1/+1
| | | | | | | This reorganisation prevents us from cluttering up the top-level lib directory with more driver libraries such as llvm-dlltool (see D29892). llvm-svn: 302995
* [llvm-ar] Remove unneeded std::, NFCI.Davide Italiano2017-04-051-2/+2
| | | | | | | This makes it more consistent with other exit() calls in llvm-ar (and the tools in general). llvm-svn: 299549
* [llvm-ar] errors go on stderr and not on stdout.Davide Italiano2017-04-051-1/+1
| | | | llvm-svn: 299548
* [llvm-ar] Extract objects to their basename in the CWDReid Kleckner2017-03-311-1/+3
| | | | | | | This is helpful when extracting objects from archives produced by MSVC's lib.exe, which users absolute paths to describe the archive members. llvm-svn: 299264
* Don't modify archive members unless really needed.Rafael Espindola2017-02-211-4/+11
| | | | | | | | | | | 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. llvm-svn: 295765
* Always use / as the path separator.Rafael Espindola2016-12-041-1/+1
| | | | | | | It is not clear if it is worth the complexity to use \ on windows. This should fix the bots. llvm-svn: 288616
* Prefix path when displaying thin archives.Rafael Espindola2016-12-041-0/+5
| | | | | | Patch by Mark Santaniello. llvm-svn: 288615
* Make the Error class constructor protectedMehdi Amini2016-11-111-4/+4
| | | | | | | | | 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 llvm-svn: 286561
* [Object] Replace TimeValue with std::chronoPavel Labath2016-10-241-1/+1
| | | | | | | | | | | | | | | 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 llvm-svn: 284974
* Remove TimeValue usage from llvm/SupportPavel Labath2016-10-241-5/+6
| | | | | | | | | | | | | | | | | 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 llvm-svn: 284966
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-1/+1
| | | | | | | | | | | | | | | 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 llvm-svn: 283671
* Use the range variant of find_if instead of unpacking begin/endDavid Majnemer2016-08-121-4/+3
| | | | | | No functionality change is intended. llvm-svn: 278443
* Use the range variant of find instead of unpacking begin/endDavid Majnemer2016-08-111-1/+1
| | | | | | | | | If the result of the find is only used to compare against end(), just use is_contained instead. No functionality change is intended. llvm-svn: 278433
* Clean up of libObject/Archive interfaces and change the last three uses of ↵Kevin Enderby2016-08-031-3/+5
| | | | | | | | | | | | 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. llvm-svn: 277656
* Reapply "More fixes to get good error messages for bad archives."Vedant Kumar2016-08-031-8/+23
| | | | | | | | 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. llvm-svn: 277630
* Revert "More fixes to get good error messages for bad archives."Vedant Kumar2016-08-031-23/+8
| | | | | | | | | | | | | 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; ~~~~~~~~ ^ llvm-svn: 277627
* More fixes to get good error messages for bad archives.Kevin Enderby2016-08-021-8/+23
| | | | | | | Fixed the last incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. llvm-svn: 277540
OpenPOWER on IntegriCloud