[PATCH] D65964: [lld-link] implement -lto-obj-path

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 16:22:37 PDT 2019


inglorion updated this revision to Diff 215708.
inglorion retitled this revision from "[lld-link] implement -thinlto-obj-path" to "[lld-link] implement -lto-obj-path".
inglorion edited the summary of this revision.
inglorion removed a subscriber: rdhindsa.
inglorion added a comment.

changed flag name to -lto-obj-path:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65964

Files:
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/COFF/Options.td
  lld/test/COFF/lto-obj-path.ll


Index: lld/test/COFF/lto-obj-path.ll
===================================================================
--- /dev/null
+++ lld/test/COFF/lto-obj-path.ll
@@ -0,0 +1,25 @@
+; REQUIRES: x86
+
+; Test to ensure that thinlto-index-only with lto-obj-path creates
+; the native object file.
+; RUN: opt -module-summary %s -o %t1.obj
+; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.obj
+; RUN: rm -f %t4.obj
+; RUN: lld-link -thinlto-index-only -lto-obj-path:%t4.obj -out:t3.exe \
+; RUN:     -entry:main %t1.obj %t2.obj
+; RUN: llvm-readobj -h %t4.obj | FileCheck %s
+; RUN: llvm-nm %t4.obj 2>&1 | FileCheck %s -check-prefix=SYMBOLS
+; RUN: llvm-nm %t4.obj 2>&1 | count 1
+
+; CHECK: Format: COFF-x86-64
+; SYMBOLS: @feat.00
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.24215"
+
+declare void @g(...)
+
+define void @main() {
+  call void (...) @g()
+  ret void
+}
Index: lld/COFF/Options.td
===================================================================
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -191,6 +191,9 @@
 def thinlto_prefix_replace: P<
     "thinlto-prefix-replace",
     "'old;new' replace old prefix with new prefix in ThinLTO outputs">;
+def lto_obj_path : P<
+    "lto-obj-path",
+    "output native object for merged LTO unit to this path">;
 def dash_dash_version : Flag<["--"], "version">,
   HelpText<"Print version information">;
 defm threads: B<"threads",
Index: lld/COFF/LTO.cpp
===================================================================
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -177,6 +177,8 @@
   // files. After that, we exit from linker and ThinLTO backend runs in a
   // distributed environment.
   if (config->thinLTOIndexOnly) {
+    if (!config->ltoObjPath.empty())
+      saveBuffer(buf[0], config->ltoObjPath);
     if (indexFile)
       indexFile->close();
     return {};
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1475,6 +1475,7 @@
       getOldNewOptions(args, OPT_thinlto_prefix_replace);
   config->thinLTOObjectSuffixReplace =
       getOldNewOptions(args, OPT_thinlto_object_suffix_replace);
+  config->ltoObjPath = args.getLastArgValue(OPT_lto_obj_path);
   // Handle miscellaneous boolean flags.
   config->allowBind = args.hasFlag(OPT_allowbind, OPT_allowbind_no, true);
   config->allowIsolation =
Index: lld/COFF/Config.h
===================================================================
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -189,6 +189,9 @@
   // Used for /thinlto-object-suffix-replace:
   std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
 
+  // Used for /lto-obj-path:
+  llvm::StringRef ltoObjPath;
+
   uint64_t align = 4096;
   uint64_t imageBase = -1;
   uint64_t fileAlign = 512;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65964.215708.patch
Type: text/x-patch
Size: 2865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190816/c7ad0862/attachment.bin>


More information about the llvm-commits mailing list