forked from OSchip/llvm-project
[PECOFF][Driver] Add -libpath command line option.
The logic to search a library from the library paths will be implemented in a different patch. llvm-svn: 186644
This commit is contained in:
parent
32488bd559
commit
9f24922bd1
|
@ -10,6 +10,8 @@
|
|||
#ifndef LLD_READER_WRITER_PECOFF_TARGET_INFO_H
|
||||
#define LLD_READER_WRITER_PECOFF_TARGET_INFO_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "lld/Core/TargetInfo.h"
|
||||
#include "lld/ReaderWriter/Reader.h"
|
||||
#include "lld/ReaderWriter/Writer.h"
|
||||
|
@ -43,6 +45,14 @@ public:
|
|||
|
||||
virtual void addPasses(PassManager &pm) const;
|
||||
|
||||
void appendInputSearchPath(StringRef dirPath) {
|
||||
_inputSearchPaths.push_back(dirPath);
|
||||
}
|
||||
|
||||
const std::vector<StringRef> getInputSearchPaths() {
|
||||
return _inputSearchPaths;
|
||||
}
|
||||
|
||||
void setStackReserve(uint64_t size) { _stackReserve = size; }
|
||||
void setStackCommit(uint64_t size) { _stackCommit = size; }
|
||||
uint64_t getStackReserve() const { return _stackReserve; }
|
||||
|
@ -85,6 +95,7 @@ private:
|
|||
bool _nxCompat;
|
||||
bool _largeAddressAware;
|
||||
|
||||
std::vector<StringRef> _inputSearchPaths;
|
||||
mutable std::unique_ptr<Reader> _reader;
|
||||
mutable std::unique_ptr<Writer> _writer;
|
||||
llvm::BumpPtrAllocator _extraStrings;
|
||||
|
|
|
@ -254,6 +254,13 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
|
|||
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_entry))
|
||||
info.setEntrySymbolName(arg->getValue());
|
||||
|
||||
// Hanlde -libpath
|
||||
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_libpath),
|
||||
ie = parsedArgs->filtered_end();
|
||||
it != ie; ++it) {
|
||||
info.appendInputSearchPath((*it)->getValue());
|
||||
}
|
||||
|
||||
// Handle -force
|
||||
if (parsedArgs->getLastArg(OPT_force))
|
||||
info.setAllowRemainingUndefines(true);
|
||||
|
|
|
@ -25,6 +25,10 @@ def entry : Separate<["-", "/"], "entry">,
|
|||
HelpText<"Name of entry point symbol">;
|
||||
def entry_c: Joined<["-", "/"], "entry:">, Alias<entry>;
|
||||
|
||||
def libpath : Separate<["-", "/"], "libpath">,
|
||||
HelpText<"Additional library search path">;
|
||||
def libpath_c: Joined<["-", "/"], "libpath:">, Alias<libpath>;
|
||||
|
||||
def force : Flag<["-", "/"], "force">,
|
||||
HelpText<"Allow undefined symbols when creating executables">;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "lld/ReaderWriter/PECOFFTargetInfo.h"
|
||||
#include "llvm/Support/COFF.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace lld;
|
||||
|
||||
|
@ -39,6 +41,7 @@ TEST_F(WinLinkParserTest, Basic) {
|
|||
EXPECT_EQ("a.obj", inputFile(0));
|
||||
EXPECT_EQ("b.obj", inputFile(1));
|
||||
EXPECT_EQ("c.obj", inputFile(2));
|
||||
EXPECT_TRUE(_info.getInputSearchPaths().empty());
|
||||
EXPECT_EQ(6, _info.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(0, _info.getMinOSVersion().minorVersion);
|
||||
EXPECT_EQ(1024 * 1024ULL, _info.getStackReserve());
|
||||
|
@ -49,7 +52,7 @@ TEST_F(WinLinkParserTest, Basic) {
|
|||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, WindowsStyleOption) {
|
||||
EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe", "a.obj",
|
||||
EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe", "a.obj",
|
||||
nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _info.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _info.outputPath());
|
||||
|
@ -72,6 +75,15 @@ TEST_F(WinLinkParserTest, NonStandardFileExtension) {
|
|||
EXPECT_EQ("foo.o", inputFile(0));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Libpath) {
|
||||
EXPECT_FALSE(parse("link.exe", "-libpath", "dir1", "-libpath", "dir2",
|
||||
nullptr));
|
||||
const std::vector<StringRef> &paths = _info.getInputSearchPaths();
|
||||
EXPECT_EQ((size_t)2, paths.size());
|
||||
EXPECT_EQ("dir1", paths[0]);
|
||||
EXPECT_EQ("dir2", paths[1]);
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MinMajorOSVersion) {
|
||||
EXPECT_FALSE(parse("link.exe", "-subsystem", "windows,3", "foo.o", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _info.getSubsystem());
|
||||
|
|
Loading…
Reference in New Issue