[lld] r186644 - [PECOFF][Driver] Add -libpath command line option.
Rui Ueyama
ruiu at google.com
Thu Jul 18 18:38:49 PDT 2013
Author: ruiu
Date: Thu Jul 18 20:38:49 2013
New Revision: 186644
URL: http://llvm.org/viewvc/llvm-project?rev=186644&view=rev
Log:
[PECOFF][Driver] Add -libpath command line option.
The logic to search a library from the library paths will be implemented
in a different patch.
Modified:
lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/lib/Driver/WinLinkOptions.td
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h?rev=186644&r1=186643&r2=186644&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h Thu Jul 18 20:38:49 2013
@@ -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;
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=186644&r1=186643&r2=186644&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Jul 18 20:38:49 2013
@@ -254,6 +254,13 @@ bool WinLinkDriver::parse(int argc, cons
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);
Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=186644&r1=186643&r2=186644&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Thu Jul 18 20:38:49 2013
@@ -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">;
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=186644&r1=186643&r2=186644&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Thu Jul 18 20:38:49 2013
@@ -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, NonStandardFil
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());
More information about the llvm-commits
mailing list