summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-ar
Commit message (Collapse)AuthorAgeFilesLines
* llvm-ar: Fix MinGW compilationHans Wennborg2020-02-281-2/+1
| | | | | | | | | | | | | | | | llvm-ar is using CompareStringOrdinal which is available only starting with Windows Vista (WINVER 0x600). Fix this by hoising WindowsSupport.h, which sets _WIN32_WINNT to 0x0601, up to llvm/include/llvm/Support and use it in llvm-ar. Patch by Cristian Adam! Differential revision: https://reviews.llvm.org/D74599 (cherry picked from commit 01f9abbb50b11dd26b9ccb7cb565cc955d2b9c74) This is for https://bugs.llvm.org/show_bug.cgi?id=44907
* [llvm-ranlib] Handle -D and -U command line flagAlex Richardson2020-01-021-4/+26
| | | | | | | | | | | | | | I have been trying to build CheriBSD (a fork for FreeBSD for the CHERI CPU) with LLVM binutils instead of the default elftoolchain utilities. I noticed that building static archives was failing because ranlib is invoked with the -D flag. This failed with llvm-ranlib since it parses the -D flag as the archive path and reports an error that more than one archive has been passed. This fixes https://llvm.org/PR41707 Reviewed By: rupprecht Differential Revision: https://reviews.llvm.org/D71554
* [llvm-ar] Improve tool selection heuristicFangrui Song2019-12-101-7/+17
| | | | | | | | | | | | | | | | If llvm-ar is installed at arm-pokymllib32-linux-gnueabi-llvm-ar, it may think it is llvm-lib due to the "lib" substring. Improve the heuristic to make all the following work as intended: llvm-ar-9 (llvm-9 package on Debian) llvm-ranlib.exe Lib.exe (reported by D44808) arm-pokymllib32-linux-gnueabi-llvm-ar (reported by D71030) Reviewed By: raj.khem, rupprecht Differential Revision: https://reviews.llvm.org/D71302
* llvm-ranlib/nm: Don't print usage message except for usage errorsSam Clegg2019-11-081-26/+32
| | | | | | | Also, fix a bug in ranlib where it didn't correctly detect being run without any argument and would try to operate on the empty string. Differential Revision: https://reviews.llvm.org/D70021
* [llvm-ar] Support verbose mode for operation 'x'Fangrui Song2019-11-071-1/+5
| | | | | | Reviewed By: jhenderson, kongyi Differential Revision: https://reviews.llvm.org/D69911
* Fix uninitialized variable warning. NFCI.Simon Pilgrim2019-11-021-1/+1
|
* [llvm-ar] Implement the O modifier: display member offsets inside the archiveFangrui Song2019-10-171-12/+22
| | | | | | | | | | | | Since GNU ar 2.31, the 't' operation prints member offsets beside file names if the 'O' modifier is specified. 'O' is ignored for thin archives. Reviewed By: gbreynoo, ruiu Differential Revision: https://reviews.llvm.org/D69087 llvm-svn: 375106
* [llvm-ar] Simplify and make two global variables static. NFCFangrui Song2019-10-171-10/+4
| | | | llvm-svn: 375082
* [llvm-ar] Implement the V modifier as an alias for --versionJordan Rupprecht2019-10-161-1/+9
| | | | | | | | | | | | | | Summary: Also update the help modifier (h) so that it works as a modifier and not just as a standalone `h`. For example, `llvm-ar h` prints the help message, but `llvm-ar xh` currently prints `unknown option h`. Reviewers: MaskRay, gbreynoo Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69007 llvm-svn: 375028
* [llvm-ar] Make paths case insensitive when on windowsOwen Reynolds2019-10-161-8/+29
| | | | | | | | | When on windows gnu-ar treats member names as case insensitive. This commit implements the same behaviour. Differential Revision: https://reviews.llvm.org/D68033 llvm-svn: 375002
* Reapply [llvm-ar] Include a line number when failing to parse an MRI scriptOwen Reynolds2019-09-201-3/+16
| | | | | | | | | | | Reapply r372309 Errors that occur when reading an MRI script now include a corresponding line number. Differential Revision: https://reviews.llvm.org/D67449 llvm-svn: 372374
* [llvm-ar] Removes repetition in the error messageFangrui Song2019-09-201-2/+1
| | | | | | | | | As per bug 40244, fixed an error where the error message was repeated. Differential Revision: https://reviews.llvm.org/D67038 Patch by Yu Jian (wyjw) llvm-svn: 372370
* Revert [llvm-ar] Include a line number when failing to parse an MRI scriptOwen Reynolds2019-09-191-16/+3
| | | | | | | | Revert r372309 due to buildbot failures Differential Revision: https://reviews.llvm.org/D67449 llvm-svn: 372311
* [llvm-ar] Include a line number when failing to parse an MRI scriptOwen Reynolds2019-09-191-3/+16
| | | | | | | | | Errors that occur when reading an MRI script now include a corresponding line number. Differential Revision: https://reviews.llvm.org/D67449 llvm-svn: 372309
* [llvm-ar] Parse 'h' and '-h': display help and exitFangrui Song2019-09-171-5/+5
| | | | | | | | | | | Support `llvm-ar h` and `llvm-ar -h` because they may be what users try at first. Note, operation 'h' is undocumented in GNU ar. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D67560 llvm-svn: 372088
* [llvm-ar] Uncapitalize error messages and delete full stopFangrui Song2019-09-141-30/+29
| | | | | | | | | | | | Most GNU binutils don't append full stops in error messages. This convention has been adopted by a bunch of LLVM binary utilities. Make llvm-ar follow the convention as well. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67558 llvm-svn: 371912
* [llvm-ar][NFC] Fix buildbotJordan Rupprecht2019-08-121-1/+1
| | | | llvm-svn: 368578
* [llvm-ar] Accept file paths with windows format slashesOwen Reynolds2019-08-121-8/+8
| | | | | | | | | | | | | | | The internal representation of llvm-ar archives uses linux style slashes for paths, no matter the OS. In the case of windows this meant file paths input intending to match existing members would only match if linux style slashes where used. This change allows either slash direction to be input by the user. This change includes removing an unnecessary call to normalisePath and moving the call of another. Differential Revision: https://reviews.llvm.org/D65743 llvm-svn: 368573
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [llvm-ar] Document response file support in --helpSam Clegg2019-06-281-0/+1
| | | | | | | | Also a test for this. Differential Revision: https://reviews.llvm.org/D63836 llvm-svn: 364673
* [llvm-ar] Create thin archives with MRI scriptsOwen Reynolds2019-06-061-1/+5
| | | | | | | | This patch implements the "CREATE_THIN" MRI script command, allowing thin archives to be created via MRI scripts. Differential Revision: https://reviews.llvm.org/D62919 llvm-svn: 362704
* [llvm-ar] Reapply Fix relative thin archive path handlingOwen Reynolds2019-06-041-9/+29
| | | | | | | | | | Includes a fix for an introduced build failure due to a post c++11 use of std::mismatch. This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command. Differential Revision: https://reviews.llvm.org/D59491 llvm-svn: 362484
* Revert "[llvm-ar] Fix relative thin archive path handling"Dmitri Gribenko2019-06-031-29/+9
| | | | | | | | | | This reverts commit r362407. It broke compilation of llvm/lib/Object/ArchiveWriter.cpp: error: type 'llvm::sys::path::const_iterator' does not provide a call operator llvm-svn: 362413
* [llvm-ar] Fix relative thin archive path handlingOwen Reynolds2019-06-031-9/+29
| | | | | | | | This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command. Differential Revision: https://reviews.llvm.org/D59491 llvm-svn: 362407
* Break false dependencies on target librariesDaniel Sanders2019-05-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For the most part this consists of replacing ${LLVM_TARGETS_TO_BUILD} with some combination of AllTargets* so that they depend on specific components of a target backend rather than all of it. The overall effect of this is that, for example, tools like opt no longer falsely depend on the disassembler, while tools like llvm-ar no longer depend on the code generator. There's a couple quirks to point out here: * AllTargetsCodeGens is a bit more prevalent than expected. Tools like dsymutil seem to need it which I was surprised by. * llvm-xray linked to all the backends but doesn't seem to need any of them. It builds and passes the tests so that seems to be correct. * I left gold out as it's not built when binutils is not available so I'm unable to test it Reviewers: bogner, JDevlieghere Reviewed By: bogner Subscribers: mehdi_amini, mgorny, steven_wu, dexonsmith, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62331 llvm-svn: 361567
* [llvm-ar] Support N [count] modifierJordan Rupprecht2019-03-191-8/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: GNU ar supports the 'N' count modifier for the extract (x) and delete (d) operations. When an archive contains multiple members with the same name, this can be used to extract (or delete) them individually. For example: ``` $ llvm-ar t archive.a foo foo $ llvm-ar x archive.a -> Writes foo twice, overwriting it the second time :( :( $ llvm-ar xN 1 archive.a foo && mv foo foo.1 $ llvm-ar xN 2 archive.a foo && mv foo foo.2 -> Write foo twice, renaming it in between invocations to preserve all versions ``` Reviewers: ruiu, MaskRay Reviewed By: ruiu, MaskRay Subscribers: jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59503 llvm-svn: 356466
* [llvm-ar] Implement the P modifier.Jordan Rupprecht2019-02-141-17/+31
| | | | | | | | | | | | | | | | | | | Summary: GNU ar has a `P` modifier that changes filename comparisons to use full paths instead of the basename. As noted in the GNU docs, regular archives are not created with full path names, so P is used to deal with archives created by other archive programs (e.g. see the updated `absolute-paths.test` test case). Since thin archives use full path names -- paths are relative to the archive -- it seems very error prone to not imply P when dealing with thin archives, so P is implied in those cases. (I think this is a deviation from GNU ar that makes sense). This fixes PR37436 via https://github.com/ClangBuiltLinux/linux/issues/33. Reviewers: mstorsjo, pcc, ruiu, davide, david2050, rnk Subscribers: tpimh, llvm-commits, nickdesaulniers Tags: #llvm Differential Revision: https://reviews.llvm.org/D57927 llvm-svn: 354044
* [llvm-ar][libObject] Fix relative paths when nesting thin archives.Jordan Rupprecht2019-02-131-6/+22
| | | | | | | | | | | | | | | | | | | | | 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, inglorion Reviewed By: ruiu Subscribers: void, jdoerfert, tpimh, mgorny, hans, nickdesaulniers, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57842 llvm-svn: 353995
* 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-192-8/+6
| | | | | | | | | | | | | | | | | 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
* Revert 349677, it contained a whole bunch of stuff I did not mean to commitNico Weber2018-12-191-0/+3
| | | | llvm-svn: 349678
* [gn build] Add build file for clang/lib/Basic and dependenciesNico Weber2018-12-191-3/+0
| | | | | | | | | | | | Adds a build file for clang-tblgen and an action for running it, and uses that to process all the .td files in include/clang/Basic. Also adds an action to write include/clang/Config/config.h and include/clang/Basic/Version.inc. Differential Revision: https://reviews.llvm.org/D55847 llvm-svn: 349677
* [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] Add a dependency to BinaryFormat after rL345383Fangrui Song2018-10-261-0/+1
| | | | llvm-svn: 345405
* [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
OpenPOWER on IntegriCloud