[llvm] e9827f0 - [ms] Add new option to llvm-lib: /llvmlibempty
Eric Astor via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 12:31:25 PDT 2020
Author: Eric Astor
Date: 2020-04-30T15:30:56-04:00
New Revision: e9827f0b82751687f35d21d29f86adfab63a8dd5
URL: https://github.com/llvm/llvm-project/commit/e9827f0b82751687f35d21d29f86adfab63a8dd5
DIFF: https://github.com/llvm/llvm-project/commit/e9827f0b82751687f35d21d29f86adfab63a8dd5.diff
LOG: [ms] Add new option to llvm-lib: /llvmlibempty
Summary:
Add a new option (/llvmlibempty). If passed and llvm-lib does not give an error, it will create a valid output archive even if empty.
By default, llvm-lib mimicks lib.exe: if given no input files, it doesn't create its output file at all. This is incompatible with some build systems, so we add a command-line option to toggle this compatibility behavior.
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D78894
Added:
Modified:
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/lib/ToolDrivers/llvm-lib/Options.td
llvm/test/tools/llvm-lib/no-inputs.test
Removed:
################################################################################
diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
index 3ea53126d850..69106bbeac21 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -292,8 +292,9 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
return 0;
}
- // If no input files, silently do nothing to match lib.exe.
- if (!Args.hasArgNoClaim(OPT_INPUT))
+ // If no input files and not told otherwise, silently do nothing to match
+ // lib.exe
+ if (!Args.hasArgNoClaim(OPT_INPUT) && !Args.hasArg(OPT_llvmlibempty))
return 0;
if (Args.hasArg(OPT_lst)) {
diff --git a/llvm/lib/ToolDrivers/llvm-lib/Options.td b/llvm/lib/ToolDrivers/llvm-lib/Options.td
index 7863196126a8..5891e238a328 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/Options.td
+++ b/llvm/lib/ToolDrivers/llvm-lib/Options.td
@@ -18,6 +18,9 @@ def out : P<"out", "Path to file to write output">;
def llvmlibthin : F<"llvmlibthin">,
HelpText<"Make .lib point to .obj files instead of copying their contents">;
+def llvmlibempty : F<"llvmlibempty">,
+ HelpText<"When given no contents, produce an empty .lib file">;
+
def machine: P<"machine", "Specify target platform">;
def help : F<"help">;
diff --git a/llvm/test/tools/llvm-lib/no-inputs.test b/llvm/test/tools/llvm-lib/no-inputs.test
index 95d6555d58c6..c1b2eeadadf2 100644
--- a/llvm/test/tools/llvm-lib/no-inputs.test
+++ b/llvm/test/tools/llvm-lib/no-inputs.test
@@ -1,2 +1,6 @@
RUN: llvm-lib -out:%t.a
RUN: test ! -e %t.a
+
+RUN: llvm-lib /llvmlibempty -out:%t.a
+RUN: FileCheck %s < %t.a
+CHECK: !<arch>
More information about the llvm-commits
mailing list