Skip to content

Commit d06ae33

Browse files
authored
[libc++][modules] Removes module testing. (llvm#76083)
This removes the entire modules testing infrastructure. The current infrastructure uses CMake to generate the std and std.compat module. This requires quite a bit of plumbing and uses CMake. Since CMake introduced module support in CMake 3.26, modules have a higher CMake requirement than the rest of the LLVM project. (The LLVM project requires 3.20.) The main motivation for this approach was how libc++ generated its modules. Every header had its own module partition. This was changed to improve performance and now only two modules remain. The code to build these can be manually crafted. A followup patch will reenable testing modules, using a different approach.
1 parent d89a0a6 commit d06ae33

27 files changed

+13
-291
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ concurrency:
3535

3636

3737
env:
38-
CMAKE: "/opt/bin/cmake"
3938
# LLVM POST-BRANCH bump version
4039
# LLVM POST-BRANCH add compiler test for ToT - 1, e.g. "Clang 17"
4140
# LLVM RELEASE bump remove compiler ToT - 3, e.g. "Clang 15"
@@ -169,24 +168,18 @@ jobs:
169168
'bootstrapping-build'
170169
]
171170
machine: [ 'libcxx-runners-8-set' ]
172-
std_modules: [ 'OFF' ]
173171
include:
174172
- config: 'generic-cxx26'
175173
machine: libcxx-runners-8-set
176-
std_modules: 'ON'
177174
- config: 'generic-asan'
178175
machine: libcxx-runners-8-set
179-
std_modules: 'OFF'
180176
- config: 'generic-tsan'
181177
machine: libcxx-runners-8-set
182-
std_modules: 'OFF'
183178
- config: 'generic-ubsan'
184179
machine: libcxx-runners-8-set
185-
std_modules: 'OFF'
186180
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
187181
- config: 'generic-msan'
188182
machine: libcxx-runners-8-set
189-
std_modules: 'OFF'
190183
runs-on: ${{ matrix.machine }}
191184
steps:
192185
- uses: actions/checkout@v4
@@ -196,7 +189,6 @@ jobs:
196189
CC: clang-18
197190
CXX: clang++-18
198191
ENABLE_CLANG_TIDY: "OFF"
199-
ENABLE_STD_MODULES: ${{ matrix.std_modules }}
200192
- uses: actions/upload-artifact@v3
201193
if: always()
202194
with:

libcxx/CMakeLists.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
117117
the shared library they shipped should turn this on and see `include/__availability`
118118
for more details." OFF)
119119
option(LIBCXX_ENABLE_CLANG_TIDY "Whether to compile and run clang-tidy checks" OFF)
120-
# TODO MODULES Remove this option and test for the requirements (CMake/Clang) instead.
121-
option(LIBCXX_ENABLE_STD_MODULES
122-
"Whether to enable the building the C++23 `std` module. This feature is
123-
experimental and has additional dependencies. Only enable this when
124-
interested in testing or developing this module. See
125-
https://libcxx.llvm.org/Modules.html for more information." OFF)
126120

127121
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
128122
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in")
@@ -772,7 +766,6 @@ config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE)
772766
config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
773767
config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
774768
config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
775-
config_define_if_not(LIBCXX_ENABLE_STD_MODULES _LIBCPP_HAS_NO_STD_MODULES)
776769
config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE)
777770
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
778771

@@ -856,19 +849,15 @@ endfunction()
856849
add_subdirectory(include)
857850
add_subdirectory(src)
858851
add_subdirectory(utils)
859-
if (LIBCXX_ENABLE_STD_MODULES)
860-
add_subdirectory(modules)
861-
endif()
852+
add_subdirectory(modules)
862853

863854
set(LIBCXX_TEST_DEPS "cxx_experimental")
864855

865856
if (LIBCXX_ENABLE_CLANG_TIDY)
866857
list(APPEND LIBCXX_TEST_DEPS cxx-tidy)
867858
endif()
868859

869-
if (LIBCXX_ENABLE_STD_MODULES)
870-
list(APPEND LIBCXX_TEST_DEPS generate-cxx-modules generate-test-module-std)
871-
endif()
860+
list(APPEND LIBCXX_TEST_DEPS generate-cxx-modules)
872861

873862
if (LIBCXX_INCLUDE_BENCHMARKS)
874863
add_subdirectory(benchmarks)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_TEST_PARAMS "std=c++26" CACHE STRING "")
32
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_HARDENING_MODE "extensive" CACHE STRING "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
32
set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_TEST_PARAMS "enable_experimental=False" CACHE STRING "")
32
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
32
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
43
set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_TIME_ZONE_DATABASE OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_UNICODE OFF CACHE BOOL "")
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
21
set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")

libcxx/docs/Modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ directory. First libc++ needs to be build with module support enabled.
115115
$ git clone https://github.com/llvm/llvm-project.git
116116
$ cd llvm-project
117117
$ mkdir build
118-
$ cmake -G Ninja -S runtimes -B build -DLIBCXX_ENABLE_STD_MODULES=ON -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
118+
$ cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
119119
$ ninja -C build
120120
121121
The above ``build`` directory will be referred to as ``<build>`` in the

libcxx/docs/ReleaseNotes/18.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Improvements and New Features
8989
- The ``_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE`` macro has been added to make
9090
the function ``std::shared_ptr<...>::unique()`` available.
9191

92+
- The cmake option ``LIBCXX_ENABLE_STD_MODULES`` has been removed. The test
93+
infrastructure no longer depends on a modern CMake, it works with the minimal
94+
required LLVM version (3.20.0).
95+
9296

9397
Deprecations and Removals
9498
-------------------------

libcxx/modules/CMakeLists.txt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
if (CMAKE_VERSION VERSION_LESS 3.26)
2-
message(WARNING "The libc++ modules won't be available because the CMake version is too old. Update to CMake 3.26 or later.")
3-
return()
4-
endif()
5-
61
# The headers of Table 24: C++ library headers [tab:headers.cpp]
72
# and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
83
set(LIBCXX_MODULE_STD_SOURCES
@@ -142,28 +137,6 @@ set(LIBCXX_MODULE_STD_COMPAT_SOURCES
142137
std.compat/cwctype.inc
143138
)
144139

145-
# TODO MODULES the CMakeLists.txt in the install directory is only temporary
146-
# When that is removed the configured file can use the substitution
147-
# LIBCXX_GENERATED_INCLUDE_TARGET_DIR avoiding this set.
148-
# Also clean up the parts needed to generate the install version.
149-
# - LIBCXX_GENERATED_INCLUDE_DIR contains the libc++ headers
150-
# - LIBCXX_GENERATED_INCLUDE_TARGET_DIR contains the libc++ site config
151-
if ("${LIBCXX_GENERATED_INCLUDE_DIR}" STREQUAL "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
152-
# This typically happens when the target is not installed.
153-
set(LIBCXX_CONFIGURED_INCLUDE_DIRS "${LIBCXX_GENERATED_INCLUDE_DIR}")
154-
else()
155-
# It's important that the arch directory be included first so that its header files
156-
# which interpose on the default include dir be included instead of the default ones.
157-
set(LIBCXX_CONFIGURED_INCLUDE_DIRS
158-
"${LIBCXX_GENERATED_INCLUDE_TARGET_DIR};${LIBCXX_GENERATED_INCLUDE_DIR}"
159-
)
160-
endif()
161-
configure_file(
162-
"CMakeLists.txt.in"
163-
"${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt"
164-
@ONLY
165-
)
166-
167140
set(LIBCXX_MODULE_STD_INCLUDE_SOURCES)
168141
foreach(file ${LIBCXX_MODULE_STD_SOURCES})
169142
set(
@@ -193,7 +166,6 @@ configure_file(
193166
)
194167

195168
set(_all_modules)
196-
list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt")
197169
list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm")
198170
list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm")
199171
foreach(file ${LIBCXX_MODULE_STD_SOURCES} ${LIBCXX_MODULE_STD_COMPAT_SOURCES})

libcxx/modules/CMakeLists.txt.in

Lines changed: 0 additions & 86 deletions
This file was deleted.

libcxx/test/CMakeLists.txt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,6 @@ if (LIBCXX_INCLUDE_TESTS)
8787
${CMAKE_CURRENT_BINARY_DIR}
8888
DEPENDS cxx-test-depends)
8989

90-
if(LIBCXX_ENABLE_STD_MODULES)
91-
# Generates the modules used in the test.
92-
# Note the test will regenerate this with the proper setting
93-
# - the right DCMAKE_CXX_STANDARD
94-
# - the right test compilation flags
95-
# Since modules depend on these flags there currently is no way to
96-
# avoid generating these for the tests. The advantage of the
97-
# pre generation is that less build information needs to be shared
98-
# in the bridge.
99-
add_custom_command(
100-
OUTPUT "${CMAKE_BINARY_DIR}/test/__config_module__/CMakeCache.txt"
101-
COMMAND
102-
${CMAKE_COMMAND}
103-
"-G${CMAKE_GENERATOR}"
104-
"-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
105-
"-B${CMAKE_BINARY_DIR}/test/__config_module__"
106-
"-H${LIBCXX_GENERATED_MODULE_DIR}"
107-
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
108-
"-DCMAKE_CXX_STANDARD=23"
109-
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
110-
)
111-
add_custom_target(generate-test-module-std
112-
DEPENDS "${CMAKE_BINARY_DIR}/test/__config_module__/CMakeCache.txt"
113-
COMMENT "Builds generic module std.")
114-
endif()
11590
endif()
11691

11792
if (LIBCXX_GENERATE_COVERAGE)

libcxx/test/configs/cmake-bridge.cfg.in

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,3 @@ config.substitutions.append(('%{target-include}', '@LIBCXX_GENERATED_INCLUDE_TAR
3131
config.substitutions.append(('%{lib}', '@LIBCXX_LIBRARY_DIR@'))
3232
config.substitutions.append(('%{module}', '@LIBCXX_GENERATED_MODULE_DIR@'))
3333
config.substitutions.append(('%{test-tools}', '@LIBCXX_TEST_TOOLS_PATH@'))
34-
35-
# The test needs to manually rebuild the module. The compiler flags used in the
36-
# test need to be the same as the compiler flags used to generate the module.
37-
# In the future, when CMake can generated modules this may no longer be
38-
# necessary.
39-
# TODO MODULES whether it's possible to remove this substitution.
40-
config.substitutions.append(('%{cmake}', '@CMAKE_COMMAND@'))

0 commit comments

Comments
 (0)