Use __has_include rather than a configure-time macro to determine if
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 18 Aug 2016 18:22:22 +0000 (18:22 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 18 Aug 2016 18:22:22 +0000 (18:22 +0000)
<sys/resource.h> is available. This should fix out-of-tree builds, at the cost
of not providing the higher rlimits to stage 1 clang when built with an old
host compiler not implementing this feature yet (bootstrap builds should be
fine, though).

llvm-svn: 279112

clang/tools/driver/cc1_main.cpp

index b44108e..fff6ffe 100644 (file)
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdio>
-#if HAVE_SYS_RESOURCE_H
+
+#ifdef __has_include
+#if __has_include(<sys/resource.h>)
+#define HAVE_RLIMITS
 #include <sys/resource.h>
 #endif
+#endif
+
 using namespace clang;
 using namespace llvm::opt;
 
@@ -69,7 +74,7 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
 }
 #endif
 
-#if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT
+#ifdef HAVE_RLIMITS
 // The amount of stack we think is "sufficient". If less than this much is
 // available, we may be unable to reach our template instantiation depth
 // limit and other similar limits.