Skip to content

Commit e7e58db

Browse files
committed
Revert "Revert llvm#76246 and llvm#76083"
This reverts commit 5c150e7.
1 parent f9bc1ee commit e7e58db

36 files changed

+200
-298
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
@@ -124,12 +124,6 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
124124
the shared library they shipped should turn this on and see `include/__availability`
125125
for more details." OFF)
126126
option(LIBCXX_ENABLE_CLANG_TIDY "Whether to compile and run clang-tidy checks" OFF)
127-
# TODO MODULES Remove this option and test for the requirements (CMake/Clang) instead.
128-
option(LIBCXX_ENABLE_STD_MODULES
129-
"Whether to enable the building the C++23 `std` module. This feature is
130-
experimental and has additional dependencies. Only enable this when
131-
interested in testing or developing this module. See
132-
https://libcxx.llvm.org/Modules.html for more information." OFF)
133127

134128
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
135129
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in")
@@ -779,7 +773,6 @@ config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE)
779773
config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
780774
config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
781775
config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
782-
config_define_if_not(LIBCXX_ENABLE_STD_MODULES _LIBCPP_HAS_NO_STD_MODULES)
783776
config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE)
784777
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
785778

@@ -863,19 +856,15 @@ endfunction()
863856
add_subdirectory(include)
864857
add_subdirectory(src)
865858
add_subdirectory(utils)
866-
if (LIBCXX_ENABLE_STD_MODULES)
867-
add_subdirectory(modules)
868-
endif()
859+
add_subdirectory(modules)
869860

870861
set(LIBCXX_TEST_DEPS "cxx_experimental")
871862

872863
if (LIBCXX_ENABLE_CLANG_TIDY)
873864
list(APPEND LIBCXX_TEST_DEPS cxx-tidy)
874865
endif()
875866

876-
if (LIBCXX_ENABLE_STD_MODULES)
877-
list(APPEND LIBCXX_TEST_DEPS generate-cxx-modules generate-test-module-std)
878-
endif()
867+
list(APPEND LIBCXX_TEST_DEPS generate-cxx-modules)
879868

880869
if (LIBCXX_INCLUDE_BENCHMARKS)
881870
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/docs/TestingLibcxx.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ Custom Directives
394394
~~~~~~~~~~~~~~~~~
395395

396396
Lit has many directives built in (e.g., ``DEFINE``, ``UNSUPPORTED``). In addition to those directives, libc++ adds two additional libc++-specific directives that makes
397-
writing tests easier. See `libc++-specific Lit Directives`_ for more information about the ``FILE_DEPENDENCIES`` and ``ADDITIONAL_COMPILE_FLAGS`` libc++-specific directives.
397+
writing tests easier. See `libc++-specific Lit Directives`_ for more information about the ``FILE_DEPENDENCIES``, ``ADDITIONAL_COMPILE_FLAGS``, and ``MODULE_DEPENDENCIES`` libc++-specific directives.
398398

399399
.. _libc++-specific Lit Directives:
400400
.. list-table:: libc++-specific Lit Directives
@@ -417,6 +417,13 @@ writing tests easier. See `libc++-specific Lit Directives`_ for more information
417417
- The additional compiler flags specified by a space-separated list to the ``ADDITIONAL_COMPILE_FLAGS`` libc++-specific Lit directive will be added to the end of the ``%{compile_flags}``
418418
substitution for the test that contains it. This libc++-specific Lit directive makes it possible to add special compilation flags without having to resort to writing a ``.sh.cpp`` test (see
419419
`Lit Meaning of libc++ Test Filenames`_), more powerful but perhaps overkill.
420+
* - ``MODULE_DEPENDENCIES``
421+
- ``// MODULE_DEPENDENCIES: std std.compat``
422+
- This directive will build the required C++23 standard library
423+
modules and add the additional compiler flags in
424+
%{compile_flags}. (Libc++ offers these modules in C++20 as an
425+
extension.)
426+
420427

421428
Benchmarks
422429
==========

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@'))

libcxx/test/libcxx/module_std.gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
3131
"%{cxx}",
3232
"%{flags} %{compile_flags}",
33+
"std",
3334
)
3435

3536

libcxx/test/libcxx/module_std_compat.gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
3131
"%{cxx}",
3232
"%{flags} %{compile_flags}",
33+
"std.compat",
3334
)
3435

3536

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// Make sure that the compile flags contain no module information.
10+
11+
// MODULE_DEPENDENCIES:
12+
13+
// RUN: echo "%{compile_flags}" | grep -v "std.pcm"
14+
// RUN: echo "%{compile_flags}" | grep -v "std.compat.pcm"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10+
// UNSUPPORTED: clang-modules-build
11+
// UNSUPPORTED: gcc
12+
13+
// XFAIL: has-no-cxx-module-support
14+
15+
// picolibc does not provide the required timespec_get function, and the
16+
// "using-if-exists" mechanism apparently did not work here.
17+
// XFAIL: LIBCXX-PICOLIBC-FIXME
18+
19+
// Make sure that the compile flags contain the expected elements.
20+
// The tests only look for the expected components and not the exact flags.
21+
// Otherwise changing the location of the module would break this test.
22+
23+
// MODULE_DEPENDENCIES: std std.compat
24+
25+
// RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std=.*/std.pcm .*/std.pcm"
26+
// RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std.compat=.*/std.compat.pcm .*/std.compat.pcm"

0 commit comments

Comments
 (0)