bool deadStrip = false;
bool errorForArchMismatch = false;
bool ignoreAutoLink = false;
+ // ld64 allows invalid auto link options as long as the link succeeds. LLD
+ // does not, but there are cases in the wild where the invalid linker options
+ // exist. This allows users to ignore the specific invalid options in the case
+ // they can't easily fix them.
+ llvm::StringSet<> ignoreAutoLinkOptions;
PlatformInfo platformInfo;
llvm::Optional<PlatformInfo> secondaryPlatformInfo;
NamespaceKind namespaceKind = NamespaceKind::twolevel;
unsigned i = 0;
StringRef arg = argv[i];
if (arg.consume_front("-l")) {
+ if (config->ignoreAutoLinkOptions.contains(arg))
+ return;
addLibrary(arg, /*isNeeded=*/false, /*isWeak=*/false,
/*isReexport=*/false, /*isHidden=*/false, /*isExplicit=*/false,
LoadType::LCLinkerOption);
} else if (arg == "-framework") {
StringRef name = argv[++i];
+ if (config->ignoreAutoLinkOptions.contains(name))
+ return;
addFramework(name, /*isNeeded=*/false, /*isWeak=*/false,
/*isReexport=*/false, /*isExplicit=*/false,
LoadType::LCLinkerOption);
getenv("LD_DYLIB_CPU_SUBTYPES_MUST_MATCH");
config->objcStubsMode = getObjCStubsMode(args);
config->ignoreAutoLink = args.hasArg(OPT_ignore_auto_link);
+ for (const Arg *arg : args.filtered(OPT_ignore_auto_link_option))
+ config->ignoreAutoLinkOptions.insert(arg->getValue());
for (const Arg *arg : args.filtered(OPT_alias)) {
config->aliasedSymbols.push_back(
def print_symbol_order_eq: Joined<["--"], "print-symbol-order=">,
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>;
+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>;
// 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
; FRAME-NEXT: name /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
; RUN: not %lld %t/framework.o -o %t/frame_no_autolink -ignore_auto_link 2>&1 | FileCheck --check-prefix=NO_AUTOLINK %s
+; RUN: not %lld %t/framework.o -o %t/frame_no_autolink --ignore-auto-link-option CoreFoundation 2>&1 | FileCheck --check-prefix=NO_AUTOLINK %s
+; RUN: not %lld %t/framework.o -o %t/frame_no_autolink --ignore-auto-link-option=CoreFoundation 2>&1 | FileCheck --check-prefix=NO_AUTOLINK %s
; NO_AUTOLINK: error: undefined symbol: __CFBigNumGetInt128
; RUN: llvm-as %t/l.ll -o %t/l.o