]> granicus.if.org Git - clang/commitdiff
driver: Support checking for rlimits via cmake (when bootstrapping)
authorChris Bieneman <beanz@apple.com>
Tue, 23 Aug 2016 20:07:07 +0000 (20:07 +0000)
committerChris Bieneman <beanz@apple.com>
Tue, 23 Aug 2016 20:07:07 +0000 (20:07 +0000)
Summary:
Add a cmake check for sys/resource.h and replace the __has_include() check with its result, in order to make it possible to use rlimits when building with compilers not supporting __has_include() -- i.e. when bootstrapping.

// Please also re-apply dfcd52eb1d8e5d322404b40414cb7331c7380a8c (llvm-config.h fix)

Patch by: Michał Górny

Reviewers: rsmith, beanz

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23744

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279559 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
include/clang/Config/config.h.cmake
tools/driver/cc1_main.cpp

index e6dde85bc2d68090698bd0f32957cf6d37363bb1..aee0d0a2426cbc6fcff902b9f58d70a2a4e531c2 100644 (file)
@@ -177,6 +177,9 @@ if (LIBXML2_FOUND)
   set(CLANG_HAVE_LIBXML 1)
 endif()
 
+include(CheckIncludeFile)
+check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
+
 set(CLANG_RESOURCE_DIR "" CACHE STRING
   "Relative directory from the Clang binary to its resource files.")
 
index 9200ed93247bbc64a39e86a39794e0c23cab582f..9bf9ea5d8a7084c8fce66a88dbb770c9008f6f8c 100644 (file)
@@ -35,6 +35,9 @@
 /* Define if we have libxml2 */
 #cmakedefine CLANG_HAVE_LIBXML ${CLANG_HAVE_LIBXML}
 
+/* Define if we have sys/resource.h (rlimits) */
+#cmakedefine CLANG_HAVE_RLIMITS ${CLANG_HAVE_RLIMITS}
+
 /* The LLVM product name and version */
 #define BACKEND_PACKAGE_STRING "${BACKEND_PACKAGE_STRING}"
 
index b8cea41e3ea2aaaf9efee27b3921a41eaa2f5ef9..45d44a015ee38d56ac64f13b71606e5b2f8abb1b 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "llvm/Option/Arg.h"
 #include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdio>
 
-#ifdef __has_include
-#if __has_include(<sys/resource.h>)
-#define HAVE_RLIMITS
+#ifdef CLANG_HAVE_RLIMITS
 #include <sys/resource.h>
 #endif
-#endif
 
 using namespace clang;
 using namespace llvm::opt;
@@ -73,7 +71,7 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
 }
 #endif
 
-#ifdef HAVE_RLIMITS
+#ifdef CLANG_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.