summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-06-02 16:28:09 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-06-02 16:28:09 +0000
commit172f80849f19dd37f493c64a20fd79af34e6e83f (patch)
tree866497525bf4a4089e9466189b0975f4b01590d4 /llvm/lib/Support/Unix
parent5c76f83106a0a78e530c70487412382dc2a59bcd (diff)
downloadbcm5719-llvm-172f80849f19dd37f493c64a20fd79af34e6e83f.tar.gz
bcm5719-llvm-172f80849f19dd37f493c64a20fd79af34e6e83f.zip
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. llvm-svn: 157891
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/PathV2.inc3
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc
index a7007cd6974..a5630b9ec90 100644
--- a/llvm/lib/Support/Unix/PathV2.inc
+++ b/llvm/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;
OpenPOWER on IntegriCloud