COFF: Add /implib option.

llvm-svn: 240045
This commit is contained in:
Rui Ueyama 2015-06-18 20:27:09 +00:00
parent 98d7803291
commit b95188cb2c
4 changed files with 16 additions and 3 deletions

View File

@ -55,6 +55,7 @@ struct Configuration {
// True if we are creating a DLL.
bool DLL = false;
StringRef Implib;
std::vector<Export> Exports;
// Options for manifest files.

View File

@ -338,6 +338,10 @@ bool LinkerDriver::link(int Argc, const char *Argv[]) {
if (parseAlternateName(Arg->getValue()))
return false;
// Handle /implib
if (auto *Arg = Args->getLastArg(OPT_implib))
Config->Implib = Arg->getValue();
// Handle /opt
for (auto *Arg : Args->filtered(OPT_opt)) {
std::string S = StringRef(Arg->getValue()).lower();

View File

@ -507,14 +507,18 @@ std::error_code writeImportLibrary() {
std::string Contents = createModuleDefinitionFile();
std::string Def = writeToTempFile(Contents);
llvm::FileRemover TempFile(Def);
SmallString<128> Out = StringRef(Config->OutputFile);
sys::path::replace_extension(Out, ".lib");
Executor E("lib.exe");
E.add("/nologo");
E.add("/machine:x64");
E.add(Twine("/def:") + Def);
E.add("/out:" + Out);
if (Config->Implib.empty()) {
SmallString<128> Out = StringRef(Config->OutputFile);
sys::path::replace_extension(Out, ".lib");
E.add("/out:" + Out);
} else {
E.add("/out:" + Config->Implib);
}
return E.run();
}

View File

@ -28,6 +28,10 @@ EXPORT-LTO-NEXT: 3 0x1030 exportfn3
# RUN: lld -flavor link2 /out:%t2.exe %t2.obj %t.lib
# RUN: llvm-readobj -coff-imports %t2.exe | FileCheck -check-prefix=IMPORT %s
# RUN: lld -flavor link2 /out:%t.dll /dll %t.obj /implib:%t2.lib /export:exportfn1 /export:exportfn2
# RUN: lld -flavor link2 /out:%t2.exe %t2.obj %t2.lib
# RUN: llvm-readobj -coff-imports %t2.exe | FileCheck -check-prefix=IMPORT %s
# RUN: lld -flavor link2 /out:%t2.lto.exe %t2.obj %t.lto.lib
# RUN: llvm-readobj -coff-imports %t2.lto.exe | FileCheck -check-prefix=IMPORT %s