Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorTobias Hieta <tobias@hieta.se>2022-04-12 17:06:46 +0300
committerTobias Hieta <tobias@hieta.se>2022-04-13 11:32:44 +0300
commiteb4eef9ec4e5c4869aa76295a10e422f54951214 (patch)
treeade46a1ef40720e0b5ff20b31f5878b84b741e69 /lld
parent2978d026819b82f77eef42d92b3b53919f375bd8 (diff)
[LLD][COFF] Add support for /noimplib
Mostly for compatibility reasons with link.exe this flag makes sure we don't write a implib - not even when /implib is also passed, that's how link.exe works. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D123591
Diffstat (limited to 'lld')
-rw-r--r--lld/COFF/Config.h1
-rw-r--r--lld/COFF/Driver.cpp8
-rw-r--r--lld/COFF/Options.td2
-rw-r--r--lld/test/COFF/noimplib.test20
4 files changed, 29 insertions, 2 deletions
diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h
index 21b1b5a1db5b..8edb545cd653 100644
--- a/lld/COFF/Config.h
+++ b/lld/COFF/Config.h
@@ -140,6 +140,7 @@ struct Configuration {
// True if we are creating a DLL.
bool dll = false;
StringRef implib;
+ bool noimplib = false;
std::vector<Export> exports;
bool hadExplicitExports;
std::set<std::string> delayLoads;
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 95ab92462a97..4ae75de4586a 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1673,6 +1673,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
if (auto *arg = args.getLastArg(OPT_implib))
config->implib = arg->getValue();
+ if (auto *arg = args.getLastArg(OPT_noimplib))
+ config->noimplib = true;
+
// Handle /opt.
bool doGC = debug == DebugKind::None || args.hasArg(OPT_profile);
Optional<ICFLevel> icfLevel = None;
@@ -2022,7 +2025,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
// Handle generation of import library from a def file.
if (!args.hasArg(OPT_INPUT, OPT_wholearchive_file)) {
fixupExports();
- createImportLibrary(/*asLib=*/true);
+ if (!config->noimplib)
+ createImportLibrary(/*asLib=*/true);
return;
}
@@ -2281,7 +2285,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
// -implib option is given explicitly, for compatibility with GNU ld.
if (!config->exports.empty() || config->dll) {
fixupExports();
- if (!config->mingw || !config->implib.empty())
+ if (!config->noimplib && (!config->mingw || !config->implib.empty()))
createImportLibrary(/*asLib=*/false);
assignExportOrdinals();
}
diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index 331da34a7a90..54555fa6f92a 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -56,6 +56,8 @@ def guard : P<"guard", "Control flow guard">;
def heap : P<"heap", "Size of the heap">;
def ignore : P<"ignore", "Specify warning codes to ignore">;
def implib : P<"implib", "Import library name">;
+def noimplib : F<"noimplib">,
+ HelpText<"Don't output an import lib">;
def lib : F<"lib">,
HelpText<"Act like lib.exe; must be first argument if present">;
def libpath : P<"libpath", "Additional library search path">;
diff --git a/lld/test/COFF/noimplib.test b/lld/test/COFF/noimplib.test
new file mode 100644
index 000000000000..ba1cee76c81f
--- /dev/null
+++ b/lld/test/COFF/noimplib.test
@@ -0,0 +1,20 @@
+REQUIRES: x86
+RUN: mkdir -p %t-out
+RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t-out/object.obj %S/Inputs/object.s
+
+Test that /noimplib writes no .lib file
+
+RUN: rm -f %t-out/library.lib
+RUN: lld-link -dll -machine:x64 -def:%S/Inputs/named.def -out:%t-out/library.dll %t-out/object.obj -entry:f -subsystem:console /noimplib
+RUN: not test -f %t-out/library.lib
+
+Just make sure the normal stuff works and then we just add /noimplib
+
+RUN: lld-link -dll -machine:x64 -def:%S/Inputs/named.def -out:%t-out/library.dll %t-out/object.obj -entry:f -subsystem:console /implib:%t-out/nolibrary.lib
+RUN: test -f %t-out/nolibrary.lib
+
+Test that it overrides /implib as well. This is how link.exe works
+
+RUN: rm -f %t-out/nolibrary.lib
+RUN: lld-link -dll -machine:x64 -def:%S/Inputs/named.def -out:%t-out/library.dll %t-out/object.obj -entry:f -subsystem:console /implib:%t-out/nolibrary.lib /noimplib
+RUN: not test -f %t-out/nolibrary.lib