Skip to content

[CMake] Remove some unneeded HAVE_*_H #123282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Jan 17, 2025

No description provided.

Created using spr 1.3.5-bogner
@llvmbot llvmbot added cmake Build system in general and CMake in particular llvm:support bazel "Peripheral" support tier build system: utils/bazel labels Jan 17, 2025
@MaskRay MaskRay added the skip-precommit-approval PR for CI feedback, not intended for review label Jan 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2025

@llvm/pr-subscribers-llvm-support

Author: Fangrui Song (MaskRay)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/123282.diff

10 Files Affected:

  • (modified) llvm/cmake/config-ix.cmake (+1-21)
  • (modified) llvm/include/llvm/Config/config.h.cmake (-6)
  • (modified) llvm/lib/Support/Unix/Process.inc (-4)
  • (modified) llvm/lib/Support/Unix/Program.inc (-2)
  • (modified) llvm/lib/Support/Unix/Signals.inc (-2)
  • (modified) llvm/lib/Support/Unix/Unix.h (+1-3)
  • (modified) llvm/unittests/Support/CrashRecoveryTest.cpp (-2)
  • (modified) llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn (-3)
  • (modified) utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h (-6)
  • (modified) utils/bazel/llvm_configs/config.h.cmake (-6)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 38f339d17c8529..51e0ba3b6b3350 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -22,13 +22,9 @@ if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|
   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)
@@ -37,13 +33,9 @@ elseif (APPLE)
   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)
@@ -52,13 +44,9 @@ elseif (PURE_WINDOWS)
   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)
@@ -69,13 +57,9 @@ elseif (ZOS)
   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)
@@ -85,13 +69,9 @@ else()
   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)
@@ -364,7 +344,7 @@ check_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
 # Avoid sigaltstack on Apple platforms, where backtrace() cannot handle it
 # (rdar://7089625) and _Unwind_Backtrace is unusable because it cannot unwind
 # past the signal handler after an assertion failure (rdar://29866587).
-if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
+if( NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
   check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK)
 endif()
 check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index d51d01017d9867..60b53c41de4fbe 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -171,9 +171,6 @@
 /* Define to 1 if you have the `sigaltstack' function. */
 #cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK}
 
-/* Define to 1 if you have the <signal.h> header file. */
-#cmakedefine HAVE_SIGNAL_H ${HAVE_SIGNAL_H}
-
 /* Define to 1 if you have the `strerror_r' function. */
 #cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R}
 
@@ -189,9 +186,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/time.h> header file. */
-#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H}
-
 /* Define to 1 if stat struct has st_mtimespec member .*/
 #cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC}
 
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index 2c55059e055bc6..e1469644104430 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -18,16 +18,12 @@
 #include <mutex>
 #include <optional>
 #include <fcntl.h>
-#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
 #include <sys/stat.h>
-#if HAVE_SIGNAL_H
 #include <signal.h>
-#endif
 #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
 #include <malloc.h>
 #endif
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 74312ed6238aef..10632e8fa7e039 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -32,9 +32,7 @@
 #if HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
-#if HAVE_SIGNAL_H
 #include <signal.h>
-#endif
 #include <fcntl.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index b66e858c965ffb..b2f68d25221a2f 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -50,9 +50,7 @@
 #ifdef HAVE_BACKTRACE
 #include BACKTRACE_HEADER // For backtrace().
 #endif
-#if HAVE_SIGNAL_H
 #include <signal.h>
-#endif
 #include <sys/stat.h>
 #if HAVE_DLFCN_H
 #include <dlfcn.h>
diff --git a/llvm/lib/Support/Unix/Unix.h b/llvm/lib/Support/Unix/Unix.h
index 4840b51f75908d..f16c7fcda22c32 100644
--- a/llvm/lib/Support/Unix/Unix.h
+++ b/llvm/lib/Support/Unix/Unix.h
@@ -36,9 +36,7 @@
 #include <unistd.h>
 #endif
 
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
+#include <sys/time.h>
 #include <time.h>
 
 #ifdef HAVE_DLFCN_H
diff --git a/llvm/unittests/Support/CrashRecoveryTest.cpp b/llvm/unittests/Support/CrashRecoveryTest.cpp
index a22e532ec4c831..ceafba5b36f113 100644
--- a/llvm/unittests/Support/CrashRecoveryTest.cpp
+++ b/llvm/unittests/Support/CrashRecoveryTest.cpp
@@ -26,10 +26,8 @@
 #endif
 
 #ifdef LLVM_ON_UNIX
-#ifdef HAVE_SIGNAL_H
 #include <signal.h>
 #endif
-#endif
 
 using namespace llvm;
 using namespace llvm::sys;
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 350eaac84d6685..e89d84105e945f 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -97,7 +97,6 @@ write_cmake_config("config") {
     "HAVE_MALLCTL=",
     "HAVE_PTHREAD_GET_NAME_NP=",
     "HAVE_PTHREAD_SET_NAME_NP=",
-    "HAVE_SIGNAL_H=1",
     "HAVE_VALGRIND_VALGRIND_H=",
     "HAVE__ALLOCA=",
     "HAVE___ALLOCA=",
@@ -225,7 +224,6 @@ write_cmake_config("config") {
       "HAVE_SYS_IOCTL_H=",
       "HAVE_SYS_MMAN_H=",
       "HAVE_SYS_RESOURCE_H=",
-      "HAVE_SYS_TIME_H=",
       "HAVE_TERMIOS_H=",
       "HAVE_UNISTD_H=",
       "HAVE__CHSIZE_S=1",
@@ -260,7 +258,6 @@ write_cmake_config("config") {
       "HAVE_SYS_IOCTL_H=1",
       "HAVE_SYS_MMAN_H=1",
       "HAVE_SYS_RESOURCE_H=1",
-      "HAVE_SYS_TIME_H=1",
       "HAVE_TERMIOS_H=1",
       "HAVE_UNISTD_H=1",
       "HAVE__CHSIZE_S=",
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 dba7129e4c87d1..38ae47fc8ae191 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
@@ -174,9 +174,6 @@
 /* Define to 1 if you have the `sigaltstack' function. */
 #define HAVE_SIGALTSTACK 1
 
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
-
 /* Define to 1 if you have the `strerror_r' function. */
 /* HAVE_STRERROR_R defined in Bazel */
 
@@ -192,9 +189,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/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
 /* Define to 1 if stat struct has st_mtimespec member .*/
 /* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */
 
diff --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake
index d51d01017d9867..60b53c41de4fbe 100644
--- a/utils/bazel/llvm_configs/config.h.cmake
+++ b/utils/bazel/llvm_configs/config.h.cmake
@@ -171,9 +171,6 @@
 /* Define to 1 if you have the `sigaltstack' function. */
 #cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK}
 
-/* Define to 1 if you have the <signal.h> header file. */
-#cmakedefine HAVE_SIGNAL_H ${HAVE_SIGNAL_H}
-
 /* Define to 1 if you have the `strerror_r' function. */
 #cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R}
 
@@ -189,9 +186,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/time.h> header file. */
-#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H}
-
 /* Define to 1 if stat struct has st_mtimespec member .*/
 #cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC}
 

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 263fed7ce9d2c155af44829018673caa67fa4f47 f591ea23e58acbb6287e02ceebc78c23a27faab0 --extensions inc,h,cpp -- llvm/lib/Support/Unix/Process.inc llvm/lib/Support/Unix/Program.inc llvm/lib/Support/Unix/Signals.inc llvm/lib/Support/Unix/Unix.h llvm/unittests/Support/CrashRecoveryTest.cpp utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
View the diff from clang-format here.
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index e146964410..74fe142b00 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -15,15 +15,15 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/config.h"
 #include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_THREADS
+#include <fcntl.h>
 #include <mutex>
 #include <optional>
-#include <fcntl.h>
 #include <sys/time.h>
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
-#include <sys/stat.h>
 #include <signal.h>
+#include <sys/stat.h>
 #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
 #include <malloc.h>
 #endif
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 10632e8fa7..df73ba0e54 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -32,8 +32,8 @@
 #if HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
-#include <signal.h>
 #include <fcntl.h>
+#include <signal.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif

@MaskRay MaskRay merged commit f999b11 into main Jan 17, 2025
9 of 13 checks passed
@MaskRay MaskRay deleted the users/MaskRay/spr/cmake-remove-some-unneeded-have__h branch January 17, 2025 05:37
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 17, 2025
@nickdesaulniers
Copy link
Member

careful with these kind of changes; llvm-libc may be lacking some of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel cmake Build system in general and CMake in particular llvm:support skip-precommit-approval PR for CI feedback, not intended for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants