[lld] c82078b - [LLD][MinGW] Handle allow-multiple-definition flag
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 23:38:39 PDT 2020
Author: Mateusz Mikuła
Date: 2020-08-26T09:38:11+03:00
New Revision: c82078b5d761974ce76561f85ae73b4d02213e57
URL: https://github.com/llvm/llvm-project/commit/c82078b5d761974ce76561f85ae73b4d02213e57
DIFF: https://github.com/llvm/llvm-project/commit/c82078b5d761974ce76561f85ae73b4d02213e57.diff
LOG: [LLD][MinGW] Handle allow-multiple-definition flag
Basically copied from ELF driver.
Differential Revision: https://reviews.llvm.org/D86512
Added:
Modified:
lld/MinGW/Driver.cpp
lld/MinGW/Options.td
lld/test/MinGW/driver.test
Removed:
################################################################################
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index d60765c70c09..bd6eab76c20c 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -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")
diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index e0f9e794dd9d..cbecafe76f84 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -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">,
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index faac3a0be57d..16cf0c4e4b0d 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -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
More information about the llvm-commits
mailing list