[lld] r313124 - [MinGW] Add support for the options --[no-]whole-archive
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 00:28:09 PDT 2017
Author: mstorsjo
Date: Wed Sep 13 00:28:09 2017
New Revision: 313124
URL: http://llvm.org/viewvc/llvm-project?rev=313124&view=rev
Log:
[MinGW] Add support for the options --[no-]whole-archive
Differential Revision: https://reviews.llvm.org/D37769
Modified:
lld/trunk/MinGW/Driver.cpp
lld/trunk/MinGW/Options.td
lld/trunk/test/MinGW/driver.test
Modified: lld/trunk/MinGW/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Driver.cpp?rev=313124&r1=313123&r2=313124&view=diff
==============================================================================
--- lld/trunk/MinGW/Driver.cpp (original)
+++ lld/trunk/MinGW/Driver.cpp Wed Sep 13 00:28:09 2017
@@ -172,11 +172,24 @@ bool mingw::link(ArrayRef<const char *>
for (auto *A : Args.filtered(OPT_L))
SearchPaths.push_back(A->getValue());
- for (auto *A : Args.filtered(OPT_INPUT, OPT_l)) {
- if (A->getOption().getUnaliasedOption().getID() == OPT_INPUT)
- Add(A->getValue());
- else
- Add(searchLibrary(A->getValue(), SearchPaths, Args.hasArg(OPT_Bstatic)));
+ StringRef Prefix = "";
+ for (auto *A : Args.filtered(OPT_INPUT, OPT_l, OPT_whole_archive,
+ OPT_no_whole_archive)) {
+ switch (A->getOption().getID()) {
+ case OPT_INPUT:
+ Add(Prefix + StringRef(A->getValue()));
+ break;
+ case OPT_l:
+ Add(Prefix +
+ searchLibrary(A->getValue(), SearchPaths, Args.hasArg(OPT_Bstatic)));
+ break;
+ case OPT_whole_archive:
+ Prefix = "-wholearchive:";
+ break;
+ case OPT_no_whole_archive:
+ Prefix = "";
+ break;
+ }
}
if (Args.hasArg(OPT_verbose))
Modified: lld/trunk/MinGW/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Options.td?rev=313124&r1=313123&r2=313124&view=diff
==============================================================================
--- lld/trunk/MinGW/Options.td (original)
+++ lld/trunk/MinGW/Options.td Wed Sep 13 00:28:09 2017
@@ -12,12 +12,16 @@ def l: JoinedOrSeparate<["-"], "l">, Met
HelpText<"Root name of library to use">;
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
def mllvm: S<"mllvm">;
+def no_whole_archive: F<"no-whole-archive">,
+ HelpText<"No longer include all object files for following archives">;
def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
HelpText<"Path to file to write output">;
def out_implib: Separate<["--"], "out-implib">, HelpText<"Import library name">;
def shared: F<"shared">, HelpText<"Build a shared object">;
def subs: Separate<["--"], "subsystem">, HelpText<"Specify subsystem">;
def stack: Separate<["--"], "stack">;
+def whole_archive: F<"whole-archive">,
+ HelpText<"Include all object files for following archives">;
def verbose: F<"verbose">, HelpText<"Verbose mode">;
// LLD specific options
Modified: lld/trunk/test/MinGW/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/MinGW/driver.test?rev=313124&r1=313123&r2=313124&view=diff
==============================================================================
--- lld/trunk/test/MinGW/driver.test (original)
+++ lld/trunk/test/MinGW/driver.test Wed Sep 13 00:28:09 2017
@@ -47,3 +47,6 @@ VERBOSE: -verbose
RUN: ld.lld -### -shared -m i386pe -e _DllMainCRTStartup at 12 foo.o | FileCheck -check-prefix I386-ENTRY %s
I386-ENTRY: -entry:DllMainCRTStartup at 12
+
+RUN: ld.lld -### -m i386pep foo.o --whole-archive bar.a --no-whole-archive baz.a | FileCheck -check-prefix WHOLE-ARCHIVE %s
+WHOLE-ARCHIVE: foo.o -wholearchive:bar.a baz.a
More information about the llvm-commits
mailing list