[llvm-commits] [llvm] r157891 - /llvm/trunk/lib/Support/Unix/PathV2.inc

Benjamin Kramer benny.kra at googlemail.com
Sat Jun 2 09:28:09 PDT 2012


Author: d0k
Date: Sat Jun  2 11:28:09 2012
New Revision: 157891

URL: http://llvm.org/viewvc/llvm-project?rev=157891&view=rev
Log:
Use access(2) instead of stat(2) to check if a file exists.

Apart from being slightly cheaper, this fixes a real bug that hits 32 bit
linux systems. When passing a file larger than 2G to be linked (which isn't
that uncommon with large projects such as WebKit), clang's driver checks
if the file exists but the file size doesn't fit in an off_t and stat(2)
fails with EOVERFLOW. Clang then says that the file doesn't exist instead
of passing it to the linker.

Modified:
    llvm/trunk/lib/Support/Unix/PathV2.inc

Modified: llvm/trunk/lib/Support/Unix/PathV2.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=157891&r1=157890&r2=157891&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/PathV2.inc (original)
+++ llvm/trunk/lib/Support/Unix/PathV2.inc Sat Jun  2 11:28:09 2012
@@ -273,8 +273,7 @@
   SmallString<128> path_storage;
   StringRef p = path.toNullTerminatedStringRef(path_storage);
 
-  struct stat status;
-  if (::stat(p.begin(), &status) == -1) {
+  if (::access(p.begin(), F_OK) == -1) {
     if (errno != errc::no_such_file_or_directory)
       return error_code(errno, system_category());
     result = false;





More information about the llvm-commits mailing list