[libcxx] [libcxxabi] [libunwind] [libc++] Apply shared CMake policies in libcxx, libcxxabi and libunwind (PR #246978)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 06:17:08 PST 2026


https://github.com/huixie90 created https://github.com/llvm/llvm-project/pull/246978

The runtimes build includes cmake/Modules/CMakePolicy.cmake, which sets
CMP0182 to NEW so that shared libraries are built as shared library
archives (lib<name>.a containing the shared object) on AIX. However,
libcxx, libcxxabi and libunwind each call
cmake_minimum_required(VERSION 3.31.0) again in their own CMakeLists.txt.
That implicitly calls cmake_policy(VERSION 3.31), which unsets every
policy introduced after 3.31. CMP0182 was introduced in CMake 4.0, so it
gets reset to its OLD behaviour inside the runtimes.

With CMake < 4.0 this is invisible, since those versions always create
shared library archives on AIX. With CMake >= 4.0 the runtimes are built
as plain lib/libc++.so, lib/libc++abi.so and lib/libunwind.so instead.
The AIX test configuration links with `-L <lib-dir> -lc++`, and without
-brtl the AIX linker only looks for libc++.a. It therefore skips the
just-built libc++.so and silently picks up the older system
/usr/lib/libc++.a, both at link time and at runtime through -blibpath.

This shows up as intermittent failures in the AIX CI, depending on which
builder picks up the job: the builders running CMake 4.2 fail, while
those running CMake 3.31 pass. Only tests that need features added to
the dylib in LLVM 24 detect the stale library:

  std/utilities/debugging/is_debugger_present.pass.cpp
    (link error: undefined symbol std::is_debugger_present())
  libcxx/input.output/iostream.objects/sync_with_stdio.buffer_type.pass.cpp
  std/input.output/iostream.format/output.streams/ostream_sentry/destruct_sync_fails.pass.cpp

Fix this by including CMakePolicy.cmake again after
cmake_minimum_required() in each runtime, like llvm, clang, lld and
compiler-rt already do.

Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>


>From 17235b75b157cb1f943c4450e9d7fd14ef91c566 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Sun, 29 Nov 2026 14:04:38 +0000
Subject: [PATCH] [libc++] Apply shared CMake policies in libcxx, libcxxabi and
 libunwind

The runtimes build includes cmake/Modules/CMakePolicy.cmake, which sets
CMP0182 to NEW so that shared libraries are built as shared library
archives (lib<name>.a containing the shared object) on AIX. However,
libcxx, libcxxabi and libunwind each call
cmake_minimum_required(VERSION 3.31.0) again in their own CMakeLists.txt.
That implicitly calls cmake_policy(VERSION 3.31), which unsets every
policy introduced after 3.31. CMP0182 was introduced in CMake 4.0, so it
gets reset to its OLD behaviour inside the runtimes.

With CMake < 4.0 this is invisible, since those versions always create
shared library archives on AIX. With CMake >= 4.0 the runtimes are built
as plain lib/libc++.so, lib/libc++abi.so and lib/libunwind.so instead.
The AIX test configuration links with `-L <lib-dir> -lc++`, and without
-brtl the AIX linker only looks for libc++.a. It therefore skips the
just-built libc++.so and silently picks up the older system
/usr/lib/libc++.a, both at link time and at runtime through -blibpath.

This shows up as intermittent failures in the AIX CI, depending on which
builder picks up the job: the builders running CMake 4.2 fail, while
those running CMake 3.31 pass. Only tests that need features added to
the dylib in LLVM 24 detect the stale library:

  std/utilities/debugging/is_debugger_present.pass.cpp
    (link error: undefined symbol std::is_debugger_present())
  libcxx/input.output/iostream.objects/sync_with_stdio.buffer_type.pass.cpp
  std/input.output/iostream.format/output.streams/ostream_sentry/destruct_sync_fails.pass.cpp

Fix this by including CMakePolicy.cmake again after
cmake_minimum_required() in each runtime, like llvm, clang, lld and
compiler-rt already do.

Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
---
 libcxx/CMakeLists.txt    | 2 ++
 libcxxabi/CMakeLists.txt | 2 ++
 libunwind/CMakeLists.txt | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 2c0eaf9583f3c5..713d36a32e2c61 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -11,6 +11,8 @@ set(LLVM_SUBPROJECT_TITLE "libc++")
 unset(CMAKE_CXX_STANDARD CACHE)
 
 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
+include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
+  NO_POLICY_SCOPE)
 
 # Add path for custom modules
 list(INSERT CMAKE_MODULE_PATH 0
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 5fed474e0b6c6f..abf50c15c39798 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -16,6 +16,8 @@ endif()
 set(LLVM_SUBPROJECT_TITLE "libc++abi")
 
 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
+include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
+  NO_POLICY_SCOPE)
 
 # Add path for custom modules
 list(INSERT CMAKE_MODULE_PATH 0
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 7427ba2c059a94..daaa26fa4c6c7a 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.31.0)
 set(LLVM_SUBPROJECT_TITLE "libunwind")
 
 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
+include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
+  NO_POLICY_SCOPE)
 
 # Add path for custom modules
 list(INSERT CMAKE_MODULE_PATH 0



More information about the cfe-commits mailing list