[llvm] [cmake] Hardcode some `check_include_file` checks (PR #104706)
Vlad Serebrennikov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 06:50:27 PDT 2024
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/104706
This patch removes 19 `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 down 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 <link.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.
>From a92b98bfa4e988ec4a4af08e7023f56485b38b40 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Sun, 18 Aug 2024 14:46:27 +0300
Subject: [PATCH 1/3] Header-centric implementation
---
llvm/cmake/config-ix.cmake | 129 ++++++++++++++++++++++++++++++-------
1 file changed, 106 insertions(+), 23 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 0aae13e30f2ab4..fd90309723c96c 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -3,6 +3,34 @@ if( WIN32 AND NOT CYGWIN )
set(PURE_WINDOWS 1)
endif()
+if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ set(AIX 1)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+ set(FREEBSD 1)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Haiku")
+ set(HAIKU 1)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(LINUX 1)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
+ set(NETBSD 1)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
+ set(OPENBSD 1)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set(SOLARIS 1)
+endif()
+
include(CheckIncludeFile)
include(CheckLibraryExists)
include(CheckSymbolExists)
@@ -17,6 +45,8 @@ include(CheckCompilerVersion)
include(CheckProblematicConfigurations)
include(HandleLLVMStdlib)
+check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
+
if( UNIX AND NOT (APPLE OR BEOS OR HAIKU) )
# Used by check_symbol_exists:
list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
@@ -40,28 +70,83 @@ if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
endif()
-# include checks
-check_include_file(dlfcn.h HAVE_DLFCN_H)
-check_include_file(errno.h HAVE_ERRNO_H)
-check_include_file(fcntl.h HAVE_FCNTL_H)
-check_include_file(link.h HAVE_LINK_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/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(sys/types.h HAVE_SYS_TYPES_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)
+if (AIX OR ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+ set(HAVE_DLFCN_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_ERRNO_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR HAIKU OR FREEBSD OR LINUX OR SOLARIS)
+ set(HAVE_FCNTL_H 1)
+endif()
+
+if (ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_FENV_H 1)
+endif()
+
+if (ANDROID OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+ set(HAVE_LINK_H 1)
+endif()
+
+if (APPLE OR LLVM_USING_GLIBC)
+ set(HAVE_MACH_MACH_H 1)
+endif()
+
+if (APPLE OR LLVM_USING_GLIBC)
+ set(HAVE_MALLOC_MALLOC_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR OPENBSD OR SOLARIS)
+ set(HAVE_PTHREAD_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_SIGNAL_H 1)
+endif()
+
+if (ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+ set(HAVE_SYS_IOCTL_H 1)
+endif()
+
+if (ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_SYS_MMAN_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+ set(HAVE_SYS_PARAM_H 1)
+endif()
+
+if (ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_SYS_RESOURCE_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_SYS_STAT_H 1)
+endif()
+
+if (ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+ set(HAVE_SYS_TIME_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_SYS_TYPES_H 1)
+endif()
+
+if (ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+ set(HAVE_SYSEXITS_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR SOLARIS)
+ set(HAVE_TERMIOS_H 1)
+endif()
+
+if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+ set(HAVE_UNISTD_H 1)
+endif()
+
check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
-check_include_file(fenv.h HAVE_FENV_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)
check_c_source_compiles("
@@ -76,7 +161,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("
@@ -339,7 +423,6 @@ else()
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
endif()
-check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
if( LLVM_USING_GLIBC )
add_compile_definitions(_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
>From 0d468fdb9c92944b621cee14b25b8925be231328 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Sun, 18 Aug 2024 16:03:02 +0300
Subject: [PATCH 2/3] Move to platform-centric approach
---
llvm/cmake/config-ix.cmake | 201 +++++++++++++++++++++++--------------
1 file changed, 126 insertions(+), 75 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index fd90309723c96c..a10082cedac246 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -7,6 +7,10 @@ if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(AIX 1)
endif()
+if (CMAKE_SYSTEM_NAME STREQUAL "DragonFly")
+ set(DRAGONFLY 1)
+endif()
+
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(FREEBSD 1)
endif()
@@ -47,103 +51,150 @@ include(HandleLLVMStdlib)
check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
-if( UNIX AND NOT (APPLE OR BEOS OR HAIKU) )
- # Used by check_symbol_exists:
- list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
-endif()
-# x86_64 FreeBSD 9.2 requires libcxxrt to be specified explicitly.
-if( CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND
- CMAKE_SIZEOF_VOID_P EQUAL 8 )
- list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt")
-endif()
-
-# Do checks with _XOPEN_SOURCE and large-file API on AIX, because we will build
-# with those too.
-if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
- list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700")
- list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_LARGE_FILE_API")
-endif()
-
-# Do checks with _FILE_OFFSET_BITS=64 on Solaris, because we will build
-# with those too.
-if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
- list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
-endif()
-
-if (AIX OR ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
+if (ANDROID OR DRAGONFLY OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_DLFCN_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_ERRNO_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR HAIKU OR FREEBSD OR LINUX OR SOLARIS)
set(HAVE_FCNTL_H 1)
-endif()
-
-if (ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_FENV_H 1)
-endif()
-
-if (ANDROID OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
set(HAVE_LINK_H 1)
-endif()
-
-if (APPLE OR LLVM_USING_GLIBC)
+ 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)
-endif()
-
-if (APPLE OR LLVM_USING_GLIBC)
set(HAVE_MALLOC_MALLOC_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR OPENBSD OR SOLARIS)
set(HAVE_PTHREAD_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_SIGNAL_H 1)
-endif()
-
-if (ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
set(HAVE_SYS_IOCTL_H 1)
-endif()
-
-if (ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_SYS_MMAN_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
set(HAVE_SYS_PARAM_H 1)
-endif()
-
-if (ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_SYS_RESOURCE_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
set(HAVE_SYS_STAT_H 1)
-endif()
-
-if (ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
set(HAVE_SYS_TIME_H 1)
-endif()
-
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
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)
+else()
+ # Other platforms that we don't promise support for.
+ # Notable exception is z/OS, which can't be detected via CMAKE_SYSTEM_NAME.
+ check_include_file(dlfcn.h HAVE_DLFCN_H)
+ check_include_file(errno.h HAVE_ERRNO_H)
+ check_include_file(fcntl.h HAVE_FCNTL_H)
+ check_include_file(fenv.h HAVE_FENV_H)
+ check_include_file(link.h HAVE_LINK_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(sys/types.h HAVE_SYS_TYPES_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 (ANDROID OR APPLE OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD)
- set(HAVE_SYSEXITS_H 1)
+if( UNIX AND NOT (APPLE OR BEOS OR HAIKU) )
+ # Used by check_symbol_exists:
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
+endif()
+# x86_64 FreeBSD 9.2 requires libcxxrt to be specified explicitly.
+if( CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND
+ CMAKE_SIZEOF_VOID_P EQUAL 8 )
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt")
endif()
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR SOLARIS)
- set(HAVE_TERMIOS_H 1)
+# Do checks with _XOPEN_SOURCE and large-file API on AIX, because we will build
+# with those too.
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700")
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_LARGE_FILE_API")
endif()
-if (AIX OR ANDROID OR APPLE OR CYGWIN OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
- set(HAVE_UNISTD_H 1)
+# Do checks with _FILE_OFFSET_BITS=64 on Solaris, because we will build
+# with those too.
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
endif()
check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
>From 31f51e44ba737bbdc22ccd2ef6d1a08c781095ba Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Sun, 18 Aug 2024 16:49:12 +0300
Subject: [PATCH 3/3] Move `LLVM_USING_GLIBC` back
---
llvm/cmake/config-ix.cmake | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index a10082cedac246..8ded6939b94d2d 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -49,8 +49,6 @@ include(CheckCompilerVersion)
include(CheckProblematicConfigurations)
include(HandleLLVMStdlib)
-check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
-
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)
@@ -474,6 +472,7 @@ else()
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
endif()
+check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
if( LLVM_USING_GLIBC )
add_compile_definitions(_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
More information about the llvm-commits
mailing list