summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-03-06 19:07:35 +0000
committerReid Kleckner <reid@kleckner.net>2014-03-06 19:07:35 +0000
commitbbf1c8d24c8c5ec1aa96623457911b97fcd5f3c6 (patch)
tree044a561b527c40d8d9a9c9fa5a58ba83079594bb /lib/Support
parent6c43168ce3b50e1a1e881e07f18aa4a31555d7a5 (diff)
downloadllvm-bbf1c8d24c8c5ec1aa96623457911b97fcd5f3c6.tar.gz
llvm-bbf1c8d24c8c5ec1aa96623457911b97fcd5f3c6.tar.bz2
llvm-bbf1c8d24c8c5ec1aa96623457911b97fcd5f3c6.tar.xz
Revert create_symbolic_link and both depending changes
This reverts commits r203136, r203137, and r203138. This code doesn't build on Windows. Even on Vista+, Windows requires elevated privileges to create a symlink. Therefore we can't use symlinks in the compiler. We'll have to find another approach. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/LockFileManager.cpp56
-rw-r--r--lib/Support/Unix/Path.inc13
-rw-r--r--lib/Support/Windows/Path.inc19
3 files changed, 24 insertions, 64 deletions
diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp
index 957f2fdd7a..61afb79fb2 100644
--- a/lib/Support/LockFileManager.cpp
+++ b/lib/Support/LockFileManager.cpp
@@ -115,42 +115,34 @@ LockFileManager::LockFileManager(StringRef FileName)
}
}
- while (1) {
- // Create a symbolic link from the lock file name. If this succeeds, we're
- // done. Note that we are using symbolic link because hard links are not
- // supported by all filesystems.
- error_code EC
- = sys::fs::create_symbolic_link(UniqueLockFileName.str(),
- LockFileName.str());
- if (EC == errc::success)
- return;
+ // Create a hard link from the lock file name. If this succeeds, we're done.
+ error_code EC
+ = sys::fs::create_hard_link(UniqueLockFileName.str(),
+ LockFileName.str());
+ if (EC == errc::success)
+ return;
- if (EC != errc::file_exists) {
- Error = EC;
- return;
- }
+ // Creating the hard link failed.
- // Someone else managed to create the lock file first. Read the process ID
- // from the lock file.
- if ((Owner = readLockFile(LockFileName))) {
- // Wipe out our unique lock file (it's useless now)
- sys::fs::remove(UniqueLockFileName.str());
- return;
- }
+#ifdef LLVM_ON_UNIX
+ // The creation of the hard link may appear to fail, but if stat'ing the
+ // unique file returns a link count of 2, then we can still declare success.
+ struct stat StatBuf;
+ if (stat(UniqueLockFileName.c_str(), &StatBuf) == 0 &&
+ StatBuf.st_nlink == 2)
+ return;
+#endif
- if (!sys::fs::exists(LockFileName.str())) {
- // The previous owner released the lock file before we could read it.
- // Try to get ownership again.
- continue;
- }
+ // Someone else managed to create the lock file first. Wipe out our unique
+ // lock file (it's useless now) and read the process ID from the lock file.
+ sys::fs::remove(UniqueLockFileName.str());
+ if ((Owner = readLockFile(LockFileName)))
+ return;
- // There is a lock file that nobody owns; try to clean it up and get
- // ownership.
- if ((EC = sys::fs::remove(LockFileName.str()))) {
- Error = EC;
- return;
- }
- }
+ // There is a lock file that nobody owns; try to clean it up and report
+ // an error.
+ sys::fs::remove(LockFileName.str());
+ Error = EC;
}
LockFileManager::LockFileState LockFileManager::getState() const {
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index fe3f43a6fd..caa30c7533 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -285,19 +285,6 @@ error_code create_hard_link(const Twine &to, const Twine &from) {
return error_code::success();
}
-error_code create_symbolic_link(const Twine &to, const Twine &from) {
- // Get arguments.
- SmallString<128> from_storage;
- SmallString<128> to_storage;
- StringRef f = from.toNullTerminatedStringRef(from_storage);
- StringRef t = to.toNullTerminatedStringRef(to_storage);
-
- if (::symlink(t.begin(), f.begin()) == -1)
- return error_code(errno, system_category());
-
- return error_code::success();
-}
-
error_code remove(const Twine &path, bool IgnoreNonExisting) {
SmallString<128> path_storage;
StringRef p = path.toNullTerminatedStringRef(path_storage);
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index bb68a3eff5..c39600357b 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -177,25 +177,6 @@ error_code create_hard_link(const Twine &to, const Twine &from) {
return error_code::success();
}
-error_code create_symbolic_link(const Twine &to, const Twine &from) {
- // Get arguments.
- SmallString<128> from_storage;
- SmallString<128> to_storage;
- StringRef f = from.toStringRef(from_storage);
- StringRef t = to.toStringRef(to_storage);
-
- // Convert to utf-16.
- SmallVector<wchar_t, 128> wide_from;
- SmallVector<wchar_t, 128> wide_to;
- if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
- if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
-
- if (!::CreateSymbolicLinkW(wide_from.begin(), wide_to.begin(), NULL))
- return windows_error(::GetLastError());
-
- return error_code::success();
-}
-
error_code remove(const Twine &path, bool IgnoreNonExisting) {
SmallString<128> path_storage;
SmallVector<wchar_t, 128> path_utf16;