[lld] r214990 - Fix mach-o tests on Windows
Rui Ueyama
ruiu at google.com
Wed Aug 6 12:37:35 PDT 2014
Author: ruiu
Date: Wed Aug 6 14:37:35 2014
New Revision: 214990
URL: http://llvm.org/viewvc/llvm-project?rev=214990&view=rev
Log:
Fix mach-o tests on Windows
The tests assume the path separator is '/', but if you run
them on Windows it is '\'. As a result the tests are failing
on Windows. This should be the minimal change to make these
tests to pass on Windows platform.
Differential Revision: http://reviews.llvm.org/D4710
Modified:
lld/trunk/lib/Driver/DarwinLdDriver.cpp
lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=214990&r1=214989&r2=214990&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Wed Aug 6 14:37:35 2014
@@ -32,6 +32,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h"
+#include <algorithm>
namespace {
@@ -361,7 +362,11 @@ bool DarwinLdDriver::parse(int argc, con
diagnostics << "Unable to find library -l" << arg->getValue() << "\n";
return false;
} else if (ctx.testingLibResolution()) {
- diagnostics << "Found library " << resolvedPath.get() << '\n';
+ // Test may be running on Windows. Canonicalize the path
+ // separator to '/' to get consistent outputs for tests.
+ std::string path = resolvedPath.get();
+ std::replace(path.begin(), path.end(), '\\', '/');
+ diagnostics << "Found library " << path << '\n';
}
inputPath = resolvedPath.get();
break;
Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=214990&r1=214989&r2=214990&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Wed Aug 6 14:37:35 2014
@@ -25,6 +25,8 @@
#include "llvm/Support/MachO.h"
#include "llvm/Support/Path.h"
+#include <algorithm>
+
using lld::mach_o::ArchHandler;
using namespace llvm::MachO;
@@ -297,7 +299,9 @@ bool MachOLinkingContext::pathExists(Str
// Otherwise, we're in test mode: only files explicitly provided on the
// command-line exist.
- return _existingPaths.find(path) != _existingPaths.end();
+ std::string key = path.str();
+ std::replace(key.begin(), key.end(), '\\', '/');
+ return _existingPaths.find(key) != _existingPaths.end();
}
void MachOLinkingContext::addModifiedSearchDir(
@@ -308,7 +312,7 @@ void MachOLinkingContext::addModifiedSea
// + If the last -syslibroot is "/", all of them are ignored (don't ask).
// + -syslibroot only applies to absolute paths.
if (!syslibRoots.empty() && syslibRoots.back() != "/" &&
- llvm::sys::path::is_absolute(libPath)) {
+ libPath.startswith("/")) {
for (auto syslibRoot : syslibRoots) {
SmallString<256> path(syslibRoot);
llvm::sys::path::append(path, libPath);
More information about the llvm-commits
mailing list