[PATCH] D117629: [lld-macho] Implement -noall_load

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 18 19:26:44 PST 2022


keith updated this revision to Diff 401075.
keith marked an inline comment as done.
keith added a comment.

Add test case for only using -noall_load


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117629

Files:
  lld/MachO/Driver.cpp
  lld/MachO/Options.td
  lld/test/MachO/archive.s


Index: lld/test/MachO/archive.s
===================================================================
--- lld/test/MachO/archive.s
+++ lld/test/MachO/archive.s
@@ -25,13 +25,19 @@
 # VISIBLE-NOT: T _undefined
 # VISIBLE-NOT: T _unused
 
-# RUN: %lld %t/test.a %t/main.o -o %t/all-load -all_load
+# RUN: %lld %t/test.a %t/main.o -o %t/all-load -noall_load -all_load
 # RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD
 # ALL-LOAD: T _bar
 # ALL-LOAD: T _boo
 # ALL-LOAD: T _main
 # ALL-LOAD: T _unused
 
+# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load -all_load -noall_load
+# RUN: llvm-nm %t/no-all-load | FileCheck %s --check-prefix NO-ALL-LOAD
+# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load-only -noall_load
+# RUN: llvm-nm %t/no-all-load-only | FileCheck %s --check-prefix NO-ALL-LOAD
+# NO-ALL-LOAD-NOT: T _unused
+
 ## Multiple archives defining the same symbols aren't an issue, due to lazy
 ## loading
 # RUN: cp %t/test.a %t/test2.a
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -223,6 +223,9 @@
 def all_load : Flag<["-"], "all_load">,
     HelpText<"Load all members of all static archive libraries">,
     Group<grp_libs>;
+def noall_load : Flag<["-"], "noall_load">,
+    HelpText<"Don't load all static members from archives, this is the default, this negates -all_load">,
+    Group<grp_libs>;
 def ObjC : Flag<["-"], "ObjC">,
     HelpText<"Load all members of static archives that are an Objective-C class or category.">,
     Group<grp_libs>;
@@ -989,10 +992,6 @@
     HelpText<"Unnecessary option: initialization and termination are roots of the dead strip graph, so never dead stripped">,
     Flags<[HelpHidden]>,
     Group<grp_deprecated>;
-def noall_load : Flag<["-"], "noall_load">,
-    HelpText<"Unnecessary option: this is already the default">,
-    Flags<[HelpHidden]>,
-    Group<grp_deprecated>;
 
 def grp_obsolete : OptionGroup<"obsolete">, HelpText<"OBSOLETE">;
 
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1295,7 +1295,7 @@
   config->thinLTOCacheDir = args.getLastArgValue(OPT_cache_path_lto);
   config->thinLTOCachePolicy = getLTOCachePolicy(args);
   config->runtimePaths = args::getStrings(args, OPT_rpath);
-  config->allLoad = args.hasArg(OPT_all_load);
+  config->allLoad = args.hasFlag(OPT_all_load, OPT_noall_load, false);
   config->archMultiple = args.hasArg(OPT_arch_multiple);
   config->applicationExtension = args.hasFlag(
       OPT_application_extension, OPT_no_application_extension, false);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117629.401075.patch
Type: text/x-patch
Size: 2676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220119/08467ab5/attachment.bin>


More information about the llvm-commits mailing list