[PATCH] D140225: [lld-macho] Provide an option to ignore framework-not-found errors coming from LC_LINKER_OPTIONS.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 09:56:31 PST 2022
oontvoo created this revision.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This makes it a bit easier for our current users to move to LLD and avoid these framework-not-found errors.
I know there is an existing option to list the framework(s) to be ignored but in our user-case it is not practical to do that.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140225
Files:
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/lc-linker-option.ll
Index: lld/test/MachO/lc-linker-option.ll
===================================================================
--- lld/test/MachO/lc-linker-option.ll
+++ lld/test/MachO/lc-linker-option.ll
@@ -134,6 +134,16 @@
; RUN: %lld %t/main -F %t -framework Foo -framework Foo -o /dev/null
; RUN: %lld -F %t -framework Foo -framework Foo %t/main -o /dev/null
+;; Checks that "framework not found" errors from LC_LINKER_OPTIONS are not emitted when
+;; -ignore_auto_link_errors is set.
+; RUN: %lld -ignore_auto_link_errors -ObjC %t/load-framework-foo.o %t/main.o -o %t/main-no-foo.out
+; RUN: llvm-objdump --macho --syms %t/main-no-foo.out | FileCheck %s --check-prefix=SYMS_NO_FOO
+
+;; Verify that nothing from the framework is included.
+; SYMS_NO_FOO: SYMBOL TABLE:
+; SYMS_NO_FOO-NEXT: g F __TEXT,__text _main
+; SYMS_NO_FOO-NOT: g O __DATA,__objc_data _OBJC_CLASS_$_TestClass
+
;--- framework.ll
target triple = "x86_64-apple-macosx10.15.0"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -96,11 +96,14 @@
HelpText<"Print a symbol order specified by --call-graph-profile-sort into the specified file">,
Group<grp_lld>;
def ignore_auto_link_option : Separate<["--"], "ignore-auto-link-option">,
- Group<grp_lld>;
+ Group<grp_lld>;
def ignore_auto_link_option_eq : Joined<["--"], "ignore-auto-link-option=">,
Alias<!cast<Separate>(ignore_auto_link_option)>,
HelpText<"Ignore a single auto-linked library or framework. Useful to ignore invalid options that ld64 ignores">,
Group<grp_lld>;
+def ignore_auto_link_errors : Flag<["-"], "ignore_auto_link_errors">,
+ HelpText<"Ignore framework or library not found errors if they are loaded via LC_LINKER_OPTIONS">,
+ Group<grp_lld>;
// This is a complete Options.td compiled from Apple's ld(1) manpage
// dated 2018-03-07 and cross checked with ld64 source code in repo
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -456,6 +456,8 @@
}
return;
}
+ if (loadType == LoadType::LCLinkerOption && config->ignoreAutoLinkErrors)
+ return;
error("framework not found for -framework " + name);
}
@@ -1569,6 +1571,8 @@
for (const Arg *arg : args.filtered(OPT_ignore_auto_link_option))
config->ignoreAutoLinkOptions.insert(arg->getValue());
+ config->ignoreAutoLinkErrors = args.hasArg(OPT_ignore_auto_link_errors);
+
for (const Arg *arg : args.filtered(OPT_alias)) {
config->aliasedSymbols.push_back(
std::make_pair(arg->getValue(0), arg->getValue(1)));
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -174,6 +174,10 @@
// exist. This allows users to ignore the specific invalid options in the case
// they can't easily fix them.
llvm::StringSet<> ignoreAutoLinkOptions;
+ // This is the more relaxed option to ignore all framework not found errors.
+ // In some cases, it's not practical to find and list all the framework names
+ // with --ignore-auto-link-options.
+ bool ignoreAutoLinkErrors = false;
PlatformInfo platformInfo;
std::optional<PlatformInfo> secondaryPlatformInfo;
NamespaceKind namespaceKind = NamespaceKind::twolevel;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140225.483570.patch
Type: text/x-patch
Size: 3500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221216/919a3ec5/attachment.bin>
More information about the llvm-commits
mailing list