[clang/mac] Accept -why_load and make -whyload an alias for it
authorNico Weber <thakis@chromium.org>
Sun, 7 Mar 2021 21:58:18 +0000 (16:58 -0500)
committerNico Weber <thakis@chromium.org>
Mon, 8 Mar 2021 14:11:01 +0000 (09:11 -0500)
From `man ld`:

     -why_load   Log why each object file in a static library is loaded.
                 That is, what symbol was needed.
                 Also called -whyload for compatibility.

`-why_load` is the spelling preferred by the linker and `-whyload` an old
compatibility setting. clang should accept the preferred form, and map both
forms to the preferred form.

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

clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Darwin.cpp

index 441c22c..9172215 100644 (file)
@@ -3700,7 +3700,8 @@ def weak__framework : Separate<["-"], "weak_framework">, Flags<[LinkerInput]>;
 def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>;
 def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">;
 def whatsloaded : Flag<["-"], "whatsloaded">;
-def whyload : Flag<["-"], "whyload">;
+def why_load : Flag<["-"], "why_load">;
+def whyload : Flag<["-"], "whyload">, Alias<why_load>;
 def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, Flags<[CC1Option]>,
   MarshallingInfoFlag<DiagnosticOpts<"IgnoreWarnings">>;
 def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>,
index eb7bd4a..91241ff 100644 (file)
@@ -417,7 +417,7 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
   Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
   Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
   Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
-  Args.AddLastArg(CmdArgs, options::OPT_whyload);
+  Args.AddLastArg(CmdArgs, options::OPT_why_load);
   Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
   Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
   Args.AddLastArg(CmdArgs, options::OPT_dylinker);