[libcxx-commits] [libcxx] 0eefb26 - [libc++] Build the library with C++26 (#181021)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 17 06:05:56 PDT 2026
Author: Louis Dionne
Date: 2026-03-17T09:05:51-04:00
New Revision: 0eefb2682bf8c04954c46e91916b5164d8424702
URL: https://github.com/llvm/llvm-project/commit/0eefb2682bf8c04954c46e91916b5164d8424702
DIFF: https://github.com/llvm/llvm-project/commit/0eefb2682bf8c04954c46e91916b5164d8424702.diff
LOG: [libc++] Build the library with C++26 (#181021)
All supported compilers support C++26. This allows simplifying some of
the upcoming <text_encoding> implementation.
Added:
Modified:
libcxx/CMakeLists.txt
libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 0ec6d196e9772..e1620f91a453c 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -4,6 +4,12 @@
cmake_minimum_required(VERSION 3.20.0)
set(LLVM_SUBPROJECT_TITLE "libc++")
+# Unset the C++ Standard: other projects sometimes override this global property, which
+# is incompatible with libc++ (since we set our own standard via other means).
+# TODO: Figure out which other part of the build is setting this and resolve the issue
+# at the root.
+unset(CMAKE_CXX_STANDARD CACHE)
+
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
# Add path for custom modules
@@ -502,11 +508,13 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
# Required flags ==============================================================
function(cxx_add_basic_build_flags target)
- # Use C++23 for all targets.
- set_target_properties(${target} PROPERTIES
- CXX_STANDARD 23
- CXX_STANDARD_REQUIRED OFF # TODO: Make this REQUIRED once we don't need to accommodate the LLVM documentation builders using an ancient CMake
- CXX_EXTENSIONS NO)
+ # Use C++26 for all targets. Note that we don't use CXX_STANDARD or cxx_std_foo
+ # since that requires a newer CMake than is available.
+ if (LIBCXX_TARGETING_CLANG_CL)
+ target_compile_options(${target} PRIVATE /std:c++latest)
+ else()
+ target_compile_options(${target} PRIVATE -std=c++26)
+ endif()
# When building the dylib, don't warn for unavailable aligned allocation
# functions based on the deployment target -- they are always available
diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
index 521a60c0fc498..3663575e33e55 100644
--- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
@@ -25,8 +25,6 @@ endif()
message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
-set(CMAKE_CXX_STANDARD 20)
-
# Link only against clangTidy itself, not anything that clangTidy uses; otherwise we run setup code multiple times
# which results in clang-tidy crashing
set_target_properties(clangTidy PROPERTIES INTERFACE_LINK_LIBRARIES "")
More information about the libcxx-commits
mailing list