[llvm] [cmake] Hardcode some `check_include_file` checks (PR #104706)

Vlad Serebrennikov via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 4 03:00:52 PST 2025


================
@@ -17,6 +55,150 @@ include(CheckCompilerVersion)
 include(CheckProblematicConfigurations)
 include(HandleLLVMStdlib)
 
+if (ANDROID OR DRAGONFLY OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+  set(HAVE_DLFCN_H 1)
+  set(HAVE_ERRNO_H 1)
+  set(HAVE_FCNTL_H 1)
+  set(HAVE_FENV_H 1)
+  set(HAVE_LINK_H 1)
+  set(HAVE_MACH_MACH_H 0)
+  set(HAVE_MALLOC_MALLOC_H 0)
+  set(HAVE_PTHREAD_H 1)
+  set(HAVE_SIGNAL_H 1)
+  set(HAVE_SYS_IOCTL_H 1)
+  set(HAVE_SYS_MMAN_H 1)
+  set(HAVE_SYS_PARAM_H 1)
+  set(HAVE_SYS_RESOURCE_H 1)
+  set(HAVE_SYS_STAT_H 1)
+  set(HAVE_SYS_TIME_H 1)
+  set(HAVE_SYS_TYPES_H 1)
+  set(HAVE_SYSEXITS_H 1)
+  set(HAVE_TERMIOS_H 1)
+  set(HAVE_UNISTD_H 1)
+elseif (AIX)
+  set(HAVE_DLFCN_H 1)
+  set(HAVE_ERRNO_H 1)
+  set(HAVE_FCNTL_H 1)
+  set(HAVE_FENV_H 0)
+  set(HAVE_LINK_H 0)
+  set(HAVE_MACH_MACH_H 0)
+  set(HAVE_MALLOC_MALLOC_H 0)
+  set(HAVE_PTHREAD_H 1)
+  set(HAVE_SIGNAL_H 1)
+  set(HAVE_SYS_IOCTL_H 0)
+  set(HAVE_SYS_MMAN_H 0)
+  set(HAVE_SYS_PARAM_H 1)
+  set(HAVE_SYS_RESOURCE_H 0)
+  set(HAVE_SYS_STAT_H 1)
+  set(HAVE_SYS_TIME_H 0)
+  set(HAVE_SYS_TYPES_H 1)
+  set(HAVE_SYSEXITS_H 0)
+  set(HAVE_TERMIOS_H 1)
+  set(HAVE_UNISTD_H 1)
+elseif (APPLE)
+  set(HAVE_DLFCN_H 1)
+  set(HAVE_ERRNO_H 1)
+  set(HAVE_FCNTL_H 1)
+  set(HAVE_FENV_H 1)
+  set(HAVE_LINK_H 0)
+  set(HAVE_MACH_MACH_H 1)
+  set(HAVE_MALLOC_MALLOC_H 1)
+  set(HAVE_PTHREAD_H 1)
+  set(HAVE_SIGNAL_H 1)
+  set(HAVE_SYS_IOCTL_H 1)
+  set(HAVE_SYS_MMAN_H 1)
+  set(HAVE_SYS_PARAM_H 1)
+  set(HAVE_SYS_RESOURCE_H 1)
+  set(HAVE_SYS_STAT_H 1)
+  set(HAVE_SYS_TIME_H 1)
+  set(HAVE_SYS_TYPES_H 1)
+  set(HAVE_SYSEXITS_H 1)
+  set(HAVE_TERMIOS_H 1)
+  set(HAVE_UNISTD_H 1)
+elseif (CYGWIN)
+  set(HAVE_DLFCN_H 1)
+  set(HAVE_ERRNO_H 1)
+  set(HAVE_FCNTL_H 1)
+  set(HAVE_FENV_H 1)
+  set(HAVE_LINK_H 0)
+  set(HAVE_MACH_MACH_H 0)
+  set(HAVE_MALLOC_MALLOC_H 0)
+  set(HAVE_PTHREAD_H 1)
+  set(HAVE_SIGNAL_H 1)
+  set(HAVE_SYS_IOCTL_H 1)
+  set(HAVE_SYS_MMAN_H 1)
+  set(HAVE_SYS_PARAM_H 1)
+  set(HAVE_SYS_RESOURCE_H 1)
+  set(HAVE_SYS_STAT_H 1)
+  set(HAVE_SYS_TIME_H 1)
+  set(HAVE_SYS_TYPES_H 1)
+  set(HAVE_SYSEXITS_H 1)
+  set(HAVE_TERMIOS_H 1)
+  set(HAVE_UNISTD_H 1)
+elseif (PURE_WINDOWS)
+  set(HAVE_DLFCN_H 0)
+  set(HAVE_ERRNO_H 1)
+  set(HAVE_FCNTL_H 1)
+  set(HAVE_FENV_H 1)
+  set(HAVE_LINK_H 0)
+  set(HAVE_MACH_MACH_H 0)
+  set(HAVE_MALLOC_MALLOC_H 0)
+  set(HAVE_PTHREAD_H 0)
+  set(HAVE_SIGNAL_H 1)
+  set(HAVE_SYS_IOCTL_H 0)
+  set(HAVE_SYS_MMAN_H 0)
+  set(HAVE_SYS_PARAM_H 0)
+  set(HAVE_SYS_RESOURCE_H 0)
+  set(HAVE_SYS_STAT_H 1)
+  set(HAVE_SYS_TIME_H 0)
+  set(HAVE_SYS_TYPES_H 1)
+  set(HAVE_SYSEXITS_H 0)
+  set(HAVE_TERMIOS_H 0)
+elseif (ZOS)
+  # Confirmed in
+  # https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297109613
+  set(HAVE_DLFCN_H 1)
+  set(HAVE_ERRNO_H 1)
+  set(HAVE_FCNTL_H 1)
+  set(HAVE_FENV_H 1)
+  set(HAVE_LINK_H 0)
+  set(HAVE_MACH_MACH_H 0)
+  set(HAVE_MALLOC_MALLOC_H 0)
+  set(HAVE_PTHREAD_H 1)
+  set(HAVE_SIGNAL_H 1)
+  set(HAVE_SYS_IOCTL_H 1)
+  set(HAVE_SYS_MMAN_H 1)
+  set(HAVE_SYS_PARAM_H 0)
+  set(HAVE_SYS_RESOURCE_H 1)
+  set(HAVE_SYS_STAT_H 1)
+  set(HAVE_SYS_TIME_H 1)
+  set(HAVE_SYS_TYPES_H 1)
+  set(HAVE_SYSEXITS_H 0)
+  set(HAVE_TERMIOS_H 1)
+  set(HAVE_UNISTD_H 1)
+else()
----------------
Endilll wrote:

> In theory, once you set the values, the check queries will early-out because they detect the cached value.

I agree that this is the behavior (https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/CheckIncludeFile.cmake?ref_type=heads#L46), but I don't see it documented at https://cmake.org/cmake/help/latest/module/CheckIncludeFile.html. So I'm reluctant to rely on this.

https://github.com/llvm/llvm-project/pull/104706


More information about the llvm-commits mailing list