diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-02 16:28:09 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-02 16:28:09 +0000 |
commit | 1222c5c121e1284e37ae91b22a5b8bf6803b077f (patch) | |
tree | e7e573ebe1e17fddbc82a874462bfa30e523ea93 | |
parent | 31219d2cec17dca632b6d047a15e86dc92b76e18 (diff) | |
download | external_llvm-1222c5c121e1284e37ae91b22a5b8bf6803b077f.zip external_llvm-1222c5c121e1284e37ae91b22a5b8bf6803b077f.tar.gz external_llvm-1222c5c121e1284e37ae91b22a5b8bf6803b077f.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157891 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Support/Unix/PathV2.inc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index a7007cd..a5630b9 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -273,8 +273,7 @@ error_code exists(const Twine &path, bool &result) { 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; |