[llvm] 6360bbb - [AIX] Raise soft memory limits to hard limits (#167928)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 17 10:46:41 PST 2025
Author: David Tenty
Date: 2025-11-17T13:46:37-05:00
New Revision: 6360bbbb6890c965016a98fab8ea76551f577c1f
URL: https://github.com/llvm/llvm-project/commit/6360bbbb6890c965016a98fab8ea76551f577c1f
DIFF: https://github.com/llvm/llvm-project/commit/6360bbbb6890c965016a98fab8ea76551f577c1f.diff
LOG: [AIX] Raise soft memory limits to hard limits (#167928)
AIX out-of-box memory soft limits are often
insufficient to run LLVM on reasonably size
inputs. Thus, we often encounter users who run
into spurious out of memory errors.
This change raises the memory soft limits
to the hard limits at LLVM startup to prevent
these types of issues.
Added:
Modified:
llvm/lib/Support/InitLLVM.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index b8fbfd21c4f28..b90f4e0714458 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -32,6 +32,34 @@
#endif
#endif
+static void RaiseLimits() {
+#ifdef _AIX
+ // AIX has restrictive memory soft-limits out-of-box, so raise them if needed.
+ auto RaiseLimit = [](int resource) {
+ struct rlimit r;
+ getrlimit(resource, &r);
+
+ // Increase the soft limit to the hard limit, if necessary and
+ // possible.
+ if (r.rlim_cur != RLIM_INFINITY && r.rlim_cur != r.rlim_max) {
+ r.rlim_cur = r.rlim_max;
+ setrlimit(resource, &r);
+ }
+ };
+
+ // Address space size.
+ RaiseLimit(RLIMIT_AS);
+ // Heap size.
+ RaiseLimit(RLIMIT_DATA);
+ // Stack size.
+ RaiseLimit(RLIMIT_STACK);
+#ifdef RLIMIT_RSS
+ // Resident set size.
+ RaiseLimit(RLIMIT_RSS);
+#endif
+#endif
+}
+
void CleanupStdHandles(void *Cookie) {
llvm::raw_ostream *Outs = &llvm::outs(), *Errs = &llvm::errs();
Outs->flush();
@@ -67,6 +95,7 @@ InitLLVM::InitLLVM(int &Argc, const char **&Argv,
StackPrinter.emplace(Argc, Argv);
sys::PrintStackTraceOnErrorSignal(Argv[0]);
install_out_of_memory_new_handler();
+ RaiseLimits();
#ifdef __MVS__
More information about the llvm-commits
mailing list