File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 13
13
14
14
#include " llvm/ToolDrivers/llvm-lib/LibDriver.h"
15
15
#include " llvm/ADT/STLExtras.h"
16
+ #include " llvm/ADT/StringSet.h"
16
17
#include " llvm/BinaryFormat/COFF.h"
17
18
#include " llvm/BinaryFormat/Magic.h"
18
19
#include " llvm/Bitcode/BitcodeReader.h"
@@ -315,6 +316,7 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
315
316
}
316
317
317
318
std::vector<std::unique_ptr<MemoryBuffer>> MBs;
319
+ StringSet<> Seen;
318
320
std::vector<NewArchiveMember> Members;
319
321
320
322
// Create a NewArchiveMember for each input file.
@@ -326,6 +328,16 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
326
328
return 1 ;
327
329
}
328
330
331
+ // Input files are uniquified by pathname. If you specify the exact same
332
+ // path more than once, all but the first one are ignored.
333
+ //
334
+ // Note that there's a loophole in the rule; you can prepend `.\` or
335
+ // something like that to a path to make it look different, and they are
336
+ // handled as if they were different files. This behavior is compatible with
337
+ // Microsoft lib.exe.
338
+ if (!Seen.insert (Path).second )
339
+ continue ;
340
+
329
341
// Open a file.
330
342
ErrorOr<std::unique_ptr<MemoryBuffer>> MOrErr =
331
343
MemoryBuffer::getFile (Path, -1 , false );
Original file line number Diff line number Diff line change
1
+ If the same file is specified more than once as an input file,
2
+ llvm-lib should ignore all but the first occurrence of the file.
3
+
4
+ RUN: rm -rf %t
5
+ RUN: mkdir -p %t
6
+
7
+ RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t/foo.o %S/Inputs/a.s
8
+ RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t/bar.o %S/Inputs/b.s
9
+ RUN: llvm-lib -out:%t/foo.lib %t/foo.o %t/foo.o %t/bar.o
10
+
11
+ RUN: llvm-ar t %t/foo.lib | FileCheck %s
12
+ CHECK: foo.o
13
+ CHECK-NOT: foo.o
14
+ CHECK: bar.o
You can’t perform that action at this time.
0 commit comments