#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"
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; }
bool _nxCompat;
bool _largeAddressAware;
+ std::vector<StringRef> _inputSearchPaths;
mutable std::unique_ptr<Reader> _reader;
mutable std::unique_ptr<Writer> _writer;
llvm::BumpPtrAllocator _extraStrings;
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);
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">;
#include "lld/ReaderWriter/PECOFFTargetInfo.h"
#include "llvm/Support/COFF.h"
+#include <vector>
+
using namespace llvm;
using namespace lld;
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());
}
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());
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());