1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
Commit Graph

323 Commits

Author SHA1 Message Date
Jordan Rupprecht
6a91773c9e [llvm-ar] Resubmit recursive thin archive test with fix for full path names and better error messages
llvm-svn: 351256
2019-01-15 21:52:31 +00:00
Jordan Rupprecht
87022c45d5 [llvm-ar] Flatten thin archives.
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
2019-01-14 21:11:46 +00:00
Jordan Rupprecht
dcc03de9b8 [binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0
llvm-svn: 349710
2018-12-20 00:57:06 +00:00
Nico Weber
098c087057 Revert 349677, it contained a whole bunch of stuff I did not mean to commit
llvm-svn: 349678
2018-12-19 20:19:58 +00:00
Nico Weber
095ff4074a [gn build] Add build file for clang/lib/Basic and dependencies
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
2018-12-19 20:18:59 +00:00
Fangrui Song
d14eeb2c34 [llvm-ar] Strip trailing \r and format
Reviewers: mstorsjo, rupprecht, gbreynoo

Reviewed By: rupprecht

Subscribers: llvm-commits

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

llvm-svn: 345410
2018-10-26 17:38:27 +00:00
Fangrui Song
ddf4c80940 [llvm-ar] Add a dependency to BinaryFormat after rL345383
llvm-svn: 345405
2018-10-26 17:15:52 +00:00
Owen Reynolds
28caf03c9a [llvm-ar] Access ADDLIB in llvm-ar via command line
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
2018-10-26 13:34:38 +00:00
Jordan Rupprecht
a38efbda32 [llvm-ar] Use POSIX-specified timestamps for 'tv'.
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
2018-10-05 23:25:39 +00:00
Martin Storsjo
89b9151626 [llvm-ar] Move a variable declaration closer to where it is needed. NFC.
This was from a missed review comment from D51338.

llvm-svn: 341577
2018-09-06 19:03:24 +00:00
Martin Storsjo
1d8b300a4a [llvm-ar] Support * as comment char in MRI scripts
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
2018-09-06 18:10:45 +00:00
Jordan Rupprecht
805c8ee060 [Support] NFC: Allow modifying access/modification times independently in 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
2018-08-13 23:03:45 +00:00
Ben Dunbobbin
ede5cc86c7 [llvm-ar] Correct help text
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
2018-08-02 11:27:38 +00:00
Zachary Turner
2f6a8ddfe8 [FileSystem] Split up the OpenFlags enumeration.
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
2018-06-07 19:58:58 +00:00
Fangrui Song
d2ec706070 [llvm-ar] Make PositionalArgs static.
llvm-svn: 332216
2018-05-14 05:56:48 +00:00
Rui Ueyama
04fb9911c5 Define InitLLVM to do common initialization all at once.
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
2018-04-13 18:26:06 +00:00
Rui Ueyama
f077e8cbde Use contains_lower() instead of find_lower() != StringRef::npos. NFC.
llvm-svn: 329767
2018-04-10 22:58:08 +00:00
Alexandre Ganea
ae1946156c [llvm-ar] Fix lib.exe detection when running within MSVC toolchain
Differential Revision: https://reviews.llvm.org/D44808

llvm-svn: 329658
2018-04-10 01:50:25 +00:00
Peter Collingbourne
2bab1d2013 [llvm-ar] Support multiple dashed options
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
2018-03-28 17:21:14 +00:00
Dmitry Mikulin
978265857a On Windows expansion of regex file name patterns is the responsibility of each
tool. Fix ar to do that.

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

llvm-svn: 326734
2018-03-05 18:54:56 +00:00
Dmitry Mikulin
4ffb3fc4af Implementation of MRI "delete" command.
Differential Revision: https://reviews.llvm.org/D43989

llvm-svn: 326636
2018-03-02 23:23:48 +00:00
Michael Zolotukhin
66a95d7c09 Remove redundant includes from tools.
llvm-svn: 320631
2017-12-13 21:31:10 +00:00
Martin Storsjo
2af6576330 [llvm-ar] Support an options string that start with a dash
Some projects call $AR like "$AR -crs output input1 input2".

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

llvm-svn: 317358
2017-11-03 20:09:10 +00:00
Shoaib Meenai
8e98660f03 [tools] Add option to install binutils symlinks
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

llvm-svn: 317272
2017-11-02 21:43:32 +00:00
Rafael Espindola
f112256d3c Convert the archive writer to use Error.
This found one place in lld that was not checking the error.

llvm-svn: 313937
2017-09-21 23:13:36 +00:00
Rafael Espindola
4f9f7452be Don't call exit from cl::PrintHelpMessage.
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
2017-09-07 23:30:48 +00:00
Rafael Espindola
39d44034da llvm-ar: exit with 1 if there is an error.
This is pr34396.

llvm-svn: 312752
2017-09-07 22:20:38 +00:00
Rui Ueyama
49c93481ee Simplify writeArchive return type.
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
2017-08-30 22:11:03 +00:00
Martell Malone
4ec77fc2c7 llvm: add llvm-dlltool support to the archiver
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
2017-07-18 21:26:38 +00:00
Rui Ueyama
b21f190999 Revert r308329: llvm: add llvm-dlltool support to the archiver
This reverts commit r308329 because it broke buildbots.

llvm-svn: 308374
2017-07-18 21:07:13 +00:00
Martell Malone
644494b9e0 llvm: add llvm-dlltool support to the archiver
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
2017-07-18 17:39:11 +00:00
Reid Kleckner
f2fcc61612 [llvm-ar] Make llvm-lib behave more like the MSVC archiver
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
2017-06-12 19:45:35 +00:00
Reid Kleckner
61c4bb4348 [llvm-ar] Fix AddNewMember typo in enum
llvm-svn: 305209
2017-06-12 17:44:42 +00:00
Peter Collingbourne
84f566c2fb Move lib/LibDriver -> lib/ToolDrivers/llvm-lib. NFCI.
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
2017-05-13 22:06:46 +00:00
Davide Italiano
f17960676f [llvm-ar] Remove unneeded std::, NFCI.
This makes it more consistent with other exit() calls in llvm-ar
(and the tools in general).

llvm-svn: 299549
2017-04-05 15:05:05 +00:00
Davide Italiano
c830c23e31 [llvm-ar] errors go on stderr and not on stdout.
llvm-svn: 299548
2017-04-05 14:52:17 +00:00
Reid Kleckner
2f8f001e86 [llvm-ar] Extract objects to their basename in the CWD
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
2017-03-31 21:10:53 +00:00
Rafael Espindola
98752fcfe6 Don't modify archive members unless really needed.
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
2017-02-21 20:40:54 +00:00
Rafael Espindola
1343951a4e Always use / as the path separator.
It is not clear if it is worth the complexity to use \ on
windows. This should fix the bots.

llvm-svn: 288616
2016-12-04 07:27:02 +00:00
Rafael Espindola
d9678b418b Prefix path when displaying thin archives.
Patch by Mark Santaniello.

llvm-svn: 288615
2016-12-04 06:52:30 +00:00
Chris Bieneman
36f5b39c92 [CMake] llvm-ar depends on intrinsics_gen
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.

llvm-svn: 287395
2016-11-18 23:04:27 +00:00
Mehdi Amini
3d0dd0ec2c Make the Error class constructor protected
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
2016-11-11 04:28:40 +00:00
Pavel Labath
2c41526fc8 [Object] Replace TimeValue with std::chrono
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
2016-10-24 13:38:27 +00:00
Pavel Labath
6b2a0c490c Remove TimeValue usage from llvm/Support
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
2016-10-24 10:59:17 +00:00
Mehdi Amini
a6cfd067ac Turn cl::values() (for enum) from a vararg function to using C++ variadic 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
2016-10-08 19:41:06 +00:00
David Majnemer
ae16160dfe Use the range variant of find_if instead of unpacking begin/end
No functionality change is intended.

llvm-svn: 278443
2016-08-12 00:18:03 +00:00
David Majnemer
85242fb9f9 Use the range variant of find instead of unpacking begin/end
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
2016-08-11 22:21:41 +00:00
Kevin Enderby
83d2e01ea8 Clean up of libObject/Archive interfaces and change the last three uses of 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
2016-08-03 21:57:47 +00:00
Vedant Kumar
225132d711 Reapply "More fixes to get good error messages for bad archives."
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
2016-08-03 19:02:50 +00:00
Vedant Kumar
ed0e3dfc2f Revert "More fixes to get good error messages for bad archives."
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
2016-08-03 18:44:32 +00:00