[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:08:09 PST 2025
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/104706
>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/8] 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/8] 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/8] 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")
>From 25c080a54a057073420b86535de2c218c3e011b4 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Mon, 19 Aug 2024 23:36:53 +0300
Subject: [PATCH 4/8] Add z/OS values
---
llvm/cmake/config-ix.cmake | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 8ded6939b94d2d..9932eac55d04b4 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -27,6 +27,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
set(NETBSD 1)
endif()
+# Confirmed in
+# https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297153534
+if (CMAKE_SYSTEM_NAME MATCHES "OS390")
+ set(ZOS 1)
+endif()
+
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
set(OPENBSD 1)
endif()
@@ -148,9 +154,30 @@ elseif (PURE_WINDOWS)
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()
# 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)
>From d226369c7bebfe4b432043f030131a96f5fb6850 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Tue, 20 Aug 2024 14:50:58 +0300
Subject: [PATCH 5/8] Adjust AIX values
---
llvm/cmake/config-ix.cmake | 30 +++++-------------------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 9932eac55d04b4..e394e63b8be090 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -75,36 +75,16 @@ if (ANDROID OR DRAGONFLY OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SO
set(HAVE_SYSEXITS_H 1)
set(HAVE_TERMIOS_H 1)
set(HAVE_UNISTD_H 1)
-elseif (AIX)
+elseif (AIX OR CYGWIN)
set(HAVE_DLFCN_H 1)
set(HAVE_ERRNO_H 1)
set(HAVE_FCNTL_H 1)
- set(HAVE_FENV_H 0)
+ 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 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)
@@ -115,14 +95,14 @@ elseif (APPLE)
set(HAVE_SYSEXITS_H 1)
set(HAVE_TERMIOS_H 1)
set(HAVE_UNISTD_H 1)
-elseif (CYGWIN)
+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 0)
- set(HAVE_MALLOC_MALLOC_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)
>From 82bcfdb79de1234ca7d6346ec0f43ef904c8341f Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Tue, 20 Aug 2024 14:51:51 +0300
Subject: [PATCH 6/8] Don't define ZOS
---
llvm/cmake/config-ix.cmake | 6 ------
1 file changed, 6 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index e394e63b8be090..37c5a2975185a0 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -27,12 +27,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
set(NETBSD 1)
endif()
-# Confirmed in
-# https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297153534
-if (CMAKE_SYSTEM_NAME MATCHES "OS390")
- set(ZOS 1)
-endif()
-
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
set(OPENBSD 1)
endif()
>From b25fbf6fb6ecce9d1f6071ab45034c49bc623964 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Wed, 21 Aug 2024 16:46:06 +0300
Subject: [PATCH 7/8] Remove `HAVE_LINK_H`
---
llvm/cmake/config-ix.cmake | 6 ------
1 file changed, 6 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 37c5a2975185a0..17590fb45ecd58 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -54,7 +54,6 @@ if (ANDROID OR DRAGONFLY OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SO
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)
@@ -74,7 +73,6 @@ elseif (AIX OR CYGWIN)
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)
@@ -94,7 +92,6 @@ elseif (APPLE)
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)
@@ -114,7 +111,6 @@ elseif (PURE_WINDOWS)
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)
@@ -135,7 +131,6 @@ elseif (ZOS)
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)
@@ -156,7 +151,6 @@ else()
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)
>From 4ebf4aca0e2e693825d780c9b87f089aca98c9fb Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Wed, 21 Aug 2024 16:54:33 +0300
Subject: [PATCH 8/8] Inline checks for `CMAKE_SYSTEM_NAME`
---
llvm/cmake/config-ix.cmake | 36 ++----------------------------------
1 file changed, 2 insertions(+), 34 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 17590fb45ecd58..ee79ebd3512e6b 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -3,38 +3,6 @@ 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 "DragonFly")
- set(DRAGONFLY 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)
@@ -49,7 +17,7 @@ include(CheckCompilerVersion)
include(CheckProblematicConfigurations)
include(HandleLLVMStdlib)
-if (ANDROID OR DRAGONFLY OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SOLARIS)
+if (ANDROID OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Haiku|Linux|NetBSD|OpenBSD|SunOS")
set(HAVE_DLFCN_H 1)
set(HAVE_ERRNO_H 1)
set(HAVE_FCNTL_H 1)
@@ -68,7 +36,7 @@ if (ANDROID OR DRAGONFLY OR FREEBSD OR HAIKU OR LINUX OR NETBSD OR OPENBSD OR SO
set(HAVE_SYSEXITS_H 1)
set(HAVE_TERMIOS_H 1)
set(HAVE_UNISTD_H 1)
-elseif (AIX OR CYGWIN)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CYGWIN)
set(HAVE_DLFCN_H 1)
set(HAVE_ERRNO_H 1)
set(HAVE_FCNTL_H 1)
More information about the llvm-commits
mailing list