[llvm] ec9aa4a - [cmake] Hardcode some `check_include_file` checks (#104706)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 01:12:32 PST 2025
Author: Vlad Serebrennikov
Date: 2025-01-16T13:12:28+04:00
New Revision: ec9aa4ac2f5a1b8e91938b47081eadc1a9d3bf85
URL: https://github.com/llvm/llvm-project/commit/ec9aa4ac2f5a1b8e91938b47081eadc1a9d3bf85
DIFF: https://github.com/llvm/llvm-project/commit/ec9aa4ac2f5a1b8e91938b47081eadc1a9d3bf85.diff
LOG: [cmake] Hardcode some `check_include_file` checks (#104706)
This patch removes 11 `check_include_file` invocations from
configuration phase of LLVM subproject on most of the platforms,
hardcoding the results. Fallback is left for platforms that we don't
document as supported or that are not detectable via
`CMAKE_SYSTEM_NAME`, e.g. z/OS.
This patch reduces configuration time on Linux by 10%, going from 44.7
seconds down to 40.6 seconds on my Debian machine (ramdisk, `cmake
-DLLVM_ENABLE_PROJECTS="clang;lldb;clang-tools-extra"
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxx;libcxxabi"
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_OPTIMIZED_TABLEGEN=ON
-DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_DOXYGEN=ON
-DLLVM_ENABLE_LIBCXX=ON -DBUILD_SHARED_LIBS=ON -DLLDB_ENABLE_PYTHON=ON
~/endill/llvm-project/llvm`).
In order to determine the values to hardcode, I prepared the following
header:
```cpp
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <fenv.h>
#include <mach/mach.h>
#include <malloc/malloc.h>
#include <pthread.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sysexits.h>
#include <termios.h>
#include <unistd.h>
int main() {}
```
and tried to compile it on the oldest versions of platforms that are
still supported (which was problematic to determine sometimes): macOS
12, Cygwin, DragonFly BSD 6.4.0, FreeBSD 13.3, Haiku R1 beta 4, RHEL
8.10 as a glibc-based Linux, Alpine 3.17 as musl-based Linux, NetBSD 9,
OpenBSD 7.4, Solaris 11.4, Windows SDK 10.0.17763.0, which corresponds
to Windows 10 1809 and is the oldest Windows 10 SDK in Visual Studio
Installer.
For platforms I don't have access to, which are AIX 7.2 TL5 and z/OS
2.4.0, I had to rely on the official documentation. I suspect that AIX
offers a better set of headers than what this PR claims, so I'm open to
input from people who have access to a live system to test it.
Similarly to AIX, I have values for z/OS compiled from the official
documentation that are not included in this patch, because apparently
upstream CMake doesn't even support z/OS, so I don't even know how to
make a place to hold those values. I see `if (ZOS)` in several places
across our CMake files, but it's a mystery to me where this variable
comes from. Input from people who have access to live z/OS instance is
welcome.
Added:
Modified:
llvm/cmake/config-ix.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 8726b3d617a8ce..38f339d17c8529 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -17,6 +17,86 @@ include(CheckCompilerVersion)
include(CheckProblematicConfigurations)
include(HandleLLVMStdlib)
+if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|Linux|NetBSD|OpenBSD|SunOS")
+ set(HAVE_DLFCN_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_SYSEXITS_H 1)
+ set(HAVE_TERMIOS_H 1)
+ set(HAVE_UNISTD_H 1)
+elseif (APPLE)
+ set(HAVE_DLFCN_H 1)
+ 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_SYSEXITS_H 1)
+ set(HAVE_TERMIOS_H 1)
+ set(HAVE_UNISTD_H 1)
+elseif (PURE_WINDOWS)
+ set(HAVE_DLFCN_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_SYSEXITS_H 0)
+ set(HAVE_TERMIOS_H 0)
+ set(HAVE_UNISTD_H 0)
+elseif (ZOS)
+ # Confirmed in
+ # https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297109613
+ set(HAVE_DLFCN_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 0)
+ set(HAVE_SYS_RESOURCE_H 1)
+ set(HAVE_SYS_STAT_H 1)
+ set(HAVE_SYS_TIME_H 1)
+ set(HAVE_SYSEXITS_H 0)
+ set(HAVE_TERMIOS_H 1)
+ set(HAVE_UNISTD_H 1)
+else()
+ # Other platforms that we don't promise support for.
+ check_include_file(dlfcn.h HAVE_DLFCN_H)
+ check_include_file(mach/mach.h HAVE_MACH_MACH_H)
+ check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
+ check_include_file(pthread.h HAVE_PTHREAD_H)
+ check_include_file(signal.h HAVE_SIGNAL_H)
+ check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
+ check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
+ check_include_file(sys/param.h HAVE_SYS_PARAM_H)
+ check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
+ check_include_file(sys/stat.h HAVE_SYS_STAT_H)
+ check_include_file(sys/time.h HAVE_SYS_TIME_H)
+ check_include_file(sysexits.h HAVE_SYSEXITS_H)
+ check_include_file(termios.h HAVE_TERMIOS_H)
+ check_include_file(unistd.h HAVE_UNISTD_H)
+endif()
+
if( UNIX AND NOT (APPLE OR BEOS OR HAIKU) )
# Used by check_symbol_exists:
list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
@@ -58,19 +138,6 @@ if(LLVM_USING_GLIBC)
endif()
# include checks
-check_include_file(dlfcn.h HAVE_DLFCN_H)
-check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
-if( NOT PURE_WINDOWS )
- check_include_file(pthread.h HAVE_PTHREAD_H)
-endif()
-check_include_file(signal.h HAVE_SIGNAL_H)
-check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
-check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
-check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
-check_include_file(sys/time.h HAVE_SYS_TIME_H)
-check_include_file(sysexits.h HAVE_SYSEXITS_H)
-check_include_file(termios.h HAVE_TERMIOS_H)
-check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT)
check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
@@ -86,7 +153,6 @@ check_c_source_compiles("
int main(void) { return 0; }"
HAVE_BUILTIN_THREAD_POINTER)
-check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H)
if(APPLE)
check_c_source_compiles("
More information about the llvm-commits
mailing list