-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CMake] Remove HAVE_SYS_RESOURCE_H/HAVE_SETRLIMIT/HAVE_GETRLIMIT #123288
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
MaskRay
merged 3 commits into
main
from
users/MaskRay/spr/cmake-remove-have_sys_resource_hhave_setrlimithave_getrlimit
Jan 17, 2025
Merged
[CMake] Remove HAVE_SYS_RESOURCE_H/HAVE_SETRLIMIT/HAVE_GETRLIMIT #123288
MaskRay
merged 3 commits into
main
from
users/MaskRay/spr/cmake-remove-have_sys_resource_hhave_setrlimithave_getrlimit
Jan 17, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-llvm-support Author: Fangrui Song (MaskRay) ChangesOnly used by Unix/Program.inc and seem always available. Full diff: https://github.com/llvm/llvm-project/pull/123288.diff 7 Files Affected:
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bb63fb000c8200..0cc3a4aa5cccda 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -23,7 +23,6 @@ if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 1)
set(HAVE_SYS_MMAN_H 1)
- set(HAVE_SYS_RESOURCE_H 1)
set(HAVE_SYSEXITS_H 1)
set(HAVE_UNISTD_H 1)
elseif (APPLE)
@@ -32,7 +31,6 @@ elseif (APPLE)
set(HAVE_MALLOC_MALLOC_H 1)
set(HAVE_PTHREAD_H 1)
set(HAVE_SYS_MMAN_H 1)
- set(HAVE_SYS_RESOURCE_H 1)
set(HAVE_SYSEXITS_H 1)
set(HAVE_UNISTD_H 1)
elseif (PURE_WINDOWS)
@@ -41,7 +39,6 @@ elseif (PURE_WINDOWS)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 0)
set(HAVE_SYS_MMAN_H 0)
- set(HAVE_SYS_RESOURCE_H 0)
set(HAVE_SYSEXITS_H 0)
set(HAVE_UNISTD_H 0)
elseif (ZOS)
@@ -52,7 +49,6 @@ elseif (ZOS)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 1)
set(HAVE_SYS_MMAN_H 1)
- set(HAVE_SYS_RESOURCE_H 1)
set(HAVE_SYSEXITS_H 0)
set(HAVE_UNISTD_H 1)
else()
@@ -62,7 +58,6 @@ else()
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
check_include_file(pthread.h HAVE_PTHREAD_H)
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
- check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sysexits.h HAVE_SYSEXITS_H)
check_include_file(unistd.h HAVE_UNISTD_H)
endif()
@@ -326,7 +321,6 @@ check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
-check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
check_symbol_exists(isatty unistd.h HAVE_ISATTY)
check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
check_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
@@ -342,7 +336,6 @@ check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
check_symbol_exists(mallinfo2 malloc.h HAVE_MALLINFO2)
check_symbol_exists(malloc_zone_statistics malloc/malloc.h
HAVE_MALLOC_ZONE_STATISTICS)
-check_symbol_exists(getrlimit "sys/types.h;sys/time.h;sys/resource.h" HAVE_GETRLIMIT)
check_symbol_exists(posix_spawn spawn.h HAVE_POSIX_SPAWN)
check_symbol_exists(pread unistd.h HAVE_PREAD)
check_symbol_exists(sbrk unistd.h HAVE_SBRK)
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index 62bf533f0d92dc..f4bdfeb1e76b6b 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -165,9 +165,6 @@
/* Define to 1 if you have the `setenv' function. */
#cmakedefine HAVE_SETENV ${HAVE_SETENV}
-/* Define to 1 if you have the `setrlimit' function. */
-#cmakedefine HAVE_SETRLIMIT ${HAVE_SETRLIMIT}
-
/* Define to 1 if you have the `sigaltstack' function. */
#cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK}
@@ -180,9 +177,6 @@
/* Define to 1 if you have the <sys/mman.h> header file. */
#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H}
-/* 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 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 dcfc38fa9f9736..550b0de2e0455b 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -19,9 +19,7 @@
#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>
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
@@ -128,7 +126,6 @@ void Process::GetTimeUsage(TimePoint<> &elapsed,
// their operation. To prevent the disk from filling up, this function
// does what's necessary to prevent their generation.
void Process::PreventCoreFiles() {
-#if HAVE_SETRLIMIT
struct rlimit rlim;
getrlimit(RLIMIT_CORE, &rlim);
#ifdef __linux__
@@ -151,7 +148,6 @@ void Process::PreventCoreFiles() {
rlim.rlim_cur = 0;
#endif
setrlimit(RLIMIT_CORE, &rlim);
-#endif
#if defined(HAVE_MACH_MACH_H) && !defined(__GNU__)
// Disable crash reporting on Mac OS X 10.0-10.4
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 10632e8fa7e039..0708df1eed0a3a 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -29,9 +29,7 @@
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/raw_ostream.h"
#include <sys/stat.h>
-#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
-#endif
#include <signal.h>
#include <fcntl.h>
#if HAVE_UNISTD_H
@@ -140,7 +138,6 @@ static bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg,
static void TimeOutHandler(int Sig) {}
static void SetMemoryLimits(unsigned size) {
-#if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT
struct rlimit r;
__typeof__(r.rlim_cur) limit = (__typeof__(r.rlim_cur))(size)*1048576;
@@ -154,7 +151,6 @@ static void SetMemoryLimits(unsigned size) {
r.rlim_cur = limit;
setrlimit(RLIMIT_RSS, &r);
#endif
-#endif
}
static std::vector<const char *>
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 75477ec7bb498c..9b8990b5a6bcf6 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -206,7 +206,6 @@ write_cmake_config("config") {
"HAVE_DLOPEN=",
"HAVE_FUTIMES=",
"HAVE_GETPAGESIZE=",
- "HAVE_GETRLIMIT=",
"HAVE_GETRUSAGE=",
"HAVE_ISATTY=",
"HAVE_LIBPTHREAD=",
@@ -217,12 +216,10 @@ write_cmake_config("config") {
"HAVE_PTHREAD_RWLOCK_INIT=",
"HAVE_SBRK=",
"HAVE_SETENV=",
- "HAVE_SETRLIMIT=",
"HAVE_SIGALTSTACK=",
"HAVE_STRERROR_R=",
"HAVE_SYSCONF=",
"HAVE_SYS_MMAN_H=",
- "HAVE_SYS_RESOURCE_H=",
"HAVE_UNISTD_H=",
"HAVE__CHSIZE_S=1",
"HAVE__UNWIND_BACKTRACE=",
@@ -238,7 +235,6 @@ write_cmake_config("config") {
"HAVE_DLOPEN=1",
"HAVE_FUTIMES=1",
"HAVE_GETPAGESIZE=1",
- "HAVE_GETRLIMIT=1",
"HAVE_GETRUSAGE=1",
"HAVE_ISATTY=1",
"HAVE_LIBPTHREAD=1",
@@ -249,12 +245,10 @@ write_cmake_config("config") {
"HAVE_PTHREAD_RWLOCK_INIT=1",
"HAVE_SBRK=1",
"HAVE_SETENV=1",
- "HAVE_SETRLIMIT=1",
"HAVE_SIGALTSTACK=1",
"HAVE_STRERROR_R=1",
"HAVE_SYSCONF=1",
"HAVE_SYS_MMAN_H=1",
- "HAVE_SYS_RESOURCE_H=1",
"HAVE_UNISTD_H=1",
"HAVE__CHSIZE_S=",
"HAVE__UNWIND_BACKTRACE=1",
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 9436aef2e75a2d..fbea5099d33322 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
@@ -168,9 +168,6 @@
/* Define to 1 if you have the `setenv' function. */
/* HAVE_SETENV defined in Bazel */
-/* Define to 1 if you have the `setrlimit' function. */
-#define HAVE_SETRLIMIT 1
-
/* Define to 1 if you have the `sigaltstack' function. */
#define HAVE_SIGALTSTACK 1
@@ -183,9 +180,6 @@
/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_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 62bf533f0d92dc..f4bdfeb1e76b6b 100644
--- a/utils/bazel/llvm_configs/config.h.cmake
+++ b/utils/bazel/llvm_configs/config.h.cmake
@@ -165,9 +165,6 @@
/* Define to 1 if you have the `setenv' function. */
#cmakedefine HAVE_SETENV ${HAVE_SETENV}
-/* Define to 1 if you have the `setrlimit' function. */
-#cmakedefine HAVE_SETRLIMIT ${HAVE_SETRLIMIT}
-
/* Define to 1 if you have the `sigaltstack' function. */
#cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK}
@@ -180,9 +177,6 @@
/* Define to 1 if you have the <sys/mman.h> header file. */
#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H}
-/* 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 stat struct has st_mtimespec member .*/
#cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC}
|
You can test this locally with the following command:git-clang-format --diff 219beb7aca6ee9888072fdb28522e1fb64fdbaa8 699a1466b143297e4e286c17ef451939222a1529 --extensions inc,h -- llvm/lib/Support/Unix/Process.inc llvm/lib/Support/Unix/Program.inc 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 550b0de2e0..422d915beb 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -15,13 +15,13 @@
#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>
+#include <signal.h>
#include <sys/resource.h>
#include <sys/stat.h>
-#include <signal.h>
+#include <sys/time.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 0708df1eed..d6cd6b1bf0 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -28,10 +28,10 @@
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/raw_ostream.h"
-#include <sys/stat.h>
-#include <sys/resource.h>
-#include <signal.h>
#include <fcntl.h>
+#include <signal.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
|
Created using spr 1.3.5-bogner
Created using spr 1.3.5-bogner
github-actions bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Jan 17, 2025
…RLIMIT Only used by Unix/Program.inc and seem always available. Pull Request: llvm/llvm-project#123288
AnthonyLatsis
added a commit
to AnthonyLatsis/swift
that referenced
this pull request
May 28, 2025
`HAVE_SYS_RESOURCE_H` was removed in llvm/llvm-project#123288, so this header is no longer included at this particular location on rebranch, which breaks the Linux build, where it is not transitively included either. Use the same condition as in the use site (`getChildrenMaxResidentSetSize`) instead.
AnthonyLatsis
added a commit
to AnthonyLatsis/swift
that referenced
this pull request
May 28, 2025
`HAVE_SYS_RESOURCE_H` was removed in llvm/llvm-project#123288, so this header is no longer included at this particular location on rebranch, which breaks the Linux build, where it is not transitively included either. Use the same condition as in the use site (`getChildrenMaxResidentSetSize`) instead. Also, don't wrap `HAVE_GETRUSAGE` in `defined()` in case it does get defined to 0.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only used by Unix/Program.inc and seem always available.