[llvm-branch-commits] [lld] ea0029f - Revert "[mac/lld] Implement -why_load"

Nico Weber via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 2 16:02:43 PST 2020


Author: Nico Weber
Date: 2020-12-02T18:57:46-05:00
New Revision: ea0029f55da9e34a58bcc79d0af76a940f2330a6

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

LOG: Revert "[mac/lld] Implement -why_load"

This reverts commit 542d3b609dbe99a30759942271398890fc7770dc.
Seems to break check-lld. Reverting while I take a look.

Added: 
    

Modified: 
    lld/MachO/Config.h
    lld/MachO/Driver.cpp
    lld/MachO/Driver.h
    lld/MachO/DriverUtils.cpp
    lld/MachO/InputFiles.cpp
    lld/MachO/Options.td

Removed: 
    lld/test/MachO/why-load.s


################################################################################
diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index bc22680db58f..82c017063d44 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -38,7 +38,6 @@ struct Configuration {
   bool staticLink = false;
   bool isPic = false;
   bool headerPadMaxInstallNames = false;
-  bool printWhyLoad = false;
   bool searchDylibsFirst = false;
   bool saveTemps = false;
   uint32_t headerPad;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 9822ecdd9f2a..426101f4f9e1 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -275,8 +275,6 @@ static InputFile *addFile(StringRef path, bool forceLoadArchive) {
         for (const ArchiveMember &member : getArchiveMembers(*buffer)) {
           inputFiles.push_back(
               make<ObjFile>(member.mbref, member.modTime, path));
-          printWhyLoad((forceLoadArchive ? "-force_load" : "-all_load"),
-                       inputFiles.back());
         }
       }
     } else if (config->forceLoadObjC) {
@@ -293,7 +291,6 @@ static InputFile *addFile(StringRef path, bool forceLoadArchive) {
           if (hasObjCSection(member.mbref)) {
             inputFiles.push_back(
                 make<ObjFile>(member.mbref, member.modTime, path));
-            printWhyLoad("-ObjC", inputFiles.back());
           }
         }
       }
@@ -640,7 +637,6 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
   config->headerPad = args::getHex(args, OPT_headerpad, /*Default=*/32);
   config->headerPadMaxInstallNames =
       args.hasArg(OPT_headerpad_max_install_names);
-  config->printWhyLoad = args.hasArg(OPT_why_load);
   config->outputType = getOutputType(args);
   config->runtimePaths = args::getStrings(args, OPT_rpath);
   config->allLoad = args.hasArg(OPT_all_load);

diff  --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index db7c54c59966..d5625fd3873e 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -19,7 +19,6 @@ namespace lld {
 namespace macho {
 
 class DylibFile;
-class InputFile;
 
 class MachOOptTable : public llvm::opt::OptTable {
 public:
@@ -46,8 +45,6 @@ llvm::Optional<DylibFile *> makeDylibFromTAPI(llvm::MemoryBufferRef mbref,
 
 uint32_t getModTime(llvm::StringRef path);
 
-void printWhyLoad(StringRef reason, const InputFile *);
-
 } // namespace macho
 } // namespace lld
 

diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 9c09ff682286..77f76b522d7e 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "Driver.h"
-#include "Config.h"
 #include "InputFiles.h"
 
 #include "lld/Common/Args.h"
@@ -186,10 +185,3 @@ uint32_t macho::getModTime(StringRef path) {
   warn("failed to get modification time of " + path);
   return 0;
 }
-
-void macho::printWhyLoad(StringRef reason, const InputFile *f) {
-  if (!config->printWhyLoad)
-    return;
-  lld::outs() << reason << " forced load of " << toString(f)
-              << '\n';
-}

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index a24d045096c6..4fd9873bcbd3 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -621,10 +621,6 @@ void ArchiveFile::fetch(const object::Archive::Symbol &sym) {
 
   auto file = make<ObjFile>(mb, modTime, getName());
 
-  // ld64 doesn't demangle sym here even with -demangle. Match that, so
-  // intentionally no call to toMachOString() here.
-  printWhyLoad(sym.getName(), file);
-
   symbols.insert(symbols.end(), file->symbols.begin(), file->symbols.end());
   subsections.insert(subsections.end(), file->subsections.begin(),
                      file->subsections.end());

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 5b38fc650e9f..399928e8d9ae 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -426,7 +426,8 @@ def commons : Separate<["-"], "commons">,
 def grp_introspect : OptionGroup<"introspect">, HelpText<"INTROSPECTING THE LINKER">;
 
 def why_load : Flag<["-"], "why_load">,
-     HelpText<"Log why each object file is loaded from a static library">,
+     HelpText<"Log the symbol that compels loading of each object file from a static library">,
+     Flags<[HelpHidden]>,
      Group<grp_introspect>;
 def whyload : Flag<["-"], "whyload">,
      Alias<why_load>,

diff  --git a/lld/test/MachO/why-load.s b/lld/test/MachO/why-load.s
deleted file mode 100644
index e2d5c95c8846..000000000000
--- a/lld/test/MachO/why-load.s
+++ /dev/null
@@ -1,83 +0,0 @@
-# REQUIRES: x86
-# RUN: rm -rf %t
-# RUN: split-file %s %t
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/objc.o %t/objc.s
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo.o %t/foo.s
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/bar.o %t/bar.s
-# RUN: llvm-ar csr  %t/lib.a %t/objc.o %t/foo.o %t/bar.o
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s
-
-# The first line checks that we never demangle symbols in -why_load output.
-# RUN: %lld %t/main.o %t/lib.a -o /dev/null -why_load -demangle | \
-# RUN:     FileCheck %s --check-prefix=WHY
-# RUN: %lld %t/main.o -force_load %t/lib.a -o /dev/null -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYFORCE
-# RUN: %lld %t/main.o %t/lib.a -o /dev/null -all_load -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYALL
-# RUN: %lld %t/main.o -force_load %t/lib.a -o /dev/null -all_load -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYALLFORCE
-
-# RUN: %lld %t/main.o %t/lib.a -o /dev/null -ObjC -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYOBJC
-# RUN: %lld %t/main.o -force_load %t/lib.a -o /dev/null -ObjC -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYOBJCFORCE
-# RUN: %lld %t/main.o %t/lib.a -o /dev/null -ObjC -all_load -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYOBJCALL
-# RUN: %lld %t/main.o -force_load %t/lib.a -o /dev/null -ObjC -all_load -why_load | \
-# RUN:     FileCheck %s --check-prefix=WHYOBJCALLFORCE
-
-# WHY-DAG: _bar forced load of lib.a(bar.o)
-# WHY-DAG: __Z3foo forced load of lib.a(foo.o)
-# WHY-NOT: {{.*}} forced load of lib.a(objc.o)
-
-# WHYFORCE-DAG: -force_load forced load of lib.a(bar.o)
-# WHYFORCE-DAG: -force_load forced load of lib.a(foo.o)
-# WHYFORCE-DAG: -force_load forced load of lib.a(objc.o)
-
-# WHYALL-DAG: -all_load forced load of lib.a(bar.o)
-# WHYALL-DAG: -all_load forced load of lib.a(foo.o)
-# WHYALL-DAG: -all_load forced load of lib.a(objc.o)
-
-# WHYALLFORCE-DAG: -force_load forced load of lib.a(bar.o)
-# WHYALLFORCE-DAG: -force_load forced load of lib.a(foo.o)
-# WHYALLFORCE-DAG: -force_load forced load of lib.a(objc.o)
-
-# WHYOBJC-DAG: _bar forced load of lib.a(bar.o)
-# WHYOBJC-DAG: __Z3foo forced load of lib.a(foo.o)
-# WHYOBJC-DAG: -ObjC forced load of lib.a(objc.o)
-
-# WHYOBJCFORCE-DAG: -force_load forced load of lib.a(bar.o)
-# WHYOBJCFORCE-DAG: -force_load forced load of lib.a(foo.o)
-# WHYOBJCFORCE-DAG: -force_load forced load of lib.a(objc.o)
-
-# WHYOBJCALL-DAG: -all_load forced load of lib.a(bar.o)
-# WHYOBJCALL-DAG: -all_load forced load of lib.a(foo.o)
-# WHYOBJCALL-DAG: -all_load forced load of lib.a(objc.o)
-
-# WHYOBJCALLFORCE-DAG: -force_load forced load of lib.a(bar.o)
-# WHYOBJCALLFORCE-DAG: -force_load forced load of lib.a(foo.o)
-# WHYOBJCALLFORCE-DAG: -force_load forced load of lib.a(objc.o)
-
-#--- objc.s
-.section	__DATA,__objc_catlist
-.quad 0x1234
-
-#--- foo.s
-.globl __Z3foo
-__Z3foo:
-  ret
-
-#--- bar.s
-.globl _bar
-_bar:
-  callq __Z3foo
-  ret
-
-#--- main.s
-.globl _main
-_main:
-  callq _bar
-  callq __Z3foo
-  ret


        


More information about the llvm-branch-commits mailing list