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
Rafael Espindola
24973f2b99
Use open+fstat instead of stat+open.
...
llvm-svn: 186381
2013-07-16 03:34:31 +00:00
Rafael Espindola
25c838d63e
Remember that we have a null terminated string.
...
This is a micro optimization. Instead of going char*->StringRef->Twine->char*,
go char*->Twine->char* and avoid having to copy the filename on the stack.
llvm-svn: 186380
2013-07-16 03:30:10 +00:00
Rafael Espindola
5910a296f4
Try to open the file before use data from stat.
...
Looks like on mingw we get bogus last modification times on directories.
Should fix the mingw bots.
llvm-svn: 186240
2013-07-13 05:07:22 +00:00
Rafael Espindola
a4d4dfc5bc
Remove unused file. Thanks to Sean Silva for noticing it.
...
llvm-svn: 186239
2013-07-13 04:24:33 +00:00
Rafael Espindola
9e9a37033b
Add r186216 back, but make the test tolerant of different uids and gids.
...
original message:
Fix a off by one error about which members need to use the string table.
llvm-svn: 186238
2013-07-13 04:14:13 +00:00
Chandler Carruth
40918c60f8
Revert commit r186216 -- it's breaking bots:
...
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/6897/steps/check-all/logs/LLVM%3A%3Aarchive-format.test
Original commit log:
Fix a off by one error about which members need to use the string
table.
llvm-svn: 186232
2013-07-13 00:42:56 +00:00
Rafael Espindola
d955e6ac00
Fix a off by one error about which members need to use the string table.
...
llvm-svn: 186216
2013-07-12 22:22:34 +00:00
Rafael Espindola
73b6b97cfa
fix autoconf build
...
llvm-svn: 186200
2013-07-12 20:45:01 +00:00
Rafael Espindola
d64177a6d0
Fix the build with c++03.
...
llvm-svn: 186198
2013-07-12 20:28:02 +00:00
Rafael Espindola
6c3ac6c001
Change llvm-ar to use lib/Object.
...
This fixes two bugs is lib/Object that the use in llvm-ar found:
* In OS X created archives, the name can be padded with nulls. Strip them.
* In the constructor, remember the first non special member and use that in
begin_children. This makes sure we skip all special members, not just the
first one.
The change to llvm-ar itself consist of
* Using lib/Object for reading archives instead of ArchiveReader.cpp.
* Writing the modified archive directly, instead of creating an in memory
representation.
The old Archive library was way more general than what is needed, as can
be seen by the diffstat of this patch.
Having llvm-ar using lib/Object now opens the way for creating regular symbol
tables for both native objects and bitcode files so that we can use those
archives for LTO.
llvm-svn: 186197
2013-07-12 20:21:39 +00:00
Rafael Espindola
4de1314777
Add static.
...
llvm-svn: 186170
2013-07-12 16:29:27 +00:00
Benjamin Kramer
eb6c2372ed
llvm-ar: Clean up memory management with OwningPtr.
...
llvm-svn: 186131
2013-07-11 23:15:05 +00:00
Rafael Espindola
e803be2a6b
Use %llu to print a 64 bit number. Should fix the ARM bots.
...
llvm-svn: 186113
2013-07-11 20:01:30 +00:00
Rafael Espindola
ee3ac4e4ae
InsertBefore is the same as AddBefore. Delete it.
...
llvm-svn: 186094
2013-07-11 15:54:53 +00:00
Rafael Espindola
f1b5484cf9
Fix a FIXME about the format and add a test.
...
While at it, use strftime on Unix too and use the thread safe versions
of localtime.
llvm-svn: 186090
2013-07-11 15:35:23 +00:00
Rafael Espindola
5033dd7f7f
Remove the 'N' modifier from llvm-ar.
...
* It is not present on OS X.
* It is untested.
* It is not needed for using ar in a build system.
llvm-svn: 186080
2013-07-11 13:03:27 +00:00
Rafael Espindola
0cf59a462a
Delete dead code.
...
llvm-svn: 186079
2013-07-11 12:54:11 +00:00
Rafael Espindola
6654d0be49
Remove support for truncating names in archives.
...
* All systems we support have some form of long name support.
* The options has different names and semantics in different implementations
('f' on gnu, 'T' on OS X), which makes it unlikely it is normally used on
build systems.
* It was completely untested.
llvm-svn: 186078
2013-07-11 12:38:02 +00:00
Rafael Espindola
d80d5d52ec
Sync llvm-ar's help string with the options it supports.
...
llvm-svn: 186076
2013-07-11 12:28:36 +00:00
Rafael Espindola
80b3c47cc6
Create files with the correct permission instead of changing it afterwards.
...
No intended functionality change.
llvm-svn: 185832
2013-07-08 16:16:51 +00:00
Manuel Klimek
1741a5940a
Fixes problem when calling llvm-ar from an unmodifiable directory.
...
This fixes a regression introduced by r185726: the new call to get
a unique file does not prepend the system temporary directory, so
we need to anchor on the file that the temporary file gets moved
to to ensure we're on the same file system.
llvm-svn: 185825
2013-07-08 14:44:57 +00:00
Michael Gottesman
762cf5cbf5
[llvm-ar] Added llvm_unreachable to quiet -Wreturn-type warnings.
...
llvm-svn: 185751
2013-07-06 02:39:51 +00:00
Rafael Espindola
66da97e093
Add a createUniqueFile function and switch llvm's users of unique_file.
...
This function is complementary to createTemporaryFile. It handles the case were
the unique file is *not* temporary: we will rename it in the end. Since we
will rename it, the file has to be in the same filesystem as the final
destination and we don't prepend the system temporary directory.
This has a small semantic difference from unique_file: the default mode is 0666.
This matches the behavior of most unix tools. For example, with this change
lld now produces files with the same permissions as ld. I will add a test
of this change when I port clang over to createUniqueFile (next commit).
llvm-svn: 185726
2013-07-05 21:01:08 +00:00
Rafael Espindola
92517e5f29
Don't create an archive if, for example, we are asked to print the index.
...
llvm-svn: 185697
2013-07-05 13:03:07 +00:00
Rafael Espindola
0763c1ac2e
Use simpler version of exists.
...
llvm-svn: 185695
2013-07-05 12:44:49 +00:00
Rafael Espindola
3e3580708f
Remove NoOperation.
...
parseCommandLine prints and error and exists if no operation is specified, so
it never returns NoOperation.
llvm-svn: 185691
2013-07-05 12:12:43 +00:00
Rafael Espindola
fdd1dfd455
Don't treat bitcode files specially in llvm-ar.
...
We really want bitcode files to behave as regular object files in archives, so
we don't need to track that a member is bitcode.
llvm-svn: 185681
2013-07-05 04:19:32 +00:00
Rafael Espindola
86155d2520
Use enums instead of raw octal values.
...
Patch by 罗勇刚(Yonggang Luo).
llvm-svn: 184971
2013-06-26 17:28:04 +00:00
Rafael Espindola
efb69d1b35
Create the file with the right permissions instead of setting it afterwards.
...
Removes the last use of PathV1.h in llvm-ar.
llvm-svn: 184630
2013-06-22 02:34:24 +00:00
Rafael Espindola
38fb6cd662
Convert some uses of PathV1.h in ArchiveWriter.cpp.
...
llvm-svn: 184599
2013-06-21 22:11:36 +00:00
Rafael Espindola
9c56a2e602
Add a fixme.
...
llvm-svn: 184486
2013-06-20 22:04:56 +00:00
Rafael Espindola
9636a2717e
Remove last use of PathV1.h from Archive.cpp.
...
llvm-svn: 184484
2013-06-20 22:02:10 +00:00
Rafael Espindola
695308b067
Add a setLastModificationAndAccessTime to PathV2.
...
With this we can remove the last use of PathV1 from llvm-ar.cpp.
llvm-svn: 184464
2013-06-20 20:56:14 +00:00
Rafael Espindola
8daed8070b
Use a raw_fd_ostream instead of a std::ofstream.
...
llvm-svn: 184460
2013-06-20 19:50:39 +00:00
Rafael Espindola
61a1d241a1
Remove a trivial use of sys::Path.
...
llvm-svn: 184455
2013-06-20 18:55:44 +00:00
Rafael Espindola
ffbd9ee39f
Add support for getting the last modification time from a file_status.
...
Use that in llvm-ar.cpp to replace a use of sys::PathWithStatus.
llvm-svn: 184450
2013-06-20 18:42:04 +00:00
Rafael Espindola
f1ead5434a
Use only the filename when deciding if a file is a duplicate.
...
Matches gnu ar behavior.
llvm-svn: 184448
2013-06-20 18:30:37 +00:00
Rafael Espindola
57dc6d35a3
Add r184420 back, but also handle long file names.
...
Original message:
Don't include directory names in archives.
This matches the behavior of both gnu and os x versions of ar.
llvm-svn: 184423
2013-06-20 13:41:51 +00:00
Rafael Espindola
e6a5ece5c5
Revert "Don't include directory names in archives."
...
This reverts commit 184420.
Investigating the bot failures.
llvm-svn: 184421
2013-06-20 13:23:48 +00:00
Rafael Espindola
aebd457c8d
Don't include directory names in archives.
...
This matches the behavior of both gnu and os x versions of ar.
llvm-svn: 184420
2013-06-20 13:16:44 +00:00
Rafael Espindola
0d52e64b86
Remove remaining bits of the old LLVM specific symtab handling.
...
llvm-svn: 184418
2013-06-20 13:00:30 +00:00
Rafael Espindola
293a58d01c
Remove more unused functions.
...
llvm-svn: 184416
2013-06-20 12:45:47 +00:00
Rafael Espindola
734706c20b
Remove unused methods.
...
llvm-svn: 184415
2013-06-20 12:42:00 +00:00
Rafael Espindola
b974bbf1d3
Use the simpler sys::fs::exists.
...
llvm-svn: 184413
2013-06-20 12:04:39 +00:00
Rafael Espindola
6c06452df3
Convert a use of sys::Path.
...
llvm-svn: 184412
2013-06-20 11:59:19 +00:00
Rafael Espindola
80c176d465
Remove unused function.
...
llvm-svn: 184359
2013-06-19 21:33:52 +00:00
Rafael Espindola
0449fdea82
Really fix the missing header :-(
...
llvm-svn: 184355
2013-06-19 21:21:43 +00:00
Rafael Espindola
73c8999f27
Add missing include found by the bots.
...
llvm-svn: 184354
2013-06-19 21:20:41 +00:00
Rafael Espindola
a7d761d107
Remove last use of PathV1.h from Archive.h
...
Store the individual fields we need instead of a sys::FileStatus.
llvm-svn: 184353
2013-06-19 21:13:59 +00:00