[PATCH] D105450: [lld/mac] Implement -arch_multiple

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 5 21:27:47 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG64be5b7d8713: [lld/mac] Implement -arch_multiple (authored by thakis).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105450/new/

https://reviews.llvm.org/D105450

Files:
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/Options.td
  lld/MachO/SymbolTable.cpp
  lld/test/MachO/arch-multiple.s


Index: lld/test/MachO/arch-multiple.s
===================================================================
--- /dev/null
+++ lld/test/MachO/arch-multiple.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t.o %s
+# RUN: not %lld -o %t.out -arch_multiple %t.o 2>&1 | FileCheck %s
+
+# CHECK: error: undefined symbol for arch x86_64: _foo
+
+.globl _main
+_main:
+  callq _foo
+  ret
Index: lld/MachO/SymbolTable.cpp
===================================================================
--- lld/MachO/SymbolTable.cpp
+++ lld/MachO/SymbolTable.cpp
@@ -198,7 +198,10 @@
 
 void lld::macho::treatUndefinedSymbol(const Undefined &sym, StringRef source) {
   auto message = [source, &sym]() {
-    std::string message = "undefined symbol: " + toString(sym);
+    std::string message = "undefined symbol";
+    if (config->archMultiple)
+      message += (" for arch " + getArchitectureName(config->arch())).str();
+    message += ": " + toString(sym);
     if (!source.empty())
       message += "\n>>> referenced by " + source.str();
     else
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -877,7 +877,6 @@
     Group<grp_rare>;
 def arch_multiple : Flag<["-"], "arch_multiple">,
     HelpText<"Augment error and warning messages with the architecture name">,
-    Flags<[HelpHidden]>,
     Group<grp_rare>;
 def dot : Separate<["-"], "dot">,
     MetaVarName<"<path>">,
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1139,6 +1139,7 @@
     error("--lto-O: invalid optimization level: " + Twine(config->ltoo));
   config->runtimePaths = args::getStrings(args, OPT_rpath);
   config->allLoad = args.hasArg(OPT_all_load);
+  config->archMultiple = args.hasArg(OPT_arch_multiple);
   config->forceLoadObjC = args.hasArg(OPT_ObjC);
   config->forceLoadSwift = args.hasArg(OPT_force_load_swift_libs);
   config->deadStripDylibs = args.hasArg(OPT_dead_strip_dylibs);
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -95,6 +95,7 @@
   Symbol *entry = nullptr;
   bool hasReexports = false;
   bool allLoad = false;
+  bool archMultiple = false;
   bool forceLoadObjC = false;
   bool forceLoadSwift = false;
   bool staticLink = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105450.356597.patch
Type: text/x-patch
Size: 2468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210706/86ef453d/attachment.bin>


More information about the llvm-commits mailing list