[PATCH] D79797: [lld-macho] Ignore -platform_version and -syslibroot flags.
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 11:16:57 PDT 2020
thakis created this revision.
thakis added a reviewer: int3.
clang passes these flags; this makes it easier to try `clang -v`
output with `ld -flavor darwinnew`.
https://reviews.llvm.org/D79797
Files:
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/platform-version.test
Index: lld/test/MachO/platform-version.test
===================================================================
--- /dev/null
+++ lld/test/MachO/platform-version.test
@@ -0,0 +1,16 @@
+# RUN: not lld -flavor darwinnew -platform_version 2>&1 \
+# RUN: | FileCheck --check-prefix=FAIL %s
+# RUN: not lld -flavor darwinnew -platform_version macos 2>&1 \
+# RUN: | FileCheck --check-prefix=FAIL %s
+# RUN: not lld -flavor darwinnew -platform_version macos 10.15 2>&1 \
+# RUN: | FileCheck --check-prefix=FAIL %s
+# RUN: not lld -flavor darwinnew -platform_version macos -lfoo 10.15 2>&1 \
+# RUN: | FileCheck --check-prefix=FAIL %s
+# RUN: not lld -flavor darwinnew -platform_version macos 10.15 10.15.4 2>&1 \
+# RUN: | FileCheck --check-prefix=GOOD %s
+# RUN: not lld -flavor darwinnew -platform_version macos 10.15 10.15.4 foobar 2>&1 \
+# RUN: | FileCheck --check-prefix=FAIL_FILE %s
+
+FAIL: usage: -platform_version platform min_version sdk_version
+GOOD: undefined symbol: _main
+FAIL_FILE: cannot open foobar
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -32,5 +32,7 @@
def: Flag<["-"], "demangle">;
def: Flag<["-"], "dynamic">;
def: Flag<["-"], "no_deduplicate">;
+def platform_version: Flag<["-"], "platform_version">;
def: Separate<["-"], "lto_library">;
def: Separate<["-"], "macosx_version_min">;
+def: Separate<["-"], "syslibroot">;
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -131,6 +131,18 @@
return false;
}
+static void handlePlatformVersion(opt::ArgList::iterator &it,
+ const opt::ArgList::iterator &end) {
+ // -platform_version takes 3 args, which LLVM's option library doesn't
+ // support directly. So this explicitly handles that.
+ // FIXME: stash skipped args for later use.
+ for (int i = 0; i < 3; ++i) {
+ ++it;
+ if (it == end || (*it)->getOption().getID() != OPT_INPUT)
+ fatal("usage: -platform_version platform min_version sdk_version");
+ }
+}
+
bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
raw_ostream &stdoutOS, raw_ostream &stderrOS) {
lld::stdoutOS = &stdoutOS;
@@ -162,7 +174,9 @@
return !errorCount();
}
- for (opt::Arg *arg : args) {
+ for (opt::ArgList::iterator it = args.begin(), end = args.end(); it != end;
+ ++it) {
+ const opt::Arg *arg = *it;
switch (arg->getOption().getID()) {
case OPT_INPUT:
addFile(arg->getValue());
@@ -171,6 +185,10 @@
if (Optional<std::string> path = findDylib(arg->getValue()))
addFile(*path);
break;
+ case OPT_platform_version: {
+ handlePlatformVersion(it, end); // Note: Can advance "it".
+ break;
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79797.263476.patch
Type: text/x-patch
Size: 2913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200512/e8ccde07/attachment-0001.bin>
More information about the llvm-commits
mailing list