[PATCH] D84486: [lld-macho] Support -filelist
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 10:02:35 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4853a86022fe: [lld-macho] Support -filelist (authored by int3).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84486/new/
https://reviews.llvm.org/D84486
Files:
lld/MachO/Driver.cpp
lld/test/MachO/filelist.s
lld/test/MachO/invalid/no-filelist.s
Index: lld/test/MachO/invalid/no-filelist.s
===================================================================
--- /dev/null
+++ lld/test/MachO/invalid/no-filelist.s
@@ -0,0 +1,9 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
+# RUN: not lld -flavor darwinnew -Z -filelist nonexistent %t.o -o %t 2>&1 | FileCheck %s
+# CHECK: cannot open nonexistent: No such file or directory
+
+.globl _main
+
+_main:
+ ret
Index: lld/test/MachO/filelist.s
===================================================================
--- /dev/null
+++ lld/test/MachO/filelist.s
@@ -0,0 +1,40 @@
+# REQUIRES: x86
+
+## This test verifies that the paths in -filelist get processed in command-line
+## order.
+
+# RUN: mkdir -p %t
+# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,first; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/first.o
+# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,second; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/second.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
+
+# FIRST: __TEXT,first _foo
+# SECOND: __TEXT,second _foo
+
+# RUN: echo "%t/first.o" > filelist
+# RUN: echo "%t/second.o" >> filelist
+# RUN: lld -flavor darwinnew -Z -filelist filelist %t/test.o -o %t/test
+# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=FIRST
+
+# RUN: echo "%t/second.o" > filelist
+# RUN: echo "%t/first.o" >> filelist
+# RUN: lld -flavor darwinnew -Z -filelist filelist %t/test.o -o %t/test
+# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=SECOND
+
+# RUN: echo "%t/first.o" > filelist
+# RUN: lld -flavor darwinnew -Z -filelist filelist %t/second.o %t/test.o -o %t/test
+# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=FIRST
+# RUN: lld -flavor darwinnew -Z %t/second.o -filelist filelist %t/test.o -o %t/test
+# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=SECOND
+
+# RUN: echo "%t/first.o" > filelist-1
+# RUN: echo "%t/second.o" > filelist-2
+# RUN: lld -flavor darwinnew -Z -filelist filelist-1 -filelist filelist-2 %t/test.o -o %t/test
+# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=FIRST
+# RUN: lld -flavor darwinnew -Z -filelist filelist-2 -filelist filelist-1 %t/test.o -o %t/test
+# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=SECOND
+
+.globl _main
+
+_main:
+ ret
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -213,6 +213,15 @@
}
}
+static void addFileList(StringRef path) {
+ Optional<MemoryBufferRef> buffer = readFile(path);
+ if (!buffer)
+ return;
+ MemoryBufferRef mbref = *buffer;
+ for (StringRef path : args::getLines(mbref))
+ addFile(path);
+}
+
static std::array<StringRef, 6> archNames{"arm", "arm64", "i386",
"x86_64", "ppc", "ppc64"};
static bool isArchString(StringRef s) {
@@ -411,6 +420,9 @@
case OPT_INPUT:
addFile(arg->getValue());
break;
+ case OPT_filelist:
+ addFileList(arg->getValue());
+ break;
case OPT_l: {
StringRef name = arg->getValue();
if (Optional<std::string> path = findLibrary(name)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84486.281269.patch
Type: text/x-patch
Size: 3307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200728/da7c379e/attachment.bin>
More information about the llvm-commits
mailing list