[llvm] [CMake] Remove some always-true HAVE_XXX_H (PR #123087)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 08:58:38 PST 2025
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/123087
These are unneeded even on AIX, PURE_WINDOWS, and ZOS (per #104706)
* HAVE_ERRNO_H: 1a93330ffa2ae2aa0b49461f05e6f0d51e8443f8 (2009).
* HAVE_SYS_STAT_H
* HAVE_FENV_H
>From ffbc2f687f84d417f3210d4e7d500fd8a6d6e71d Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Wed, 15 Jan 2025 08:58:14 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
llvm/cmake/config-ix.cmake | 2 --
llvm/include/llvm/Config/config.h.cmake | 6 ------
llvm/include/llvm/Support/FileSystem.h | 2 --
llvm/lib/Analysis/ConstantFolding.cpp | 4 ++--
.../ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp | 8 +++-----
llvm/lib/Support/Errno.cpp | 5 -----
llvm/lib/Support/Unix/Path.inc | 2 --
llvm/lib/Support/Unix/Process.inc | 2 --
llvm/lib/Support/Unix/Program.inc | 2 --
llvm/lib/Support/Unix/Signals.inc | 2 --
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn | 3 ---
.../llvm/include/llvm/Config/config.h | 3 ---
utils/bazel/llvm_configs/config.h.cmake | 3 ---
13 files changed, 5 insertions(+), 39 deletions(-)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 64878d28d9e1e5..14248624d54504 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -59,7 +59,6 @@ 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(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
if( NOT PURE_WINDOWS )
@@ -69,7 +68,6 @@ 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/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)
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index 3e6b94dfbe5458..dbecb5c17ce386 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -72,9 +72,6 @@
/* Define if __unw_add_dynamic_fde() is available on this platform. */
#cmakedefine HAVE_UNW_ADD_DYNAMIC_FDE ${HAVE_UNW_ADD_DYNAMIC_FDE}
-/* Define to 1 if you have the <errno.h> header file. */
-#cmakedefine HAVE_ERRNO_H ${HAVE_ERRNO_H}
-
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H ${HAVE_FCNTL_H}
@@ -198,9 +195,6 @@
/* Define to 1 if you have the <sys/resource.h> header file. */
#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H}
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H}
-
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H}
diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h
index 9cf53360b4e966..c16ea2dcbb770f 100644
--- a/llvm/include/llvm/Support/FileSystem.h
+++ b/llvm/include/llvm/Support/FileSystem.h
@@ -44,9 +44,7 @@
#include <system_error>
#include <vector>
-#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
-#endif
namespace llvm {
namespace sys {
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 031d675c330ec4..ecdc841a38d112 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1885,7 +1885,7 @@ Constant *GetConstantFoldFPValue128(float128 V, Type *Ty) {
/// Clear the floating-point exception state.
inline void llvm_fenv_clearexcept() {
-#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT
+#if HAVE_DECL_FE_ALL_EXCEPT
feclearexcept(FE_ALL_EXCEPT);
#endif
errno = 0;
@@ -1896,7 +1896,7 @@ inline bool llvm_fenv_testexcept() {
int errno_val = errno;
if (errno_val == ERANGE || errno_val == EDOM)
return true;
-#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT && HAVE_DECL_FE_INEXACT
+#if HAVE_DECL_FE_ALL_EXCEPT && HAVE_DECL_FE_INEXACT
if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
return true;
#endif
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
index 71036f33cf9291..10160ddbf826ee 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
@@ -20,11 +20,9 @@
#ifdef __linux__
// These includes used by RTDyldMemoryManager::getPointerToNamedFunction()
// for Glibc trickery. See comments in this function for more information.
- #ifdef HAVE_SYS_STAT_H
- #include <sys/stat.h>
- #endif
- #include <fcntl.h>
- #include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
#endif
namespace llvm {
diff --git a/llvm/lib/Support/Errno.cpp b/llvm/lib/Support/Errno.cpp
index 60a7e536b6c5cf..0ef8d1ef1c99ae 100644
--- a/llvm/lib/Support/Errno.cpp
+++ b/llvm/lib/Support/Errno.cpp
@@ -13,10 +13,7 @@
#include "llvm/Support/Errno.h"
#include "llvm/Config/config.h"
#include <cstring>
-
-#if HAVE_ERRNO_H
#include <errno.h>
-#endif
//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only TRULY operating system
@@ -26,11 +23,9 @@
namespace llvm {
namespace sys {
-#if HAVE_ERRNO_H
std::string StrError() {
return StrError(errno);
}
-#endif // HAVE_ERRNO_H
std::string StrError(int errnum) {
std::string str;
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 44097bad7b46ed..9f943687c9e721 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -18,9 +18,7 @@
#include "Unix.h"
#include <limits.h>
#include <stdio.h>
-#if HAVE_SYS_STAT_H
#include <sys/stat.h>
-#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index 3c07cba7122bf9..bc7391bd8c08aa 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -26,9 +26,7 @@
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
-#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
-#endif
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index ec0fad7076b450..9af2c175806275 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -28,9 +28,7 @@
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/raw_ostream.h"
-#if HAVE_SYS_STAT_H
#include <sys/stat.h>
-#endif
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 50d6248ba6af8e..b66e858c965ffb 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -53,9 +53,7 @@
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
-#if HAVE_SYS_STAT_H
#include <sys/stat.h>
-#endif
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index 75a370a3b7e8ee..db2a78765858fc 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -89,9 +89,7 @@ write_cmake_config("config") {
"HAVE_DECL_FE_ALL_EXCEPT=1",
"HAVE_DECL_FE_INEXACT=1",
"LLVM_ENABLE_CRASH_DUMPS=",
- "HAVE_ERRNO_H=1",
"HAVE_FCNTL_H=1",
- "HAVE_FENV_H=1",
"HAVE_FFI_CALL=",
"HAVE_FFI_FFI_H=",
"HAVE_FFI_H=",
@@ -101,7 +99,6 @@ write_cmake_config("config") {
"HAVE_PTHREAD_GET_NAME_NP=",
"HAVE_PTHREAD_SET_NAME_NP=",
"HAVE_SIGNAL_H=1",
- "HAVE_SYS_STAT_H=1",
"HAVE_VALGRIND_VALGRIND_H=",
"HAVE__ALLOCA=",
"HAVE___ALLOCA=",
diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
index 74b4eca0889a7a..52e5106812c1f3 100644
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -201,9 +201,6 @@
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
diff --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake
index 3e6b94dfbe5458..9dfb70710f74e3 100644
--- a/utils/bazel/llvm_configs/config.h.cmake
+++ b/utils/bazel/llvm_configs/config.h.cmake
@@ -198,9 +198,6 @@
/* Define to 1 if you have the <sys/resource.h> header file. */
#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H}
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H}
-
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H}
More information about the llvm-commits
mailing list