[libc-commits] [clang] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [CMake] Bump the minimum required version to 3.31 (PR #232658)
Mehdi Amini via libc-commits
libc-commits at lists.llvm.org
Sat Oct 17 02:26:04 PDT 2026
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/232658
>From 7a015beb06cc6855d4603e0165de50f276fe88ae Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 15 Sep 2026 21:45:40 +0000
Subject: [PATCH 1/4] [CMake] Bump the minimum required version to 3.31
This is a follow up to e192ec42b426f6ffbc25419238a90f3c59088587 which
changes the warning to an error when using CMake older than 3.31.
See
https://discourse.llvm.org/t/91086
Assisted-by: Codex
---
bolt/CMakeLists.txt | 9 +--------
clang/CMakeLists.txt | 10 +---------
compiler-rt/CMakeLists.txt | 10 +---------
flang/CMakeLists.txt | 10 +---------
libc/CMakeLists.txt | 10 +---------
libclc/CMakeLists.txt | 9 +--------
libcxx/CMakeLists.txt | 10 +---------
libcxxabi/CMakeLists.txt | 10 +---------
libsycl/CMakeLists.txt | 9 +--------
libunwind/CMakeLists.txt | 10 +---------
lld/CMakeLists.txt | 10 +---------
lldb/CMakeLists.txt | 10 +---------
llvm-libgcc/CMakeLists.txt | 10 +---------
llvm/CMakeLists.txt | 9 +--------
mlir/CMakeLists.txt | 10 +---------
offload/CMakeLists.txt | 10 +---------
openmp/CMakeLists.txt | 10 +---------
orc-rt/CMakeLists.txt | 9 +--------
polly/CMakeLists.txt | 10 +---------
runtimes/CMakeLists.txt | 9 +--------
20 files changed, 20 insertions(+), 174 deletions(-)
diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt
index 8deb5cea0401ba..87646a9554ed2a 100644
--- a/bolt/CMakeLists.txt
+++ b/bolt/CMakeLists.txt
@@ -1,11 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "BOLT")
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index bc415539fceb13..e37f38f4e18a20 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -1,12 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "Clang")
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 0458b17ba38c20..44bdb20587f785 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -3,15 +3,7 @@
# An important constraint of the build is that it only produces libraries
# based on the ability of the host toolchain to target various platforms.
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "compiler-rt")
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 83e9655220590e..a0d7eef5b5b3a5 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -1,12 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "Flang")
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index b6c6b0aa546e2d..d2415fd83e2388 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -1,12 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "libc")
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 5829bd9b39eac0..f6eb1833e6eebe 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -1,11 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
+cmake_minimum_required(VERSION 3.31.0)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(libclc VERSION 0.2.0 LANGUAGES CXX C)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index d163f0f579c395..27485a1936ccdd 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -1,15 +1,7 @@
#===============================================================================
# Setup Project
#===============================================================================
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "libc++")
# Unset the C++ Standard: other projects sometimes override this global property, which
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 6ea3cea30bdbc9..0fdf0e1e91f0ad 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -4,15 +4,7 @@
# Setup Project
#===============================================================================
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "libc++abi")
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
diff --git a/libsycl/CMakeLists.txt b/libsycl/CMakeLists.txt
index 609103ce226a6c..6e2467361df5aa 100644
--- a/libsycl/CMakeLists.txt
+++ b/libsycl/CMakeLists.txt
@@ -1,14 +1,7 @@
#===============================================================================
# Setup Project
#===============================================================================
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "libsycl")
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 93a3a0b74c8766..7427ba2c059a94 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -2,15 +2,7 @@
# Setup Project
#===============================================================================
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "libunwind")
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 5181eb272d5be9..d3557dc94e493b 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -1,12 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "LLD")
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 7f45487c1d2d70..05d443d1273eb5 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -1,12 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "LLDB")
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt
index a2974473279361..131c7729cbfc33 100644
--- a/llvm-libgcc/CMakeLists.txt
+++ b/llvm-libgcc/CMakeLists.txt
@@ -2,15 +2,7 @@
# Setup Project
#===============================================================================
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "LLVM libgcc")
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 5dd8797b506792..88f8da9ab5de7f 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1,12 +1,5 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
+cmake_minimum_required(VERSION 3.31.0)
include(CMakeDependentOption)
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 68df5aed001e2e..233fc61ed12d7b 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -1,13 +1,5 @@
# MLIR project.
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "MLIR")
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index e09ba60c5055e8..4f7c4477cc8dae 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -1,15 +1,7 @@
# See for https://openmp.llvm.org/SupportAndFAQ.html for instructions on how
# to build offload with CMake.
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "liboffload")
# The minimum versions required for dependencies.
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index f9a89859be7afa..f02d1d3e0283e2 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -1,12 +1,4 @@
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_SUBPROJECT_TITLE "OpenMP")
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
diff --git a/orc-rt/CMakeLists.txt b/orc-rt/CMakeLists.txt
index a025f3256fdad8..82407ccb4268b9 100644
--- a/orc-rt/CMakeLists.txt
+++ b/orc-rt/CMakeLists.txt
@@ -4,14 +4,7 @@
# Setup Project
#===============================================================================
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
+cmake_minimum_required(VERSION 3.31.0)
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt
index 48459c61f456f9..7a8766b79e0f0c 100644
--- a/polly/CMakeLists.txt
+++ b/polly/CMakeLists.txt
@@ -1,15 +1,7 @@
# Check if this is a in tree build.
if (NOT DEFINED LLVM_MAIN_SRC_DIR)
project(Polly)
- cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
-
+ cmake_minimum_required(VERSION 3.31.0)
set(POLLY_STANDALONE_BUILD TRUE)
endif()
set(LLVM_SUBPROJECT_TITLE "Polly")
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index a0ec44617c9c77..a66dcffc032c5f 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -1,12 +1,5 @@
# This file handles building LLVM runtime sub-projects.
-cmake_minimum_required(VERSION 3.20.0)
-if("${CMAKE_VERSION}" VERSION_LESS "3.31.0")
- message(WARNING
- "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the "
- "minimum version of CMake required to build LLVM will become 3.31.0, and "
- "using an older CMake will become an error. Please upgrade your CMake to "
- "at least 3.31.0 now to avoid issues in the future.")
-endif()
+cmake_minimum_required(VERSION 3.31.0)
# This file can be used in two ways: the bootstrapping build calls it from
# llvm/runtimes/CMakeLists.txt where we reuse the build tree of the top-level
>From 9357f75cad1150d5030e8f5a4fa1d1053f90e7a7 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Fri, 16 Oct 2026 02:28:39 -0700
Subject: [PATCH 2/4] [libc++] Provision a suitable CMake for CI builds
The previous commit raised cmake_minimum_required to 3.31. The GitHub
jobs already satisfy it (the Linux image pins 3.31.0, macOS uses brew,
Windows uses the hosted image), but some self-hosted Buildkite agents
ship an older CMake and their images cannot be updated by us.
Teach run-buildbot to check the CMake version up front. When the cmake
on PATH is new enough, this costs a single `cmake --version` and nothing
else changes. Otherwise, download a pinned, SHA-256 verified CMake
3.31.12 release binary into ${XDG_CACHE_HOME:-~/.cache}/libcxx (outside
the build directory that run-buildbot wipes) and, when no binary exists
for the host or it cannot run there, bootstrap it from source with the
host compilers rather than the runtime's CC/CXX. The install is
published with an atomic rename so concurrent builders on one agent
never see a partial cache entry.
An explicit CMAKE override is still honored but now validated; in the
provisioned or overridden cases its directory is prepended to PATH so
helper scripts that run a bare `cmake` see the same binary. The slow
paths rely on curl and python3; the latter is already required by lit.
Assisted-by: Codex
Assisted-by: Claude Code
---
libcxx/utils/ci/ensure-cmake.sh | 180 ++++++++++++++++++++++++++++++++
libcxx/utils/ci/run-buildbot | 36 +++++--
2 files changed, 205 insertions(+), 11 deletions(-)
create mode 100644 libcxx/utils/ci/ensure-cmake.sh
diff --git a/libcxx/utils/ci/ensure-cmake.sh b/libcxx/utils/ci/ensure-cmake.sh
new file mode 100644
index 00000000000000..208e6e11765d2d
--- /dev/null
+++ b/libcxx/utils/ci/ensure-cmake.sh
@@ -0,0 +1,180 @@
+#!/usr/bin/env bash
+# ===----------------------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+# ===----------------------------------------------------------------------===##
+
+# Sourced by run-buildbot, which runs with `set -e`.
+#
+# Some self-hosted CI agents ship a CMake older than what runtimes/CMakeLists.txt
+# requires. When that happens, provision a pinned, checksum-verified CMake into
+# a per-user cache. When the host CMake is recent enough, this costs a single
+# `cmake --version` and changes nothing else.
+#
+# Keep CMAKE_MIN_VERSION in sync with cmake_minimum_required() in
+# runtimes/CMakeLists.txt.
+CMAKE_MIN_VERSION=3.31
+CMAKE_PINNED_VERSION=3.31.12
+
+function cmake-is-supported() {
+ local version
+ version=$("$1" --version 2>/dev/null) || return 1
+ [[ "$version" =~ ^cmake\ version\ ([0-9]+)\.([0-9]+)\. ]] || return 1
+ (( BASH_REMATCH[1] > ${CMAKE_MIN_VERSION%%.*} ||
+ (BASH_REMATCH[1] == ${CMAKE_MIN_VERSION%%.*} &&
+ BASH_REMATCH[2] >= ${CMAKE_MIN_VERSION##*.}) ))
+}
+
+# python3 is already required by the test suite (lit), so it is used here for
+# the pieces that have no portable shell equivalent across Linux, macOS, AIX,
+# FreeBSD and Git Bash on Windows.
+function download-cmake-archive() {
+ local filename="$1" destination="$2" sha256="$3"
+ # Fail on a stalled transfer instead of hanging until the CI timeout.
+ curl --fail --location --retry 3 --connect-timeout 30 \
+ --speed-limit 1024 --speed-time 60 \
+ "https://github.com/Kitware/CMake/releases/download/v${CMAKE_PINNED_VERSION}/${filename}" \
+ --output "$destination"
+ python3 -c 'import hashlib, sys
+if hashlib.sha256(open(sys.argv[1], "rb").read()).hexdigest() != sys.argv[2]:
+ sys.exit("CMake archive checksum mismatch: " + sys.argv[1])' "$destination" "$sha256"
+}
+
+# Runs in a subshell so the EXIT trap, cd, and CC/CXX/flag changes do not leak
+# into the caller.
+function install-cmake() (
+ set -e
+ local install_dir="$1" system="$2" arch="$3"
+ local version="$CMAKE_PINNED_VERSION"
+ local archive='' sha256=''
+ mkdir -p "$(dirname "$install_dir")"
+ # Not `local`: bash unsets locals before running the EXIT trap when the
+ # function is invoked with a redirection. The subshell scopes it anyway.
+ work=$(mktemp -d "${install_dir}.tmp.XXXXXX")
+ trap 'rm -rf "$work"' EXIT
+
+ # Discard an incomplete or unusable installation from an earlier run.
+ if [[ -e "$install_dir" ]]; then
+ mv "$install_dir" "${work}/stale"
+ fi
+
+ # Select binaries by host, not by the architecture being tested.
+ case "${system}-${arch}" in
+ Linux-x86_64)
+ archive="cmake-${version}-linux-x86_64.tar.gz"
+ sha256=0dc2e9a6860f06bf10bd8fadc03e35d9eeb4df46e33763a7e480e987758f385c
+ ;;
+ Linux-aarch64)
+ archive="cmake-${version}-linux-aarch64.tar.gz"
+ sha256=83f8fd91d2038a56556e1400390fcfe42f79602940c494f6c6f1cdae7f9e7f40
+ ;;
+ Darwin-x86_64|Darwin-arm64)
+ archive="cmake-${version}-macos10.10-universal.tar.gz"
+ sha256=cf096d869d45b79f5ce82f3d6abffa44f983fc146fee13cfe59024911e6975af
+ ;;
+ MINGW*-x86_64|MSYS*-x86_64|CYGWIN*-x86_64)
+ archive="cmake-${version}-windows-x86_64.zip"
+ sha256=0c4baa40f28b3f8225eb3fdf6946c987b4fe901403b4eaf2fbbd9378100aaa0c
+ ;;
+ MINGW*-aarch64|MSYS*-aarch64|CYGWIN*-aarch64)
+ archive="cmake-${version}-windows-arm64.zip"
+ sha256=e4160c1842dea858ad376ff2ec17587104515b51714eca5963b8bdd798105553
+ ;;
+ esac
+
+ if [[ -n "$archive" ]]; then
+ download-cmake-archive "$archive" "${work}/${archive}" "$sha256"
+ if [[ "$archive" == *.zip ]]; then
+ # Git for Windows does not ship unzip.
+ python3 -m zipfile -e "${work}/${archive}" "${work}/binary"
+ mv "${work}/binary/cmake-${version}-windows-"* "${work}/install"
+ elif [[ "$system" == Darwin ]]; then
+ mkdir "${work}/binary"
+ tar -xzf "${work}/${archive}" -C "${work}/binary" --strip-components=1
+ mv "${work}/binary/CMake.app/Contents" "${work}/install"
+ else
+ mkdir "${work}/install"
+ tar -xzf "${work}/${archive}" -C "${work}/install" --strip-components=1
+ fi
+ fi
+
+ # No binary for this host, or one that is incompatible with its libc/loader.
+ if ! cmake-is-supported "${work}/install/bin/cmake"; then
+ echo "Bootstrapping CMake ${version} from source for ${system}-${arch}"
+ download-cmake-archive "cmake-${version}.tar.gz" "${work}/source.tar.gz" \
+ 5f3fd5a54dfa65602bdbed64f981a72673cc19f2d304cc2955cf0dfa0cfd8272
+ rm -rf "${work}/install"
+ mkdir -p "${work}/source" "${work}/build"
+ tar -xzf "${work}/source.tar.gz" -C "${work}/source" --strip-components=1
+ # CC/CXX and flags from run-buildbot may target a different machine.
+ export CC="${HOST_CC:-cc}" CXX="${HOST_CXX:-c++}"
+ unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS CMAKE_TOOLCHAIN_FILE
+ local jobs make_program=make
+ jobs="${CMAKE_BOOTSTRAP_JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 8)}"
+ if command -v gmake >/dev/null 2>&1; then
+ make_program=gmake
+ fi
+ # The runtime builds don't need CMake's HTTPS support. Avoid requiring
+ # OpenSSL development headers on the host just to bootstrap CMake.
+ # Build in a nested subshell so the EXIT trap does not run from inside
+ # the directory it removes.
+ (
+ cd "${work}/build"
+ "${work}/source/bootstrap" --prefix="${work}/install" --parallel="$jobs" \
+ -- -DCMAKE_USE_OPENSSL=OFF -DBUILD_TESTING=OFF
+ "$make_program" -j "$jobs"
+ "$make_program" install
+ )
+ cmake-is-supported "${work}/install/bin/cmake"
+ fi
+
+ # Publish the complete, relocatable install atomically. If another builder
+ # populated the cache while we were working, the rename fails; in that case
+ # discard our copy (via the EXIT trap) and use theirs.
+ python3 -c 'import os, sys
+try:
+ os.rename(sys.argv[1], sys.argv[2])
+except OSError as error:
+ sys.exit("CMake install already present: " + str(error))' \
+ "${work}/install" "$install_dir" \
+ || cmake-is-supported "${install_dir}/bin/cmake"
+)
+
+function ensure-cmake() {
+ local cmake_dir
+ if [[ -n ${CMAKE+x} ]]; then
+ if ! cmake-is-supported "$CMAKE"; then
+ echo "CMAKE must name a runnable CMake ${CMAKE_MIN_VERSION} or newer" \
+ "(output must start with 'cmake version'): ${CMAKE}" >&2
+ return 1
+ fi
+ # Scripts we invoke that run a bare `cmake` must see the same binary.
+ cmake_dir=$(cd "$(dirname "$(command -v "$CMAKE")")" && pwd)
+ elif cmake-is-supported cmake; then
+ # Fast path: use the host's cmake as-is; do not reorder PATH.
+ CMAKE=cmake
+ export CMAKE
+ return 0
+ else
+ local system arch install_dir
+ system=$(uname -s)
+ arch=$(uname -m)
+ # Keep tools outside BUILD_DIR, which run-buildbot's clean() removes.
+ install_dir="${XDG_CACHE_HOME:-${HOME:-${TMPDIR:-/tmp}}/.cache}/libcxx/cmake-${CMAKE_PINNED_VERSION}-${system}-${arch}"
+ if ! cmake-is-supported "${install_dir}/bin/cmake"; then
+ echo "cmake on PATH is missing or older than ${CMAKE_MIN_VERSION};" \
+ "provisioning CMake ${CMAKE_PINNED_VERSION} into ${install_dir}" >&2
+ # Called as a plain statement: wrapping it in `||` or `if !` would
+ # disable errexit inside the subshell.
+ install-cmake "$install_dir" "$system" "$arch"
+ fi
+ CMAKE="${install_dir}/bin/cmake"
+ cmake-is-supported "$CMAKE" || return 1
+ cmake_dir="${install_dir}/bin"
+ fi
+ PATH="${cmake_dir}:${PATH}"
+ export CMAKE PATH
+}
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 3bfb5bb5fb02c3..92a92dc1f7e03e 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -29,7 +29,22 @@ ${PROGNAME} [options] <BUILDER>
this is '<llvm-root>/build/<builder>'.
Environment variables
-CMAKE The cmake binary to use. This variable is optional.
+CMAKE The cmake binary to use. This variable is optional. When
+ unset, the cmake found on PATH is used if it is at least
+ version 3.31; otherwise a pinned CMake is downloaded (or
+ built from source) and cached.
+
+HOST_CC, HOST_CXX Host compilers used only when CMake has to be bootstrapped
+ from source, defaulting to cc and c++. These are
+ independent of the runtime's CC and CXX.
+
+CMAKE_BOOTSTRAP_JOBS
+ Number of parallel jobs when bootstrapping CMake from
+ source (default: number of online processors).
+
+XDG_CACHE_HOME Parent of the cache directory for the provisioned CMake,
+ stored in <XDG_CACHE_HOME>/libcxx/ (default: ~/.cache).
+ Keep it outside --build-dir, which the build wipes.
NINJA The ninja binary to use, this value is used by CMake. This
variable is optional.
@@ -100,10 +115,6 @@ MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
INSTALL_DIR="${BUILD_DIR}/install"
-if [ -z ${CMAKE+x} ]; then
- CMAKE=cmake
-fi
-
if [ -z ${NINJA+x} ]; then
NINJA=ninja
else
@@ -120,9 +131,12 @@ if [ -z ${CXX+x} ]; then
exit 1
fi
+source "${MONOREPO_ROOT}/libcxx/utils/ci/ensure-cmake.sh"
+ensure-cmake
+
# Print the version of a few tools to aid diagnostics in some cases
step "Diagnose tools in use"
-${CMAKE} --version
+"${CMAKE}" --version
${NINJA} --version
${CC} --version
${CXX} --version
@@ -139,7 +153,7 @@ function generate-cmake-base() {
export PATH="$PATH:/opt/compiler-explorer/clang-trunk/bin"
# We can remove -DCMAKE_INSTALL_MESSAGE=NEVER once https://gitlab.kitware.com/cmake/cmake/-/issues/26085 is fixed.
- ${CMAKE} \
+ "${CMAKE}" \
-S "${MONOREPO_ROOT}/runtimes" \
-B "${BUILD_DIR}" \
-GNinja \
@@ -219,7 +233,7 @@ function test-armv7m-picolibc() {
# architecture name, which is not what Clang's driver expects to find.
# The install location will however be wrong with
# LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, so we correct that below.
- ${CMAKE} \
+ "${CMAKE}" \
-S "${MONOREPO_ROOT}/compiler-rt" \
-B "${BUILD_DIR}/compiler-rt" \
-GNinja \
@@ -469,7 +483,7 @@ bootstrapping-build)
fi
step "Generating CMake"
- ${CMAKE} \
+ "${CMAKE}" \
-S "${MONOREPO_ROOT}/llvm" \
-B "${BUILD_DIR}" \
-GNinja \
@@ -676,7 +690,7 @@ apple-system|apple-system-hardened)
# In the Apple system configuration, we build libc++ and libunwind separately.
step "Installing libc++ and libc++abi in Apple-system configuration"
- ${CMAKE} \
+ "${CMAKE}" \
-S "${MONOREPO_ROOT}/runtimes" \
-B "${BUILD_DIR}/cxx" \
-GNinja \
@@ -693,7 +707,7 @@ apple-system|apple-system-hardened)
-DLIBCXXABI_TEST_PARAMS="${params}"
step "Installing libunwind in Apple-system configuration"
- ${CMAKE} \
+ "${CMAKE}" \
-S "${MONOREPO_ROOT}/runtimes" \
-B "${BUILD_DIR}/unwind" \
-GNinja \
>From 562796d7c3edb5ffcc9801abc545865946dccfd6 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Fri, 16 Oct 2026 08:25:21 -0700
Subject: [PATCH 3/4] [libc++abi] Retain the old CMP0155 behavior for GCC
compatibility
Raising the minimum CMake version to 3.31 enables automatic module dependency
scanning for the C++23 libc++abi object libraries. GCC 16 and 17 then probe
the libstdc++ bits/stdc++.h header when processing libc++ headers and fail
if it is absent.
Set CMP0155 to OLD within libc++abi only when using GCC until its optional
header lookup is fixed. Preserve automatic scanning with Clang and guard
the policy setting for older CMake versions.
GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127940
Validated the policy workaround on the CMake 3.31 minimum-version branch
with GCC 16.2.0 and CMake 3.31.12: the focused cxa_handlers.cpp reproducer
compiles. Clang 22.1.0 still generates and successfully executes the
clang-scan-deps rule for that source. git diff --check passes.
Assisted-by: Codex
---
libcxxabi/CMakeLists.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 0fdf0e1e91f0ad..5fed474e0b6c6f 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -5,6 +5,14 @@
#===============================================================================
cmake_minimum_required(VERSION 3.31.0)
+
+# GCC 16's module scanning redirects standard header includes to libstdc++
+# headers, which fails when using libc++ headers.
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127940
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND POLICY CMP0155)
+ cmake_policy(SET CMP0155 OLD)
+endif()
+
set(LLVM_SUBPROJECT_TITLE "libc++abi")
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
>From 5d1f4a9dd56c27d568b6d30a700fc6b64a51039b Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Fri, 16 Oct 2026 13:35:21 -0700
Subject: [PATCH 4/4] [libc++] Disable automatic module scanning on ARM CI
builders
The ARM Buildkite toolchains do not expose clang-scan-deps to CMake.
When CMP0155 enables automatic scanning for libc++abi C++23 sources,
these standalone runtimes builds fail with the scanner set to NOTFOUND.
Pass CMAKE_CXX_SCAN_FOR_MODULES=OFF in the eight ARM job invocations,
including the no-exceptions variants, until their toolchains provide a
matching scanner. Keep the other CI configurations on their defaults.
Validated bash syntax, git diff --check, and argument dispatch for all
eight ARM jobs with generic C++20, C++23, and modules jobs as controls.
Assisted-by: Codex
---
libcxx/utils/ci/run-buildbot | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 92a92dc1f7e03e..48700482d9a8a9 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -731,12 +731,16 @@ apple-system|apple-system-hardened)
;;
aarch64)
clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
+ # The ARM builders' preinstalled toolchains do not provide a discoverable
+ # clang-scan-deps. Disable automatic module scanning for these jobs.
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
check-runtimes
;;
aarch64-no-exceptions)
clean
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF \
-DLIBCXX_ENABLE_EXCEPTIONS=OFF \
-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
check-runtimes
@@ -744,32 +748,38 @@ aarch64-no-exceptions)
# Aka Armv8 32 bit
armv8)
clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake"
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
check-runtimes
;;
armv8-no-exceptions)
clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake"
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
check-runtimes
;;
# Armv7 32 bit. One building Arm only one Thumb only code.
armv7)
clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake"
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
check-runtimes
;;
armv7-no-exceptions)
clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake"
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
check-runtimes
;;
armv7m-picolibc)
test-armv7m-picolibc \
- -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
+ -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
;;
armv7m-picolibc-no-exceptions)
test-armv7m-picolibc \
-C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
+ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF \
-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
-DLIBCXXABI_ENABLE_STATIC_UNWINDER=OFF \
-DLIBCXX_ENABLE_EXCEPTIONS=OFF \
More information about the libc-commits
mailing list