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

303 Commits

Author SHA1 Message Date
Davide Italiano
87f81cd4cc [llvm-ar] Use fail() helper to reduce duplication.
llvm-svn: 253139
2015-11-14 18:33:47 +00:00
Davide Italiano
8d119234ad [llvm-ar] Simplify the code.
llvm-svn: 253138
2015-11-14 18:25:18 +00:00
Kevin Enderby
8994e20f69 Reapply r250906 with many suggested updates from Rafael Espindola.
The needed lld matching changes to be submitted immediately next,
but this revision will cause lld failures with this alone which is expected.

This removes the eating of the error in Archive::Child::getSize() when the characters
in the size field in the archive header for the member is not a number.  To do this we
have all of the needed methods return ErrorOr to push them up until we get out of lib.
Then the tools and can handle the error in whatever way is appropriate for that tool.

So the solution is to plumb all the ErrorOr stuff through everything that touches archives.
This include its iterators as one can create an Archive object but the first or any other
Child object may fail to be created due to a bad size field in its header.

Thanks to Lang Hames on the changes making child_iterator contain an
ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add
operator overloading for * and -> .

We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash”
and using report_fatal_error() to move the error checking will cause the program to
stop, neither of which are really correct in library code. There are still some uses of
these that should be cleaned up in this library code for other than the size field.

The test cases use archives with text files so one can see the non-digit character,
in this case a ‘%’, in the size field.

These changes will require corresponding changes to the lld project.  That will be
committed immediately after this change.  But this revision will cause lld failures
with this alone which is expected.

llvm-svn: 252192
2015-11-05 19:24:56 +00:00
Rafael Espindola
b1fed5af0a This doesn't need a object::Archive::child_iterator.
llvm-svn: 251796
2015-11-02 13:30:46 +00:00
Rafael Espindola
4411a45b5e Make a few definitions static. NFC.
llvm-svn: 251759
2015-11-01 00:14:59 +00:00
Rafael Espindola
38d8e625e7 Use Child instead of child_iterator in the archive writer.
We never need to pass end(). This will also remove some complication
once we start adding error checking.

llvm-svn: 251758
2015-11-01 00:10:37 +00:00
Ed Schouten
072b6e7dc4 Prefer ranlib mode over ar mode.
For CloudABI's toolchain I have a symlink that goes from <target>-ar and
<target>-ranlib to LLVM's ar binary, to mimick GNU Binutils' naming
scheme. The problem is that if we're targetting ARM64, the name of the
ranlib executable is aarch64-unknown-cloudabi-ranlib. This already
contains the string "ar".

Let's move the "ranlib" test above the "ar" test. It's not that likely
that we're going to see operating systems or harwdare architectures that
are called "ranlib".

Reviewed by:	rafael
Differential Revision:	http://reviews.llvm.org/D14123

llvm-svn: 251413
2015-10-27 16:37:49 +00:00
Kevin Enderby
1d015d1179 Backing out commit r250906 as it broke lld.
llvm-svn: 250908
2015-10-21 17:13:20 +00:00
Kevin Enderby
bcb0d035e4 This removes the eating of the error in Archive::Child::getSize() when the characters
in the size field in the archive header for the member is not a number.  To do this we
have all of the needed methods return ErrorOr to push them up until we get out of lib.
Then the tools and can handle the error in whatever way is appropriate for that tool.

So the solution is to plumb all the ErrorOr stuff through everything that touches archives.
This include its iterators as one can create an Archive object but the first or any other
Child object may fail to be created due to a bad size field in its header.

Thanks to Lang Hames on the changes making child_iterator contain an
ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add
operator overloading for * and -> .

We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash”
and using report_fatal_error() to move the error checking will cause the program to
stop, neither of which are really correct in library code. There are still some uses of
these that should be cleaned up in this library code for other than the size field.

Also corrected the code where the size gets us to the “at the end of the archive”
which is OK but past the end of the archive will return object_error::parse_failed now.

The test cases use archives with text files so one can see the non-digit character,
in this case a ‘%’, in the size field.

llvm-svn: 250906
2015-10-21 16:59:24 +00:00
Chris Bieneman
965f23f273 [CMake] Refactor and cleanup generating and installing symlinks to tools.
Summary: This change generalizes symlink generation and makes symlinks to tools obey LLVM_TOOLCHAIN_TOOLS. It makes it so that if you exclude llvm-ar from LLVM_TOOLCHAIN_TOOLS you don't end up with broken symlinks to llvm-lib and llvm-ranlib in your install.

Reviewers: bogner, chapuni, rafael

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12864

llvm-svn: 247632
2015-09-14 23:09:06 +00:00
Rafael Espindola
d304dca4c6 For new archive member we only need to store the full path.
We were storing both the path and the file name, which was redundant
and easy to get confused up with.

llvm-svn: 242347
2015-07-15 22:46:53 +00:00
Rafael Espindola
cb9db3a66d Handle the error of trying to convert a regular archive to a thin one.
While at it, test that we can add to a thin archive.

llvm-svn: 242330
2015-07-15 20:45:56 +00:00
Rafael Espindola
71571d65a9 Initial support for writing thin archives.
llvm-svn: 242269
2015-07-15 05:47:46 +00:00
Rafael Espindola
fadf8cbec7 Add support for reading members out of thin archives.
For now the Archive owns the buffers of the thin archive members.
This makes for a simple API, but all the buffers are destructed
only when the archive is destructed. This should be fine since we
close the files after mmap so we should not hit an open file
limit.

llvm-svn: 242215
2015-07-14 22:18:43 +00:00
Rafael Espindola
1893c5e76b llvm-ar: Don't try to extract from thin archives.
This matches the gnu ar behavior.

llvm-svn: 242162
2015-07-14 16:55:13 +00:00
Rafael Espindola
e5753ae917 llvm-ar: print an error when the requested member is not found.
llvm-svn: 242156
2015-07-14 16:02:40 +00:00
Rafael Espindola
98eeaa500c Use a range loop. NFC.
llvm-svn: 242153
2015-07-14 15:22:42 +00:00
Rafael Espindola
8be47bcf22 Add support deterministic output in llvm-ar and make it the default.
llvm-svn: 242061
2015-07-13 20:38:09 +00:00
Rafael Espindola
111ba6bab3 Create BSD archives by default on OS X.
They should probably be created on anything that is not windows or linux, but I will
test on freebsd before changing that.

With this it is possible to bootstrap with llvm-ar instead of ar+ranlib on OS X.

llvm-svn: 241849
2015-07-09 20:12:50 +00:00
Rafael Espindola
aa281f8938 Disallow Archive::child_iterator that don't point to an archive.
NFC, just less error prone.

llvm-svn: 241747
2015-07-08 22:15:07 +00:00
Rafael Espindola
116995db75 Start adding support for writing archives in BSD format.
No support for the symbol table yet (but will hopefully add it today).
We always use the long filename format so that we can align the member,
which is an advantage of the BSD format.

llvm-svn: 241721
2015-07-08 20:47:32 +00:00
David Blaikie
fadceb8c9d ArrayRef-ify libDriverMain
llvm-svn: 240234
2015-06-21 06:31:56 +00:00
Peter Collingbourne
f713e907c2 LibDriver, llvm-lib: introduce.
llvm-lib is intended to be a lib.exe compatible utility that also
understands bitcode. The implementation lives in a library so that
lld can use it to implement /lib.

Differential Revision: http://reviews.llvm.org/D10297

llvm-svn: 239434
2015-06-09 21:50:22 +00:00
Peter Collingbourne
2a2ba76ed8 llvm-ar: Move archive writer to Object.
No functional change intended, other than some minor changes to certain
diagnostics.

Differential Revision: http://reviews.llvm.org/D10296

llvm-svn: 239278
2015-06-08 02:32:01 +00:00
Benjamin Kramer
45a545b9c6 Purge unused includes throughout libSupport.
NFC.

llvm-svn: 232976
2015-03-23 18:07:13 +00:00
David Majnemer
a78e0384f4 llvm-ar: Remove unimplemented -N option from -help
This fixes PR22358.

llvm-svn: 227296
2015-01-28 06:00:01 +00:00
Aaron Ballman
909ff272a3 Manually specify the folder that llvm-ranlib should reside in for CMake-produced solutions that care about such things (like MSVC). This takes llvm-ranlib out of the root solution folder and places it into the Tools folder where it belongs.
llvm-svn: 225353
2015-01-07 14:19:15 +00:00
Rafael Espindola
c3e0e956cb Only seek once before writing the member offsets.
This cuts down the number on system calls done by a static llvm-ar producing
lib/libclangSema.a from 9164 to 442.

llvm-svn: 224025
2014-12-11 16:34:00 +00:00
Rafael Espindola
c0790c762d llvm-ar: close input files early.
We already have them mapped into memory, so we can just close the file.

llvm-svn: 224020
2014-12-11 15:16:14 +00:00
NAKAMURA Takumi
00e6cf67da [CMake] Fix installation of llvm-ranlib on multiconfig builder.
Introduce install_symlink.cmake from clang/tools/driver/clang_symlink.cmake.

FIXME: Would it be generalized?
llvm-svn: 223655
2014-12-08 13:43:38 +00:00
NAKAMURA Takumi
92f7403490 Introduce "llvm-ranlib" as a name of targets since Object/archive-symtab.test requires llvm-ranlib.
llvm-svn: 223332
2014-12-04 01:34:11 +00:00
Rafael Espindola
f1df60aeef For copy, cmake needs the full path to llvm-ar.
This should fix the windows build.

llvm-svn: 223324
2014-12-04 00:23:58 +00:00
Rafael Espindola
775946cf76 Add missing dependency on llvm-ar. Should hopefully fix the bots.
llvm-svn: 223321
2014-12-04 00:00:36 +00:00
Rafael Espindola
f6eab70376 Make llvm-ar a real build target and install it.
llvm-svn: 223309
2014-12-03 23:17:24 +00:00
Rafael Espindola
1c1edbf2dd Remove unused variable.
llvm-svn: 221549
2014-11-07 21:33:09 +00:00
Rafael Espindola
d5fc2ad2f5 Make two helper functions static.
llvm-svn: 220389
2014-10-22 15:05:51 +00:00
Rafael Espindola
c82df04466 Handle spaces and quotes in file names in MRI scripts.
llvm-svn: 220364
2014-10-22 03:10:56 +00:00
Rafael Espindola
2cfc7cef2c MRI scripts: Add addlib support.
llvm-svn: 220346
2014-10-21 23:18:51 +00:00
Rafael Espindola
57a9dbf097 Use a range loop. NFC.
llvm-svn: 220344
2014-10-21 23:04:55 +00:00
Rafael Espindola
c61ba0d3ae Overwrite instead of adding to archives when creating them in mri scripts.
This matches the behavior of GNU ar and also makes it easier to implemnt
support for the addlib command.

llvm-svn: 220336
2014-10-21 21:56:47 +00:00
Rafael Espindola
aaaa7bf04a Convert a few std::string with StringRef. NFC.
This is a micro optimization, but also makes the code a bit more flexible.

The MRIMembers variable is a short term hack. It is going away in the next
commit.

llvm-svn: 220334
2014-10-21 21:47:27 +00:00
Rafael Espindola
a68d2115f3 Use a StringRef. No functionality change.
llvm-svn: 220327
2014-10-21 21:07:49 +00:00
Rafael Espindola
05ca555aab Move code a bit to avoid a few declarations. NFC.
llvm-svn: 220317
2014-10-21 20:34:57 +00:00
Rafael Espindola
59c106d8c1 Comment cleanup. NFC.
Don't duplicate names in comments and remove useless ones. Hopefully anyone
reading this knows what main is.

llvm-svn: 220298
2014-10-21 15:49:46 +00:00
Rafael Espindola
134fc95edc Add support for addmod to mri scripts.
llvm-svn: 220294
2014-10-21 14:46:17 +00:00
Rafael Espindola
b1d09a178a llvm-ar: Start adding support for mri scripts.
I was quiet surprised to find this feature being used. Fortunately the uses
I found look fairly simple. In fact, they are just a very verbose version
of the regular ar commands.

Start implementing it then by parsing the script and setting the command
variables as if we had a regular command line.

This patch adds just enough support to create an empty archive and do a bit
of error checking. In followup patches I will implement at least addmod
and addlib.

From the description in the manual, even the more general case should not
be too hard to implement if needed. The features that don't map 1:1 to
the simple command line are

* Reading from multiple archives.
* Creating multiple archives.

llvm-svn: 219521
2014-10-10 18:33:51 +00:00
Rafael Espindola
08aa78de63 Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

llvm-svn: 216002
2014-08-19 18:44:46 +00:00
Rafael Espindola
19e7ab14ac Remove some calls to std::move.
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get
a reference to it.

Thanks to David Blaikie for the suggestion.

llvm-svn: 214516
2014-08-01 14:31:55 +00:00
Rafael Espindola
191faa331e Use std::unique_ptr to make the ownership explicit.
llvm-svn: 214377
2014-07-31 03:12:45 +00:00
NAKAMURA Takumi
59ba3fdb61 [CMake] Update libdeps.
llvm-svn: 212920
2014-07-14 05:01:53 +00:00
Rafael Espindola
858b9e1423 Update the MemoryBuffer API to use ErrorOr.
llvm-svn: 212405
2014-07-06 17:43:13 +00:00
Rafael Espindola
1972f7d7c5 Add support for inline asm symbols in llvm-ar.
This should allow llvm-ar to be used instead of gnu ar + plugin in a LTO
build. I will add a release note about it once I finish a LTO bootstrap with it.

llvm-svn: 212287
2014-07-03 19:40:08 +00:00
Alp Toker
97022b0c1f Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

llvm-svn: 211814
2014-06-26 22:52:05 +00:00
Alp Toker
fd9ead3b6f Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

llvm-svn: 211749
2014-06-26 00:00:48 +00:00
Rafael Espindola
3df1c115ec Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.
Once the objects are constructed, they own the buffer. Passing a unique_ptr
makes that clear.

llvm-svn: 211595
2014-06-24 13:56:32 +00:00
Rafael Espindola
86b258f3cd Pass a std::unique_ptr& to the create??? methods is lib/Object.
This makes the buffer ownership on error conditions very natural. The buffer
is only moved out of the argument if an object is constructed that now
owns the buffer.

llvm-svn: 211546
2014-06-23 22:00:37 +00:00
Rafael Espindola
23e5fb2297 Make ObjectFile and BitcodeReader always own the MemoryBuffer.
This allows us to just use a std::unique_ptr to store the pointer to the buffer.
The flip side is that they have to support releasing the buffer back to the
caller.

Overall this looks like a more efficient and less brittle api.

llvm-svn: 211542
2014-06-23 21:53:12 +00:00
Rafael Espindola
471fa0401b Simplify memory management with std::unique_ptr.
llvm-svn: 211538
2014-06-23 21:15:27 +00:00
Rafael Espindola
072e836a72 Add a symbols() range and use a range loop.
llvm-svn: 211222
2014-06-18 21:14:57 +00:00
Rafael Espindola
13e7a1bbb0 Simplify code.
We can delete the objects earlier now that we are copying the names to a buffer.

llvm-svn: 211221
2014-06-18 21:08:17 +00:00
Rafael Espindola
910ec52f4e Convert the Archive API to use ErrorOr.
Now that we have c++11, even things like ErrorOr<std::unique_ptr<...>> are
easy to use.

No intended functionality change.

llvm-svn: 211033
2014-06-16 16:08:36 +00:00
Rafael Espindola
0df15fc77a Finishing touch for the std::error_code transition.
While std::error_code itself seems to work OK in all platforms, there
are few annoying differences with regards to the std::errc enumeration.

This patch adds a simple llvm enumeration, which will hopefully avoid build
breakages in other platforms and surprises as we get more uses of
std::error_code.

llvm-svn: 210920
2014-06-13 17:20:48 +00:00
Rafael Espindola
5c15b3d369 Remove 'using std::error_code' from tools.
llvm-svn: 210876
2014-06-13 03:07:50 +00:00
Rafael Espindola
e0e308ff6d Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

llvm-svn: 210835
2014-06-12 21:46:39 +00:00
Rafael Espindola
d004f0c75f Don't import make_error_code into the llvm namespace.
llvm-svn: 210772
2014-06-12 11:58:49 +00:00
Rafael Espindola
cb080681ac Use std::error_code instead of llvm::error_code.
The idea of this patch is to turn llvm/Support/system_error.h into a
transitional header that just brings in the erorr_code api to the llvm
namespace. I will remove it shortly afterwards.

The cases where the general idea needed some tweaking:

* std::errc is a namespace in msvc, so we cannot use "using std::errc". I could
add an #ifdef, but there were not that many uses, so I just added std:: to
them in this patch.

* Template specialization had to be moved to the std namespace in this
patch set already.

* The msvc implementation of default_error_condition doesn't seem to
provide the same transformations as we need. Not too surprising since
the standard doesn't actually say what "equivalent" means. I fixed the
problem by keeping our old mapping and using it at error_code
construction time.

Despite these shortcomings I think this is still a good thing. Some reasons:

* The different implementations of system_error might improve over time.
* It removes 925 lines of code from llvm already.
* It removes 6313 bytes from the text segment of the clang binary when
it is built with gcc and 2816 bytes when building with clang and
libstdc++.

llvm-svn: 210687
2014-06-11 19:05:50 +00:00
Rafael Espindola
11e569dd23 Turn errc and windows_error into enum classes.
llvm-svn: 209957
2014-05-31 02:29:28 +00:00
Filipe Cabecinhas
15bb1703a1 llvm-ar: Output the file we errored on.
llvm-svn: 209500
2014-05-23 05:52:12 +00:00
Craig Topper
0e2ab5732c [C++] Use 'nullptr'. Tools edition.
llvm-svn: 207176
2014-04-25 04:24:47 +00:00
Ahmed Charles
52ce0c101e Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

llvm-svn: 203083
2014-03-06 05:51:42 +00:00
Ahmed Charles
4a96a15754 [C++11] Replace OwningPtr::take() with OwningPtr::release().
llvm-svn: 202957
2014-03-05 10:19:29 +00:00
Benjamin Kramer
803ba41365 Now that we have C++11, turn simple functors into lambdas and remove a ton of boilerplate.
No intended functionality change.

llvm-svn: 202588
2014-03-01 11:47:00 +00:00
Rafael Espindola
d89ca7eab7 Replace the F_Binary flag with a F_Text one.
After this I will set the default back to F_None. The advantage is that
before this patch forgetting to set F_Binary would corrupt a file on windows.
Forgetting to set F_Text produces one that cannot be read in notepad, which
is a better failure mode :-)

llvm-svn: 202052
2014-02-24 18:20:12 +00:00
Rafael Espindola
43f88a22f0 Add a SymbolicFile interface between Binary and ObjectFile.
This interface allows IRObjectFile to be implemented without having dummy
methods for all section and segment related methods.

Both llvm-ar and llvm-nm are changed to use it. Unfortunately the mangler is
still not plugged in since it requires some refactoring to make a Module hold
a DataLayout.

llvm-svn: 201881
2014-02-21 20:10:59 +00:00
Rafael Espindola
4abddc0b33 Change the begin and end methods in ObjectFile to match the style guide.
llvm-svn: 201108
2014-02-10 20:24:04 +00:00
Rafael Espindola
4007ec608c Simplify getSymbolFlags.
None of the object formats require extra parsing to compute these flags,
so the method cannot fail.

llvm-svn: 200574
2014-01-31 20:57:12 +00:00
Rafael Espindola
6148a226d5 Simplify the handling of iterators in ObjectFile.
None of the object file formats reported error on iterator increment. In
retrospect, that is not too surprising: no object format stores symbols or
sections in a linked list or other structure that requires chasing pointers.
As a consequence, all error checking can be done on begin() and end().

This reduces the text segment of bin/llvm-readobj in my machine from 521233 to
518526 bytes.

llvm-svn: 200442
2014-01-30 02:49:50 +00:00
Rafael Espindola
9ade36c920 Make createObjectFile's signature a bit less error prone.
This will be better with c++11, but right now file_magic converts to bool,
which makes the api really easy to misuse.

llvm-svn: 200357
2014-01-29 00:02:26 +00:00
Rafael Espindola
4ff697089b Fix c++03 build.
llvm-svn: 200042
2014-01-24 21:52:44 +00:00
Rafael Espindola
a11df1035e Make ObjectFile ownership of the MemoryBuffer optional.
This allows llvm-ar to mmap the input files only once.

llvm-svn: 200040
2014-01-24 21:32:21 +00:00
Rafael Espindola
1968b85973 Don't open or fstat files twice in llvm-ar.
We still read/mmap them twice, but the fix for that is a bit more complex.

llvm-svn: 199815
2014-01-22 16:43:45 +00:00
Rafael Espindola
a7de95d3e7 Change createObjectFile to return an ErrorOr.
llvm-svn: 199776
2014-01-22 00:14:49 +00:00
Rafael Espindola
176488ad20 Rename these methods to match the style guide.
llvm-svn: 199751
2014-01-21 16:09:45 +00:00
Rafael Espindola
878f612c22 Handle UIDs and GIDs that don't fit in 6 decimal places.
Newer unix systems have 32 bit uid and gid types, but the archive format was
not updated. Fortunately, these fields are not normally used. Just truncate
the data to fit in 6 chars.

llvm-svn: 199223
2014-01-14 17:02:09 +00:00
NAKAMURA Takumi
7644bac321 [CMake] Introduce LLVM_RUNTIME_OUTPUT_INTDIR and LLVM_LIBRARY_OUTPUT_INTDIR to reduce references to CMAKE_CFG_INTDIR.
Each of them forms like;
  ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}
  ${CMAKE_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}

llvm-svn: 197394
2013-12-16 16:03:08 +00:00
NAKAMURA Takumi
955efe24ce [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.
llvm-svn: 196908
2013-12-10 11:13:32 +00:00
NAKAMURA Takumi
ad0df78440 llvm-ar: Let opening a directory failed in llvm-ar.
Linux cannot open directories with open(2), although cygwin and *bsd can.

Motivation: The test, Object/directory.ll, had been failing with --target=cygwin on Linux. XFAIL was improper for host issues.
llvm-svn: 194257
2013-11-08 12:35:56 +00:00
Rafael Espindola
384d1f23a0 Support names like llvm-ar-3.4 and llvm-ranlib-3.4.
They are used in some packages. For example:
http://packages.ubuntu.com/saucy/i386/llvm-3.4/filelist

This fixes pr17721.

llvm-svn: 193612
2013-10-29 14:25:43 +00:00
Rafael Espindola
a44903bdb6 Fix name matching to work on windows.
llvm-svn: 189517
2013-08-28 21:00:03 +00:00
Rafael Espindola
695620f5e9 Add a minimal implementation of ranlib.
This is just enough to get "llvm-ranlib foo.a" working and tested. Making
llvm-ranlib a symbolic link to llvm-ar doesn't work so well with llvm's option
parsing, but ar's option parsing is mostly custom anyway.

This patch also removes the -X32_64 option. Looks like it was just added in
r10297 as part of implementing the current command line parsing. I can add it
back (with a test) if someone really has AIX portability problems without it.

llvm-svn: 189489
2013-08-28 16:22:16 +00:00
Rafael Espindola
ca0a1505ba Add support for the 's' operation to llvm-ar.
If no other operation is specified, 's' becomes an operation instead of an
modifier. The s operation just creates a symbol table. It is the same as
running ranlib.

We assume the archive was created by a sane ar (like llvm-ar or gnu ar) and
if the symbol table is present, then it is current. We use that to optimize
the most common case: a broken build system that thinks it has to run ranlib.

llvm-svn: 187353
2013-07-29 12:40:31 +00:00
Rafael Espindola
f3a9f67eee Split getOpenFile into getOpenFile and getOpenFileSlice.
The main observation is that we never need both the filesize and the map size.
When mapping a slice of a file, it doesn't make sense to request a null
terminator and that would be the only case where the filesize would be used.

There are other cleanups that should be done in this area:

* A client should not have to pass the size (even an explicit -1) to say if
  it wants a null terminator or not, so we should probably swap the argument
  order.
* The default should be to not require a null terminator. Very few clients
  require this, but many end up asking for it just because it is the default.

llvm-svn: 186984
2013-07-23 20:25:01 +00:00
Rafael Espindola
bc0d1fb30f Fix the build in c++03 mode.
llvm-svn: 186935
2013-07-23 11:02:16 +00:00
Rafael Espindola
081f6f185f Add an initial implementation of archive symbol table generation.
The symbol table has forward references in the file. Instead of allocating
a temporary buffer or counting the size and then writing, this implementation
writes a dummy value first and patches it once the final value is known.

There is room for performance improvement. I will implement them as soon as I
get some other features (like a ranlib mode) in.

llvm-svn: 186934
2013-07-23 10:47:01 +00:00
Rafael Espindola
9cfbdad631 Replace archive members in the old position.
This matches gnu archive behavior and since archive member order can change
which member is used, not changing the order on replacement looks like the
right thing to do.

This patch also refactors the logic for which archive member to keep and
whether to move it to a helper function (computeInsertAction). The
nesting in computeNewArchiveMembers was getting a bit confusing.

llvm-svn: 186829
2013-07-22 15:11:51 +00:00
Rafael Espindola
c2acfa8f64 Handle replacement into a position past the original member.
We were incorrectly computing where to insert a member if it was replacing
a previous member that was before the insert point.

llvm-svn: 186792
2013-07-21 12:58:07 +00:00
Rafael Espindola
e054c779bd Fix inserting new elements in a specified location.
We were only handling the 'a' and 'b' options during moves before.

llvm-svn: 186721
2013-07-19 21:23:28 +00:00
NAKAMURA Takumi
d1d48ff2e9 llvm-ar: doExtract(): Write extracted files with F_Binary. It should fix llvm/test/Object/extract.ll
llvm-svn: 186503
2013-07-17 12:31:50 +00:00
Rafael Espindola
2a9326a78f Add a wrapper for open.
This centralizes the handling of O_BINARY and opens the way for hiding more
differences (like how open behaves with directories).

llvm-svn: 186447
2013-07-16 19:44:17 +00:00
Rafael Espindola
77c12b390e On error, close the temporary file descriptor.
With this change llvm-ar can remove the temporary file on windows too.

llvm-svn: 186423
2013-07-16 16:00:32 +00:00