[lld] r324332 - Revert r324322 "[ELF] - Use InitTargetOptionsFromCodeGenFlags/ParseCommandLineOptions for parsing LTO options."

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 02:31:02 PST 2018


Author: grimar
Date: Tue Feb  6 02:31:01 2018
New Revision: 324332

URL: http://llvm.org/viewvc/llvm-project?rev=324332&view=rev
Log:
Revert r324322 "[ELF] - Use InitTargetOptionsFromCodeGenFlags/ParseCommandLineOptions for parsing LTO options."

It broke BB:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/8162


Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/test/ELF/lto-plugin-ignore.s

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=324332&r1=324331&r2=324332&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Feb  6 02:31:01 2018
@@ -42,7 +42,6 @@
 #include "lld/Common/Driver.h"
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Memory.h"
-#include "lld/Common/TargetOptionsCommandFlags.h"
 #include "lld/Common/Threads.h"
 #include "lld/Common/Version.h"
 #include "llvm/ADT/StringExtras.h"
@@ -253,11 +252,18 @@ void LinkerDriver::addLibrary(StringRef
 // LTO calls LLVM functions to compile bitcode files to native code.
 // Technically this can be delayed until we read bitcode files, but
 // we don't bother to do lazily because the initialization is fast.
-static void initLLVM() {
+static void initLLVM(opt::InputArgList &Args) {
   InitializeAllTargets();
   InitializeAllTargetMCs();
   InitializeAllAsmPrinters();
   InitializeAllAsmParsers();
+
+  // Parse and evaluate -mllvm options.
+  std::vector<const char *> V;
+  V.push_back("lld (LLVM option parsing)");
+  for (auto *Arg : Args.filtered(OPT_mllvm))
+    V.push_back(Arg->getValue());
+  cl::ParseCommandLineOptions(V.size(), V.data());
 }
 
 // Some command line options or some combinations of them are not allowed.
@@ -366,7 +372,7 @@ void LinkerDriver::main(ArrayRef<const c
   }
 
   readConfigs(Args);
-  initLLVM();
+  initLLVM(Args);
   createFiles(Args);
   inferMachineType();
   setConfigs(Args);
@@ -690,7 +696,6 @@ void LinkerDriver::readConfigs(opt::Inpu
   Config->ZWxneeded = hasZOption(Args, "wxneeded");
 
   // Parse LTO plugin-related options for compatibility with gold.
-  std::vector<const char *> LTOOptions({Config->Argv[0].data()});
   for (auto *Arg : Args.filtered(OPT_plugin_opt)) {
     StringRef S = Arg->getValue();
     if (S == "disable-verify")
@@ -704,13 +709,11 @@ void LinkerDriver::readConfigs(opt::Inpu
     else if (S.startswith("jobs="))
       Config->ThinLTOJobs = parseInt(S.substr(5), Arg);
     else if (!S.startswith("/") && !S.startswith("-fresolution=") &&
-             !S.startswith("-pass-through="))
-      LTOOptions.push_back(S.data());
+             !S.startswith("-pass-through=") && !S.startswith("mcpu=") &&
+             !S.startswith("thinlto") && S != "-function-sections" &&
+             S != "-data-sections")
+      error(Arg->getSpelling() + ": unknown option: " + S);
   }
-  // Parse and evaluate -mllvm options.
-  for (auto *Arg : Args.filtered(OPT_mllvm))
-    LTOOptions.push_back(Arg->getValue());
-  cl::ParseCommandLineOptions(LTOOptions.size(), LTOOptions.data());
 
   if (Config->LTOO > 3)
     error("invalid optimization level for LTO: " + Twine(Config->LTOO));

Modified: lld/trunk/test/ELF/lto-plugin-ignore.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto-plugin-ignore.s?rev=324332&r1=324331&r2=324332&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto-plugin-ignore.s (original)
+++ lld/trunk/test/ELF/lto-plugin-ignore.s Tue Feb  6 02:31:01 2018
@@ -5,7 +5,7 @@
 # RUN:   -plugin-opt=-pass-through=-lgcc -plugin-opt=-function-sections \
 # RUN:   -plugin-opt=-data-sections -o /dev/null
 
-# RUN: not ld.lld %t -plugin-opt=-data-sectionxxx \
-# RUN:   -plugin-opt=-function-sectionxxx 2>&1 | FileCheck %s
-# CHECK: Unknown command line argument '-data-sectionxxx'
-# CHECK: Unknown command line argument '-function-sectionxxx'
+# RUN: not ld.lld %t -plugin-opt=-data-sectionssss \
+# RUN:   -plugin-opt=-function-sectionsss 2>&1 | FileCheck %s
+# CHECK: unknown option: -data-sectionsss
+# CHECK: unknown option: -function-sectionsss




More information about the llvm-commits mailing list