[libcxx-commits] [libcxx] 5b2363a - [libc++][AIX] Fix force_thread_creation_failure by using RLIMIT_THREADS (#188787)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 31 00:05:03 PDT 2026


Author: Himadhith
Date: 2026-03-31T12:34:58+05:30
New Revision: 5b2363a1027c3a172326d0f43a23fbbe5d70a304

URL: https://github.com/llvm/llvm-project/commit/5b2363a1027c3a172326d0f43a23fbbe5d70a304
DIFF: https://github.com/llvm/llvm-project/commit/5b2363a1027c3a172326d0f43a23fbbe5d70a304.diff

LOG: [libc++][AIX] Fix force_thread_creation_failure by using RLIMIT_THREADS (#188787)

This patch fixes the test `force_thread_creation_failure.cpp` on AIX by
using platform specific `RLIMIT_THREADS` which helps in restricting the
thread creation as `RLIMIT_NPROC` on AIX restricts processes and not
threads.

---------

Co-authored-by: himadhith <himadhith.v at ibm.com>

Added: 
    lib.out
    tmp.exe

Modified: 
    libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp

Removed: 
    


################################################################################
diff  --git a/lib.out b/lib.out
new file mode 100644
index 0000000000000..3dccf1b1c016e
--- /dev/null
+++ b/lib.out
@@ -0,0 +1,38 @@
++ set +x
+--- Diagnose tools in use
++ cmake --version
+cmake version 4.2.0
+
+CMake suite maintained and supported by Kitware (kitware.com/cmake).
++ ninja --version
+1.12.1
++ /xl_le/compgpfs/builds/continuous/openxlC/aix/v1714p/latest/bin/ibm-clang --version
+IBM Open XL C/C++ for AIX 17.1.4 (5725-C72, 5765-J18), version 17.1.4.3, clang version 21.1.8 (build fab5847 fab584759d67508c07d1bf7523fded49ae9a4f0a) 
+Target: powerpc64-ibm-aix7.2.0.0
+Thread model: posix
+InstalledDir: /compgpfs/build/xlcit/continuous/openxlC/aix/v1714p/219/opt/IBM/openxlC/17.1.4/bin
+Build config: +assertions
++ /xl_le/compgpfs/builds/continuous/openxlC/aix/v1714p/latest/bin/ibm-clang++_r --version
+IBM Open XL C/C++ for AIX 17.1.4 (5725-C72, 5765-J18), version 17.1.4.3, clang version 21.1.8 (build fab5847 fab584759d67508c07d1bf7523fded49ae9a4f0a) 
+Target: powerpc64-ibm-aix7.2.0.0
+Thread model: posix
+InstalledDir: /compgpfs/build/xlcit/continuous/openxlC/aix/v1714p/219/opt/IBM/openxlC/17.1.4/bin
+Build config: +assertions
++ case "${BUILDER}" in
++ clean
++ rm -rf /home/himadhit/llvm/community/llvm-project/build/aix
++ generate-cmake -C /home/himadhit/llvm/community/llvm-project/libcxx/cmake/caches/AIX.cmake -DLIBCXX_TEST_CONFIG=ibm-libc++-shared.cfg.in -DLIBCXXABI_TEST_CONFIG=ibm-libc++abi-shared.cfg.in -DLIBUNWIND_TEST_CONFIG=ibm-libunwind-shared.cfg.in
++ generate-cmake-base '-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi;libunwind' -DLIBCXX_CXX_ABI=libcxxabi -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -C /home/himadhit/llvm/community/llvm-project/libcxx/cmake/caches/AIX.cmake -DLIBCXX_TEST_CONFIG=ibm-libc++-shared.cfg.in -DLIBCXXABI_TEST_CONFIG=ibm-libc++abi-shared.cfg.in -DLIBUNWIND_TEST_CONFIG=ibm-libunwind-shared.cfg.in
++ step 'Generating CMake'
++ endstep
++ set +x
++ set +x
+--- Generating CMake
++ cmake -S /home/himadhit/llvm/community/llvm-project/runtimes -B /home/himadhit/llvm/community/llvm-project/build/aix -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/home/himadhit/llvm/community/llvm-project/build/aix/install -DLIBCXX_ENABLE_WERROR=YES -DLIBCXXABI_ENABLE_WERROR=YES -DLIBUNWIND_ENABLE_WERROR=YES -DCMAKE_INSTALL_MESSAGE=NEVER '-DLLVM_LIT_ARGS=-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests' '-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi;libunwind' -DLIBCXX_CXX_ABI=libcxxabi -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -C /home/himadhit/llvm/community/llvm-project/libcxx/cmake/caches/AIX.cmake -DLIBCXX_TEST_CONFIG=ibm-libc++-shared.cfg.in -DLIBCXXABI_TEST_CONFIG=ibm-libc++abi-shared.cfg.in -DLIBUNWIND_TEST_CONFIG=ibm-libunwind-shared.cfg.in
+loading initial cache file /home/himadhit/llvm/community/llvm-project/libcxx/cmake/caches/AIX.cmake
+-- Performing standalone runtimes build.
+-- The C compiler identification is IBMClang 17.1.4.3
+-- The CXX compiler identification is IBMClang 17.1.4.3
+-- The ASM compiler identification is Clang with GNU-like command-line
+-- Found assembler: /xl_le/compgpfs/builds/continuous/openxlC/aix/v1714p/latest/bin/ibm-clang
+-- Detecting C compiler ABI info

diff  --git a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
index 70009589e985b..40daa49393bd4 100644
--- a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
@@ -16,8 +16,7 @@
 // There is no way to limit the number of threads on windows
 // UNSUPPORTED: windows
 
-// AIX, macOS and FreeBSD seem to limit the number of processes, not threads via RLIMIT_NPROC
-// XFAIL: target={{.+}}-aix{{.*}}
+// macOS and FreeBSD seem to limit the number of processes, not threads via RLIMIT_NPROC.
 // XFAIL: target={{.+}}-apple-{{.*}}
 // XFAIL: freebsd
 
@@ -33,17 +32,20 @@
 
 #if __has_include(<sys/resource.h>)
 #  include <sys/resource.h>
-#  ifdef RLIMIT_NPROC
-void force_thread_creation_failure() {
-  rlimit lim = {1, 1};
-  assert(setrlimit(RLIMIT_NPROC, &lim) == 0);
-}
+#  if defined(_AIX) && defined(RLIMIT_THREADS)
+#    define TEST_RLIMIT RLIMIT_THREADS
+#  elif defined(RLIMIT_NPROC)
+#    define TEST_RLIMIT RLIMIT_NPROC
 #  else
 #    error "No known way to force only one thread being available"
 #  endif
 #else
 #  error "No known way to force only one thread being available"
 #endif
+void force_thread_creation_failure() {
+  rlimit lim = {1, 1};
+  assert(setrlimit(TEST_RLIMIT, &lim) == 0);
+}
 
 int main(int, char**) {
   force_thread_creation_failure();

diff  --git a/tmp.exe b/tmp.exe
new file mode 100755
index 0000000000000..de19d9f514c91
Binary files /dev/null and b/tmp.exe 
diff er


        


More information about the libcxx-commits mailing list