[llvm] ffea9fc - [llvm-libtool-darwin] Improve warning message for no symbols

Keith Smiley via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 3 10:34:40 PST 2022


Author: Keith Smiley
Date: 2022-02-03T10:22:06-08:00
New Revision: ffea9fc10dcd13ea3b9178a6320c7351b8778978

URL: https://github.com/llvm/llvm-project/commit/ffea9fc10dcd13ea3b9178a6320c7351b8778978
DIFF: https://github.com/llvm/llvm-project/commit/ffea9fc10dcd13ea3b9178a6320c7351b8778978.diff

LOG: [llvm-libtool-darwin] Improve warning message for no symbols

This more closely mirrors apple's libtool, and also potentially makes it
clearer for multi-arch archives where the issue lies.

Differential Revision: https://reviews.llvm.org/D118867

Added: 
    

Modified: 
    llvm/test/tools/llvm-libtool-darwin/no-symbols-warning.test
    llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-libtool-darwin/no-symbols-warning.test b/llvm/test/tools/llvm-libtool-darwin/no-symbols-warning.test
index 4e53b259a1465..9dfc334537869 100644
--- a/llvm/test/tools/llvm-libtool-darwin/no-symbols-warning.test
+++ b/llvm/test/tools/llvm-libtool-darwin/no-symbols-warning.test
@@ -9,7 +9,7 @@
 # RUN: llvm-libtool-darwin -static -o %t.lib %t-x86_64-empty.o 2>&1 | \
 # RUN:   FileCheck --check-prefix=WARNING %s -DPREFIX=%basename_t.tmp
 
-# WARNING: warning: [[PREFIX]]-x86_64-empty.o has no symbols
+# WARNING: warning: '[[PREFIX]]-x86_64-empty.o': has no symbols for architecture x86_64
 
 # RUN: llvm-libtool-darwin -no_warning_for_no_symbols -static -o %t.lib \
 # RUN:   %t-x86_64-empty.o 2>&1 | \

diff  --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
index 9355d385d6f31..a5c664c6de1d1 100644
--- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -360,8 +360,9 @@ class MembersBuilder {
 
       auto *O = dyn_cast<MachOObjectFile>(ObjOrErr->get());
       uint32_t FileCPUType, FileCPUSubtype;
+      StringRef ArchName = O->getArchTriple().getArchName();
       std::tie(FileCPUType, FileCPUSubtype) = MachO::getCPUTypeFromArchitecture(
-          MachO::getArchitectureFromName(O->getArchTriple().getArchName()));
+          MachO::getArchitectureFromName(ArchName));
 
       // If -arch_only is specified then skip this file if it doesn't match
       // the architecture specified.
@@ -370,7 +371,9 @@ class MembersBuilder {
       }
 
       if (!NoWarningForNoSymbols && O->symbols().empty())
-        WithColor::warning() << Member.MemberName + " has no symbols\n";
+        WithColor::warning() << "'" + Member.MemberName +
+                                    "': has no symbols for architecture " +
+                                    ArchName + "\n";
 
       uint64_t FileCPUID = getCPUID(FileCPUType, FileCPUSubtype);
       Builder.Data.MembersPerArchitecture[FileCPUID].push_back(


        


More information about the llvm-commits mailing list