llvm.org GIT mirror llvm / 7b95c0d
[Support/LockFileManager] Use symbolic link for the lock file. Hard links do not work on SMB network directories, and it causes us to fail to build clang module files if the module cache is in such a directory. rdar://15944959 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203137 91177308-0d34-0410-b5e6-96231b3b80d8 Argyrios Kyrtzidis 5 years ago
1 changed file(s) with 4 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
114114 }
115115 }
116116
117 // Create a hard link from the lock file name. If this succeeds, we're done.
117 // Create a symbolic link from the lock file name. If this succeeds, we're done.
118 // Note that we are using symbolic link because hard links are not supported
119 // by all filesystems.
118120 error_code EC
119 = sys::fs::create_hard_link(UniqueLockFileName.str(),
121 = sys::fs::create_symbolic_link(UniqueLockFileName.str(),
120122 LockFileName.str());
121123 if (EC == errc::success)
122124 return;
123
124 // Creating the hard link failed.
125
126 #ifdef LLVM_ON_UNIX
127 // The creation of the hard link may appear to fail, but if stat'ing the
128 // unique file returns a link count of 2, then we can still declare success.
129 struct stat StatBuf;
130 if (stat(UniqueLockFileName.c_str(), &StatBuf) == 0 &&
131 StatBuf.st_nlink == 2)
132 return;
133 #endif
134125
135126 // Someone else managed to create the lock file first. Wipe out our unique
136127 // lock file (it's useless now) and read the process ID from the lock file.