[LLD][MinGW] Handle allow-multiple-definition flag

Basically copied from ELF driver.

Differential Revision: https://reviews.llvm.org/D86512
This commit is contained in:
Mateusz Mikuła 2020-08-26 09:25:52 +03:00 committed by Martin Storsjö
parent dcb1ce61b8
commit c82078b5d7
3 changed files with 15 additions and 0 deletions

View File

@ -313,6 +313,10 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
else
add("-runtime-pseudo-reloc:no");
if (args.hasFlag(OPT_allow_multiple_definition,
OPT_no_allow_multiple_definition, false))
add("-force:multiple");
if (auto *a = args.getLastArg(OPT_icf)) {
StringRef s = a->getValue();
if (s == "all")

View File

@ -23,6 +23,9 @@ multiclass B<string name, string help1, string help2> {
def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
HelpText<"Add a directory to the library search path">;
defm allow_multiple_definition: B<"allow-multiple-definition",
"Allow multiple definitions",
"Do not allow multiple definitions (default)">;
def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
def disable_auto_import: F<"disable-auto-import">,

View File

@ -260,3 +260,11 @@ ALIGN: -align:0x2000
RUN: ld.lld -### -m i386pe foo.o -no-seh | FileCheck -check-prefix NOSEH %s
RUN: ld.lld -### -m i386pe foo.o --no-seh | FileCheck -check-prefix NOSEH %s
NOSEH: -noseh
RUN: ld.lld -### -m i386pep foo.o --no-allow-multiple-definition --allow-multiple-definition | FileCheck -check-prefix ALLOW_MULTIPLE_DEFINITION %s
RUN: ld.lld -### -m i386pep foo.o -no-allow-multiple-definition -allow-multiple-definition | FileCheck -check-prefix ALLOW_MULTIPLE_DEFINITION %s
ALLOW_MULTIPLE_DEFINITION: -force:multiple
RUN: ld.lld -### -m i386pep foo.o --allow-multiple-definition --no-allow-multiple-definition | FileCheck -check-prefix NO_ALLOW_MULTIPLE_DEFINITION %s
RUN: ld.lld -### -m i386pep foo.o -allow-multiple-definition -no-allow-multiple-definition | FileCheck -check-prefix NO_ALLOW_MULTIPLE_DEFINITION %s
NO_ALLOW_MULTIPLE_DEFINITION-NOT: -force:multiple