[PATCH] D65728: [LLD] [MinGW] Add an lld specific option for requesting to delay load libraries

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 4 13:24:49 PDT 2019


mstorsjo created this revision.
mstorsjo added reviewers: ruiu, rnk.
Herald added subscribers: dexonsmith, mehdi_amini.
Herald added a project: LLVM.

With GNU tools, delayload is handled completely differently. (One creates a specific delayload import library using dlltool and then links against it instead of the normal import library.)

Instead of requiring using -Xlink=-delayload:lib.dll, we can provide an lld specific option for this.

@jacek - If this one lands, do you need it in the 9.x release branch? (I might do an llvm-mingw release from that point release, but then move on back to latest trunk when there's other changes I need from there.)


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D65728

Files:
  MinGW/Driver.cpp
  MinGW/Options.td
  test/MinGW/driver.test


Index: test/MinGW/driver.test
===================================================================
--- test/MinGW/driver.test
+++ test/MinGW/driver.test
@@ -200,3 +200,7 @@
 # RUN: ld.lld -m i386pep --help 2>&1 | FileCheck -check-prefix=HELP %s
 # HELP: USAGE:
 # HELP: --enable-auto-import
+
+RUN: ld.lld -### -m i386pep foo.o -delayload user32.dll --delayload shell32.dll | FileCheck -check-prefix DELAYLOAD %s
+RUN: ld.lld -### -m i386pep foo.o -delayload=user32.dll --delayload=shell32.dll | FileCheck -check-prefix DELAYLOAD %s
+DELAYLOAD: -delayload:user32.dll -delayload:shell32.dll
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -80,6 +80,8 @@
 def _HASH_HASH_HASH : Flag<["-"], "###">,
     HelpText<"Print (but do not run) the commands to run for this compilation">;
 def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
+def delayload: S<"delayload">, HelpText<"DLL to load only on demand">;
+def delayload_eq: J<"delayload=">, Alias<delayload>;
 def mllvm: S<"mllvm">;
 def pdb: S<"pdb">, HelpText<"Output PDB debug info file, chosen implicitly if the argument is empty">;
 def pdb_eq: J<"pdb=">, Alias<pdb>;
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -303,6 +303,8 @@
     add("-include:" + StringRef(a->getValue()));
   for (auto *a : args.filtered(OPT_undefined))
     add("-includeoptional:" + StringRef(a->getValue()));
+  for (auto *a : args.filtered(OPT_delayload))
+    add("-delayload:" + StringRef(a->getValue()));
 
   std::vector<StringRef> searchPaths;
   for (auto *a : args.filtered(OPT_L)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65728.213266.patch
Type: text/x-patch
Size: 1744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190804/748bd2df/attachment.bin>


More information about the llvm-commits mailing list