forked from OSchip/llvm-project
[PECOFF] Add /IMPLIB command line option.
This option is to override the default import file path. llvm-svn: 207175
This commit is contained in:
parent
6a48f7d66e
commit
409ac186bb
|
|
@ -49,7 +49,8 @@ public:
|
|||
_createManifest(true), _embedManifest(false), _manifestId(1),
|
||||
_manifestUAC(true), _manifestLevel("'asInvoker'"),
|
||||
_manifestUiAccess("'false'"), _isDll(false), _requireSEH(false),
|
||||
_noSEH(false), _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
|
||||
_noSEH(false), _implib(""),
|
||||
_dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
|
||||
setDeadStripping(true);
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +210,9 @@ public:
|
|||
bool requireSEH() const { return _requireSEH; }
|
||||
bool noSEH() const { return _noSEH; }
|
||||
|
||||
void setOutputImportLibraryPath(const std::string &val) { _implib = val; }
|
||||
std::string getOutputImportLibraryPath() const;
|
||||
|
||||
StringRef getOutputSectionName(StringRef sectionName) const;
|
||||
bool addSectionRenaming(raw_ostream &diagnostics,
|
||||
StringRef from, StringRef to);
|
||||
|
|
@ -330,6 +334,9 @@ private:
|
|||
// compatible with SEH.
|
||||
bool _noSEH;
|
||||
|
||||
// /IMPLIB command line option.
|
||||
std::string _implib;
|
||||
|
||||
// The set to store /nodefaultlib arguments.
|
||||
std::set<std::string> _noDefaultLibs;
|
||||
|
||||
|
|
|
|||
|
|
@ -1143,6 +1143,10 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
|
|||
ctx.setSwapRunFromNet(true);
|
||||
break;
|
||||
|
||||
case OPT_implib:
|
||||
ctx.setOutputImportLibraryPath(inputArg->getValue());
|
||||
break;
|
||||
|
||||
case OPT_stub: {
|
||||
ArrayRef<uint8_t> contents;
|
||||
if (!readFile(ctx, inputArg->getValue(), contents)) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ def section : P<"section", "Specify section attributes">;
|
|||
def subsystem : P<"subsystem", "Specify subsystem">;
|
||||
def stub : P<"stub", "Specify DOS stub file">;
|
||||
def opt : P<"opt", "Control optimizations">;
|
||||
def implib : P<"implib", "Import library name">;
|
||||
|
||||
def manifest : F<"manifest">;
|
||||
def manifest_colon : P<"manifest", "Create manifest file">;
|
||||
|
|
@ -104,7 +105,6 @@ def delayload : QF<"delayload">;
|
|||
def errorreport : QF<"errorreport">;
|
||||
def idlout : QF<"idlout">;
|
||||
def ignore : QF<"ignore">;
|
||||
def implib : QF<"implib">;
|
||||
def pdb : QF<"pdb">;
|
||||
def pdbaltpath : QF<"pdbaltpath">;
|
||||
def tlbid : QF<"tlbid">;
|
||||
|
|
|
|||
|
|
@ -268,6 +268,14 @@ void PECOFFLinkingContext::addDllExport(ExportDesc &desc) {
|
|||
<< "' specified more than once.\n";
|
||||
}
|
||||
|
||||
std::string PECOFFLinkingContext::getOutputImportLibraryPath() const {
|
||||
if (!_implib.empty())
|
||||
return _implib;
|
||||
SmallString<128> path = outputPath();
|
||||
llvm::sys::path::replace_extension(path, ".lib");
|
||||
return path.str();
|
||||
}
|
||||
|
||||
void PECOFFLinkingContext::addPasses(PassManager &pm) {
|
||||
pm.add(std::unique_ptr<Pass>(new pecoff::SetSubsystemPass(*this)));
|
||||
pm.add(std::unique_ptr<Pass>(new pecoff::EdataPass(*this)));
|
||||
|
|
|
|||
|
|
@ -20,12 +20,6 @@
|
|||
namespace lld {
|
||||
namespace pecoff {
|
||||
|
||||
static std::string getOutputPath(const PECOFFLinkingContext &ctx) {
|
||||
SmallString<128> path = ctx.outputPath();
|
||||
llvm::sys::path::replace_extension(path, ".lib");
|
||||
return path.str();
|
||||
}
|
||||
|
||||
/// Creates a .def file containing the list of exported symbols.
|
||||
static std::string
|
||||
createModuleDefinitionFile(const PECOFFLinkingContext &ctx,
|
||||
|
|
@ -65,7 +59,7 @@ void writeImportLibrary(const PECOFFLinkingContext &ctx) {
|
|||
std::string defArg = "/def:";
|
||||
defArg.append(createModuleDefinitionFile(ctx, tmpFile));
|
||||
std::string outputArg = "/out:";
|
||||
outputArg.append(getOutputPath(ctx));
|
||||
outputArg.append(ctx.getOutputImportLibraryPath());
|
||||
|
||||
std::vector<const char *> args;
|
||||
args.push_back(programPath.c_str());
|
||||
|
|
|
|||
|
|
@ -329,6 +329,16 @@ TEST_F(WinLinkParserTest, Merge_Circular) {
|
|||
"a.out", nullptr));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Implib) {
|
||||
EXPECT_TRUE(parse("link.exe", "/implib:foo.dll.lib", "a.out", nullptr));
|
||||
EXPECT_EQ("foo.dll.lib", _context.getOutputImportLibraryPath());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, ImplibDefault) {
|
||||
EXPECT_TRUE(parse("link.exe", "/out:foobar.dll", "a.out", nullptr));
|
||||
EXPECT_EQ("foobar.lib", _context.getOutputImportLibraryPath());
|
||||
}
|
||||
|
||||
//
|
||||
// Tests for /section
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue