[PATCH] D37772: [LLD] [MinGW] Support dllexport on i386
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 12:31:16 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313174: [MinGW] Support dllexport on i386 (authored by mstorsjo).
Changed prior to commit:
https://reviews.llvm.org/D37772?vs=114988&id=115097#toc
Repository:
rL LLVM
https://reviews.llvm.org/D37772
Files:
lld/trunk/COFF/Config.h
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Options.td
lld/trunk/MinGW/Driver.cpp
lld/trunk/test/COFF/dllexport-mingw.s
lld/trunk/test/MinGW/driver.test
Index: lld/trunk/COFF/Config.h
===================================================================
--- lld/trunk/COFF/Config.h
+++ lld/trunk/COFF/Config.h
@@ -173,6 +173,7 @@
bool LargeAddressAware = false;
bool HighEntropyVA = false;
bool AppContainer = false;
+ bool MinGW = false;
};
extern Configuration *Config;
Index: lld/trunk/COFF/Driver.cpp
===================================================================
--- lld/trunk/COFF/Driver.cpp
+++ lld/trunk/COFF/Driver.cpp
@@ -234,6 +234,12 @@
break;
case OPT_export: {
Export E = parseExport(Arg->getValue());
+ if (Config->Machine == I386 && Config->MinGW) {
+ if (!isDecorated(E.Name))
+ E.Name = Saver.save("_" + E.Name);
+ if (!E.ExtName.empty() && !isDecorated(E.ExtName))
+ E.ExtName = Saver.save("_" + E.ExtName);
+ }
E.Directives = true;
Config->Exports.push_back(E);
break;
@@ -719,6 +725,10 @@
return;
}
+ // Handle /lldmingw early, since it can potentially affect how other
+ // options are handled.
+ Config->MinGW = Args.hasArg(OPT_lldmingw);
+
if (auto *Arg = Args.getLastArg(OPT_linkrepro)) {
SmallString<64> Path = StringRef(Arg->getValue());
sys::path::append(Path, "repro.tar");
Index: lld/trunk/COFF/Options.td
===================================================================
--- lld/trunk/COFF/Options.td
+++ lld/trunk/COFF/Options.td
@@ -104,6 +104,7 @@
// LLD extensions
def nopdb : F<"nopdb">, HelpText<"Disable PDB generation for DWARF users">;
def nosymtab : F<"nosymtab">;
+def lldmingw : F<"lldmingw">;
def msvclto : F<"msvclto">;
def rsp_quoting : Joined<["--"], "rsp-quoting=">,
HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
Index: lld/trunk/MinGW/Driver.cpp
===================================================================
--- lld/trunk/MinGW/Driver.cpp
+++ lld/trunk/MinGW/Driver.cpp
@@ -120,6 +120,7 @@
auto Add = [&](const Twine &S) { LinkArgs.push_back(S.str()); };
Add("lld-link");
+ Add("-lldmingw");
if (auto *A = Args.getLastArg(OPT_entry)) {
StringRef S = A->getValue();
Index: lld/trunk/test/COFF/dllexport-mingw.s
===================================================================
--- lld/trunk/test/COFF/dllexport-mingw.s
+++ lld/trunk/test/COFF/dllexport-mingw.s
@@ -0,0 +1,19 @@
+# REQEUIRES: x86
+
+# RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj
+
+# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:main %t.obj -implib:%t.lib
+# RUN: llvm-readobj %t.lib | FileCheck %s
+
+# CHECK: Symbol: __imp__func
+# CHECK: Symbol: _func
+
+.global _main
+.global _func
+.text
+_main:
+ ret
+_func:
+ ret
+.section .drectve
+.ascii "-export:func"
Index: lld/trunk/test/MinGW/driver.test
===================================================================
--- lld/trunk/test/MinGW/driver.test
+++ lld/trunk/test/MinGW/driver.test
@@ -53,3 +53,6 @@
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
+
+RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix MINGW-FLAG %s
+MINGW-FLAG: -lldmingw
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37772.115097.patch
Type: text/x-patch
Size: 3220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/7fd64e86/attachment.bin>
More information about the llvm-commits
mailing list