[lld] 7afbf31 - [lld-macho] minimally handle option -dynamic

Greg McGary via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 08:05:13 PDT 2020


Author: Greg McGary
Date: 2020-09-22T08:03:44-07:00
New Revision: 7afbf3192dc5690285edbfb336c061a9d43e247e

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

LOG: [lld-macho] minimally handle option -dynamic

Stifle the warning for unimplemented option `-dyamic`, since it is already the default. Add `Config::staticLink` and skeletal support for altering the flag, but otherwise leave the option `-static` as hidden and its warning in place.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 5fbb477c1993..47b4cb679613 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -35,6 +35,7 @@ struct Configuration {
   bool hasReexports = false;
   bool allLoad = false;
   bool forceLoadObjC = false;
+  bool staticLink = false;
   uint32_t headerPad;
   llvm::StringRef installName;
   llvm::StringRef outputFile;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index cda82ecd5630..71af294f6829 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -525,6 +525,9 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
   config->runtimePaths = args::getStrings(args, OPT_rpath);
   config->allLoad = args.hasArg(OPT_all_load);
 
+  if (const opt::Arg *arg = args.getLastArg(OPT_static, OPT_dynamic))
+    config->staticLink = (arg->getOption().getID() == OPT_static);
+
   std::vector<StringRef> &roots = config->systemLibraryRoots;
   for (const Arg *arg : args.filtered(OPT_syslibroot))
     roots.push_back(arg->getValue());
@@ -603,6 +606,7 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
     case OPT_arch:
     case OPT_syslibroot:
     case OPT_sectcreate:
+    case OPT_dynamic:
       // handled elsewhere
       break;
     default:

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index e53c1bd87ecd..73e3ae8e1be9 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -37,7 +37,6 @@ def dylinker : Flag<["-"], "dylinker">,
      Group<grp_kind>;
 def dynamic : Flag<["-"], "dynamic">,
      HelpText<"Link dynamically (default)">,
-     Flags<[HelpHidden]>,
      Group<grp_kind>;
 def static : Flag<["-"], "static">,
      HelpText<"Link statically">,


        


More information about the llvm-commits mailing list