[libcxx-commits] [libcxx] 1d6b613 - [libc++] Reland CI module improvements.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jan 21 03:14:47 PST 2024
Author: Mark de Wever
Date: 2024-01-21T12:10:36+01:00
New Revision: 1d6b6132ff9d59c27f033c8a2003ea9bff421e04
URL: https://github.com/llvm/llvm-project/commit/1d6b6132ff9d59c27f033c8a2003ea9bff421e04
DIFF: https://github.com/llvm/llvm-project/commit/1d6b6132ff9d59c27f033c8a2003ea9bff421e04.diff
LOG: [libc++] Reland CI module improvements.
Revert "Revert #76246 and #76083"
This reverts commit 5c150e7eeba9db13cc65b329b3c3537b613ae61d.
Adds a small fix that should properly disable the tests on Windows.
Unfortunately the original poster has not provided feedback and the
original patch did not fail in the LLVM CI infrastructure.
Modules are known to fail on Windows due to non compliance of the
C library. Currently not having this patch prevents testing on other
platforms.
Added:
libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
libcxx/test/libcxx/selftest/modules/std-module.sh.cpp
libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp
Modified:
.github/workflows/libcxx-build-and-test.yaml
libcxx/CMakeLists.txt
libcxx/cmake/caches/Generic-cxx26.cmake
libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake
libcxx/cmake/caches/Generic-no-exceptions.cmake
libcxx/cmake/caches/Generic-no-experimental.cmake
libcxx/cmake/caches/Generic-no-filesystem.cmake
libcxx/cmake/caches/Generic-no-localization.cmake
libcxx/cmake/caches/Generic-no-random_device.cmake
libcxx/cmake/caches/Generic-no-threads.cmake
libcxx/cmake/caches/Generic-no-tzdb.cmake
libcxx/cmake/caches/Generic-no-unicode.cmake
libcxx/cmake/caches/Generic-no-wide-characters.cmake
libcxx/docs/Modules.rst
libcxx/docs/ReleaseNotes/18.rst
libcxx/docs/TestingLibcxx.rst
libcxx/modules/CMakeLists.txt
libcxx/test/CMakeLists.txt
libcxx/test/configs/cmake-bridge.cfg.in
libcxx/test/libcxx/module_std.gen.py
libcxx/test/libcxx/module_std_compat.gen.py
libcxx/test/std/modules/std.compat.pass.cpp
libcxx/test/std/modules/std.pass.cpp
libcxx/utils/ci/Dockerfile
libcxx/utils/ci/buildkite-pipeline.yml
libcxx/utils/ci/run-buildbot
libcxx/utils/libcxx/test/config.py
libcxx/utils/libcxx/test/features.py
libcxx/utils/libcxx/test/format.py
libcxx/utils/libcxx/test/modules.py
Removed:
libcxx/modules/CMakeLists.txt.in
libcxx/test/lit.local.cfg
################################################################################
diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index 1666a687aa5d047..0cab9b841e4ee15 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -35,7 +35,6 @@ concurrency:
env:
- CMAKE: "/opt/bin/cmake"
# LLVM POST-BRANCH bump version
# LLVM POST-BRANCH add compiler test for ToT - 1, e.g. "Clang 17"
# LLVM RELEASE bump remove compiler ToT - 3, e.g. "Clang 15"
@@ -169,24 +168,18 @@ jobs:
'bootstrapping-build'
]
machine: [ 'libcxx-runners-8-set' ]
- std_modules: [ 'OFF' ]
include:
- config: 'generic-cxx26'
machine: libcxx-runners-8-set
- std_modules: 'ON'
- config: 'generic-asan'
machine: libcxx-runners-8-set
- std_modules: 'OFF'
- config: 'generic-tsan'
machine: libcxx-runners-8-set
- std_modules: 'OFF'
- config: 'generic-ubsan'
machine: libcxx-runners-8-set
- std_modules: 'OFF'
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
- config: 'generic-msan'
machine: libcxx-runners-8-set
- std_modules: 'OFF'
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout at v4
@@ -196,7 +189,6 @@ jobs:
CC: clang-18
CXX: clang++-18
ENABLE_CLANG_TIDY: "OFF"
- ENABLE_STD_MODULES: ${{ matrix.std_modules }}
- uses: actions/upload-artifact at v3
if: always()
with:
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index a5b516974700886..53de53480266b07 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -124,12 +124,6 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
the shared library they shipped should turn this on and see `include/__availability`
for more details." OFF)
option(LIBCXX_ENABLE_CLANG_TIDY "Whether to compile and run clang-tidy checks" OFF)
-# TODO MODULES Remove this option and test for the requirements (CMake/Clang) instead.
-option(LIBCXX_ENABLE_STD_MODULES
- "Whether to enable the building the C++23 `std` module. This feature is
- experimental and has additional dependencies. Only enable this when
- interested in testing or developing this module. See
- https://libcxx.llvm.org/Modules.html for more information." OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
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)
config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
-config_define_if_not(LIBCXX_ENABLE_STD_MODULES _LIBCPP_HAS_NO_STD_MODULES)
config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE)
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
@@ -863,9 +856,7 @@ endfunction()
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(utils)
-if (LIBCXX_ENABLE_STD_MODULES)
- add_subdirectory(modules)
-endif()
+add_subdirectory(modules)
set(LIBCXX_TEST_DEPS "cxx_experimental")
@@ -873,9 +864,7 @@ if (LIBCXX_ENABLE_CLANG_TIDY)
list(APPEND LIBCXX_TEST_DEPS cxx-tidy)
endif()
-if (LIBCXX_ENABLE_STD_MODULES)
- list(APPEND LIBCXX_TEST_DEPS generate-cxx-modules generate-test-module-std)
-endif()
+list(APPEND LIBCXX_TEST_DEPS generate-cxx-modules)
if (LIBCXX_INCLUDE_BENCHMARKS)
add_subdirectory(benchmarks)
diff --git a/libcxx/cmake/caches/Generic-cxx26.cmake b/libcxx/cmake/caches/Generic-cxx26.cmake
index f48d72d493c2f51..6ba9482af57851b 100644
--- a/libcxx/cmake/caches/Generic-cxx26.cmake
+++ b/libcxx/cmake/caches/Generic-cxx26.cmake
@@ -1,3 +1,2 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_TEST_PARAMS "std=c++26" CACHE STRING "")
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
diff --git a/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake b/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake
index 0487377d4e9ba2c..72263dfd84635b5 100644
--- a/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake
+++ b/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_HARDENING_MODE "extensive" CACHE STRING "")
diff --git a/libcxx/cmake/caches/Generic-no-exceptions.cmake b/libcxx/cmake/caches/Generic-no-exceptions.cmake
index f405f7fe9937523..f0dffef60dba082 100644
--- a/libcxx/cmake/caches/Generic-no-exceptions.cmake
+++ b/libcxx/cmake/caches/Generic-no-exceptions.cmake
@@ -1,3 +1,2 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-experimental.cmake b/libcxx/cmake/caches/Generic-no-experimental.cmake
index fe14e7afed7b962..f33ed01418990bf 100644
--- a/libcxx/cmake/caches/Generic-no-experimental.cmake
+++ b/libcxx/cmake/caches/Generic-no-experimental.cmake
@@ -1,3 +1,2 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_TEST_PARAMS "enable_experimental=False" CACHE STRING "")
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
diff --git a/libcxx/cmake/caches/Generic-no-filesystem.cmake b/libcxx/cmake/caches/Generic-no-filesystem.cmake
index db62f86854d941a..4000f3a3e8ef23b 100644
--- a/libcxx/cmake/caches/Generic-no-filesystem.cmake
+++ b/libcxx/cmake/caches/Generic-no-filesystem.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-localization.cmake b/libcxx/cmake/caches/Generic-no-localization.cmake
index 54a7ec3f1f5b36c..79d6b44c7139aaf 100644
--- a/libcxx/cmake/caches/Generic-no-localization.cmake
+++ b/libcxx/cmake/caches/Generic-no-localization.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-random_device.cmake b/libcxx/cmake/caches/Generic-no-random_device.cmake
index adfa2458a8edf6d..e9b4cc60cc80eac 100644
--- a/libcxx/cmake/caches/Generic-no-random_device.cmake
+++ b/libcxx/cmake/caches/Generic-no-random_device.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-threads.cmake b/libcxx/cmake/caches/Generic-no-threads.cmake
index 2aeab22915e00cc..616baef1be7bef1 100644
--- a/libcxx/cmake/caches/Generic-no-threads.cmake
+++ b/libcxx/cmake/caches/Generic-no-threads.cmake
@@ -1,4 +1,3 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-tzdb.cmake b/libcxx/cmake/caches/Generic-no-tzdb.cmake
index c5dc882e584428c..27c826edfecffbb 100644
--- a/libcxx/cmake/caches/Generic-no-tzdb.cmake
+++ b/libcxx/cmake/caches/Generic-no-tzdb.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_TIME_ZONE_DATABASE OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-unicode.cmake b/libcxx/cmake/caches/Generic-no-unicode.cmake
index 880e2d502ad91b1..01160bf218981a2 100644
--- a/libcxx/cmake/caches/Generic-no-unicode.cmake
+++ b/libcxx/cmake/caches/Generic-no-unicode.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_UNICODE OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-wide-characters.cmake b/libcxx/cmake/caches/Generic-no-wide-characters.cmake
index 5036f6abd52e832..728d41086a38673 100644
--- a/libcxx/cmake/caches/Generic-no-wide-characters.cmake
+++ b/libcxx/cmake/caches/Generic-no-wide-characters.cmake
@@ -1,2 +1 @@
-set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
diff --git a/libcxx/docs/Modules.rst b/libcxx/docs/Modules.rst
index 146a91522436d86..a0735c0ed3f95fe 100644
--- a/libcxx/docs/Modules.rst
+++ b/libcxx/docs/Modules.rst
@@ -115,7 +115,7 @@ directory. First libc++ needs to be build with module support enabled.
$ git clone https://github.com/llvm/llvm-project.git
$ cd llvm-project
$ mkdir build
- $ cmake -G Ninja -S runtimes -B build -DLIBCXX_ENABLE_STD_MODULES=ON -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
+ $ cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
$ ninja -C build
The above ``build`` directory will be referred to as ``<build>`` in the
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 14e1e09907fad72..77cf22398ea4ca2 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -95,6 +95,10 @@ Improvements and New Features
- The ``_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE`` macro has been added to make
the function ``std::shared_ptr<...>::unique()`` available.
+- The cmake option ``LIBCXX_ENABLE_STD_MODULES`` has been removed. The test
+ infrastructure no longer depends on a modern CMake, it works with the minimal
+ required LLVM version (3.20.0).
+
Deprecations and Removals
-------------------------
diff --git a/libcxx/docs/TestingLibcxx.rst b/libcxx/docs/TestingLibcxx.rst
index e7645cb5885f14e..50ee9d4ee400b45 100644
--- a/libcxx/docs/TestingLibcxx.rst
+++ b/libcxx/docs/TestingLibcxx.rst
@@ -394,7 +394,7 @@ Custom Directives
~~~~~~~~~~~~~~~~~
Lit has many directives built in (e.g., ``DEFINE``, ``UNSUPPORTED``). In addition to those directives, libc++ adds two additional libc++-specific directives that makes
-writing tests easier. See `libc++-specific Lit Directives`_ for more information about the ``FILE_DEPENDENCIES`` and ``ADDITIONAL_COMPILE_FLAGS`` libc++-specific directives.
+writing tests easier. See `libc++-specific Lit Directives`_ for more information about the ``FILE_DEPENDENCIES``, ``ADDITIONAL_COMPILE_FLAGS``, and ``MODULE_DEPENDENCIES`` libc++-specific directives.
.. _libc++-specific Lit Directives:
.. list-table:: libc++-specific Lit Directives
@@ -417,6 +417,13 @@ writing tests easier. See `libc++-specific Lit Directives`_ for more information
- 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}``
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
`Lit Meaning of libc++ Test Filenames`_), more powerful but perhaps overkill.
+ * - ``MODULE_DEPENDENCIES``
+ - ``// MODULE_DEPENDENCIES: std std.compat``
+ - This directive will build the required C++23 standard library
+ modules and add the additional compiler flags in
+ %{compile_flags}. (Libc++ offers these modules in C++20 as an
+ extension.)
+
Benchmarks
==========
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index fae6448a7eec84b..31fbadf449f7734 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -1,8 +1,3 @@
-if (CMAKE_VERSION VERSION_LESS 3.26)
- message(WARNING "The libc++ modules won't be available because the CMake version is too old. Update to CMake 3.26 or later.")
- return()
-endif()
-
# The headers of Table 24: C++ library headers [tab:headers.cpp]
# and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
set(LIBCXX_MODULE_STD_SOURCES
@@ -142,28 +137,6 @@ set(LIBCXX_MODULE_STD_COMPAT_SOURCES
std.compat/cwctype.inc
)
-# TODO MODULES the CMakeLists.txt in the install directory is only temporary
-# When that is removed the configured file can use the substitution
-# LIBCXX_GENERATED_INCLUDE_TARGET_DIR avoiding this set.
-# Also clean up the parts needed to generate the install version.
-# - LIBCXX_GENERATED_INCLUDE_DIR contains the libc++ headers
-# - LIBCXX_GENERATED_INCLUDE_TARGET_DIR contains the libc++ site config
-if ("${LIBCXX_GENERATED_INCLUDE_DIR}" STREQUAL "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
- # This typically happens when the target is not installed.
- set(LIBCXX_CONFIGURED_INCLUDE_DIRS "${LIBCXX_GENERATED_INCLUDE_DIR}")
-else()
- # It's important that the arch directory be included first so that its header files
- # which interpose on the default include dir be included instead of the default ones.
- set(LIBCXX_CONFIGURED_INCLUDE_DIRS
- "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR};${LIBCXX_GENERATED_INCLUDE_DIR}"
- )
-endif()
-configure_file(
- "CMakeLists.txt.in"
- "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt"
- @ONLY
-)
-
set(LIBCXX_MODULE_STD_INCLUDE_SOURCES)
foreach(file ${LIBCXX_MODULE_STD_SOURCES})
set(
@@ -193,7 +166,6 @@ configure_file(
)
set(_all_modules)
-list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/CMakeLists.txt")
list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.cppm")
list(APPEND _all_modules "${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm")
foreach(file ${LIBCXX_MODULE_STD_SOURCES} ${LIBCXX_MODULE_STD_COMPAT_SOURCES})
diff --git a/libcxx/modules/CMakeLists.txt.in b/libcxx/modules/CMakeLists.txt.in
deleted file mode 100644
index 98168673ebfe9c6..000000000000000
--- a/libcxx/modules/CMakeLists.txt.in
+++ /dev/null
@@ -1,86 +0,0 @@
-cmake_minimum_required(VERSION 3.26)
-
-project(libc++-modules LANGUAGES CXX)
-
-# Enable CMake's module support
-if(CMAKE_VERSION VERSION_LESS "3.28.0")
- if(CMAKE_VERSION VERSION_LESS "3.27.0")
- set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
- else()
- set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7")
- endif()
- set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
-else()
- cmake_policy(VERSION 3.28)
-endif()
-
-# Default to C++ extensions being off. Libc++'s modules support have trouble
-# with extensions right now.
-set(CMAKE_CXX_EXTENSIONS OFF)
-
-# Propagates the CMake options to the modules.
-#
-# This uses the std module hard-coded since the std.compat module does not
-# depend on these flags.
-macro(compile_define_if_not condition def)
- if (NOT ${condition})
- target_compile_definitions(std PRIVATE ${def})
- endif()
-endmacro()
-macro(compile_define_if condition def)
- if (${condition})
- target_compile_definitions(std PRIVATE ${def})
- endif()
-endmacro()
-
-### STD
-
-add_library(std)
-target_sources(std
- PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES
- std.cppm
-)
-
-target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
-
-if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)
- target_compile_options(std PUBLIC -fno-exceptions)
-endif()
-
-target_compile_options(std
- PUBLIC
- -nostdinc++
- -Wno-reserved-module-identifier
- -Wno-reserved-user-defined-literal
- @LIBCXX_COMPILE_FLAGS@
-)
-set_target_properties(std
- PROPERTIES
- OUTPUT_NAME "c++std"
-)
-
-### STD.COMPAT
-
-add_library(std.compat)
-target_sources(std.compat
- PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES
- std.compat.cppm
-)
-
-target_include_directories(std.compat SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
-
-if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)
- target_compile_options(std.compat PUBLIC -fno-exceptions)
-endif()
-
-target_compile_options(std.compat
- PUBLIC
- -nostdinc++
- -Wno-reserved-module-identifier
- -Wno-reserved-user-defined-literal
- @LIBCXX_COMPILE_FLAGS@
-)
-set_target_properties(std.compat
- PROPERTIES
- OUTPUT_NAME "c++std.compat"
-)
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 48dd233462ab3b7..52620fc55feeb7e 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -87,31 +87,6 @@ if (LIBCXX_INCLUDE_TESTS)
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS cxx-test-depends)
- if(LIBCXX_ENABLE_STD_MODULES)
- # Generates the modules used in the test.
- # Note the test will regenerate this with the proper setting
- # - the right DCMAKE_CXX_STANDARD
- # - the right test compilation flags
- # Since modules depend on these flags there currently is no way to
- # avoid generating these for the tests. The advantage of the
- # pre generation is that less build information needs to be shared
- # in the bridge.
- add_custom_command(
- OUTPUT "${CMAKE_BINARY_DIR}/test/__config_module__/CMakeCache.txt"
- COMMAND
- ${CMAKE_COMMAND}
- "-G${CMAKE_GENERATOR}"
- "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
- "-B${CMAKE_BINARY_DIR}/test/__config_module__"
- "-H${LIBCXX_GENERATED_MODULE_DIR}"
- "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
- "-DCMAKE_CXX_STANDARD=23"
- "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
- )
- add_custom_target(generate-test-module-std
- DEPENDS "${CMAKE_BINARY_DIR}/test/__config_module__/CMakeCache.txt"
- COMMENT "Builds generic module std.")
- endif()
endif()
if (LIBCXX_GENERATE_COVERAGE)
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in
index 0e3c3040c964462..72b2ddf378bb644 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -31,10 +31,3 @@ config.substitutions.append(('%{target-include}', '@LIBCXX_GENERATED_INCLUDE_TAR
config.substitutions.append(('%{lib}', '@LIBCXX_LIBRARY_DIR@'))
config.substitutions.append(('%{module}', '@LIBCXX_GENERATED_MODULE_DIR@'))
config.substitutions.append(('%{test-tools}', '@LIBCXX_TEST_TOOLS_PATH@'))
-
-# The test needs to manually rebuild the module. The compiler flags used in the
-# test need to be the same as the compiler flags used to generate the module.
-# In the future, when CMake can generated modules this may no longer be
-# necessary.
-# TODO MODULES whether it's possible to remove this substitution.
-config.substitutions.append(('%{cmake}', '@CMAKE_COMMAND@'))
diff --git a/libcxx/test/libcxx/module_std.gen.py b/libcxx/test/libcxx/module_std.gen.py
index 8e03d6e5b5b5235..a9a05a0cd74e614 100644
--- a/libcxx/test/libcxx/module_std.gen.py
+++ b/libcxx/test/libcxx/module_std.gen.py
@@ -30,6 +30,7 @@
"%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
"%{cxx}",
"%{flags} %{compile_flags}",
+ "std",
)
diff --git a/libcxx/test/libcxx/module_std_compat.gen.py b/libcxx/test/libcxx/module_std_compat.gen.py
index c4792db3d71e624..2866066ccedc89c 100644
--- a/libcxx/test/libcxx/module_std_compat.gen.py
+++ b/libcxx/test/libcxx/module_std_compat.gen.py
@@ -30,6 +30,7 @@
"%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
"%{cxx}",
"%{flags} %{compile_flags}",
+ "std.compat",
)
diff --git a/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp b/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
new file mode 100644
index 000000000000000..74e65a9072f7b65
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure that the compile flags contain no module information.
+
+// MODULE_DEPENDENCIES:
+
+// RUN: echo "%{compile_flags}" | grep -v "std.pcm"
+// RUN: echo "%{compile_flags}" | grep -v "std.compat.pcm"
diff --git a/libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp b/libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
new file mode 100644
index 000000000000000..81241d7f43f9a13
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
+
+// picolibc does not provide the required timespec_get function, and the
+// "using-if-exists" mechanism apparently did not work here.
+// XFAIL: LIBCXX-PICOLIBC-FIXME
+
+// Make sure that the compile flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module would break this test.
+
+// MODULE_DEPENDENCIES: std std.compat
+
+// RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std=.*/std.pcm .*/std.pcm"
+// RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std.compat=.*/std.compat.pcm .*/std.compat.pcm"
diff --git a/libcxx/test/libcxx/selftest/modules/std-module.sh.cpp b/libcxx/test/libcxx/selftest/modules/std-module.sh.cpp
new file mode 100644
index 000000000000000..ec43994fa1ef970
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/modules/std-module.sh.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
+
+// Make sure that the compile flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module would break this test.
+
+// MODULE_DEPENDENCIES: std
+
+// RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std=.*/std.pcm .*/std.pcm"
+
+// The std module should not provide the std.compat module
+// RUN: echo "%{compile_flags}" | grep -v "std.compat.pcm"
diff --git a/libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp b/libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp
new file mode 100644
index 000000000000000..b74c2f1a249fcc1
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
+
+// picolibc does not provide the required timespec_get function, and the
+// "using-if-exists" mechanism apparently did not work here.
+// XFAIL: LIBCXX-PICOLIBC-FIXME
+
+// Make sure that the compile flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module would break this test.
+
+// MODULE_DEPENDENCIES: std.compat
+
+// RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std.compat=.*/std.compat.pcm .*/std.compat.pcm"
+
+// It's unspecified whether std.compat is built on the std module.
+// Therefore don't test its presence
diff --git a/libcxx/test/lit.local.cfg b/libcxx/test/lit.local.cfg
deleted file mode 100644
index 1ee9086ee22e3c5..000000000000000
--- a/libcxx/test/lit.local.cfg
+++ /dev/null
@@ -1,83 +0,0 @@
-# ===----------------------------------------------------------------------===##
-#
-# 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
-#
-# ===----------------------------------------------------------------------===##
-
-# This configuration builds the C++23 std module.
-# It is build when the current lit configuration supports modules.
-#
-# TODO MODULES Evaluate whether this file can be removed when CMake supports
-# modules in libc++.
-
-import os
-import site
-import subprocess
-import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
-
-
-def getSubstitution(substitution, config):
- for orig, replacement in config.substitutions:
- if orig == substitution:
- return replacement
- raise ValueError("Substitution {} is not in the config.".format(substitution))
-
-
-def appendToSubstitution(substitutions, key, value):
- return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]
-
-
-std = getSubstitution("%{cxx_std}", config)
-if std == "cxx26":
- std = "26"
-elif std == "cxx23":
- std = "23"
-elif std == "cxx20":
- std = "20"
-else:
- std = ""
-
-if (
- std
- and not "libcpp-has-no-std-modules" in config.available_features
- and not "clang-modules-build" in config.available_features
-):
- build = os.path.join(config.test_exec_root, "__config_module__")
- config.substitutions = appendToSubstitution(
- config.substitutions,
- "%{compile_flags}",
- "-fprebuilt-module-path="
- + os.path.join(config.test_exec_root, "__config_module__/CMakeFiles/std.dir"),
- )
-
- cmake = getSubstitution("%{cmake}", config)
- flags = getSubstitution("%{flags}", config)
- if "c++experimental" in config.available_features:
- flags = f"{flags} -D_LIBCPP_ENABLE_EXPERIMENTAL"
-
- subprocess.check_call(
- [cmake, f"-DCMAKE_CXX_STANDARD={std}", f"-DCMAKE_CXX_FLAGS={flags}", build],
- env={},
- )
- subprocess.check_call([cmake, "--build", build, "--", "-v"], env={})
- config.substitutions = appendToSubstitution(
- config.substitutions,
- "%{link_flags}",
- os.path.join(build, "libc++std.a"),
- )
-
- config.substitutions = appendToSubstitution(
- config.substitutions,
- "%{compile_flags}",
- "-fprebuilt-module-path="
- + os.path.join(
- config.test_exec_root, "__config_module__/CMakeFiles/std.compat.dir"
- ),
- )
- config.substitutions = appendToSubstitution(
- config.substitutions,
- "%{link_flags}",
- os.path.join(build, "libc++std.compat.a"),
- )
diff --git a/libcxx/test/std/modules/std.compat.pass.cpp b/libcxx/test/std/modules/std.compat.pass.cpp
index 9a2f330d722edde..40ea979e2734653 100644
--- a/libcxx/test/std/modules/std.compat.pass.cpp
+++ b/libcxx/test/std/modules/std.compat.pass.cpp
@@ -7,9 +7,10 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-
-// UNSUPPORTED: libcpp-has-no-std-modules
// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
// picolibc does not provide the required timespec_get function, and the
// "using-if-exists" mechanism apparently did not work here.
@@ -17,6 +18,8 @@
// A minimal test to validate import works.
+// MODULE_DEPENDENCIES: std.compat
+
import std.compat;
int main(int, char**) { return !(::strlen("Hello modular world") == 19); }
diff --git a/libcxx/test/std/modules/std.pass.cpp b/libcxx/test/std/modules/std.pass.cpp
index 8ec3ce27322b743..ca05825b3a18632 100644
--- a/libcxx/test/std/modules/std.pass.cpp
+++ b/libcxx/test/std/modules/std.pass.cpp
@@ -7,12 +7,15 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-
-// UNSUPPORTED: libcpp-has-no-std-modules
// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
// A minimal test to validate import works.
+// MODULE_DEPENDENCIES: std
+
import std;
int main(int, char**) {
diff --git a/libcxx/utils/ci/Dockerfile b/libcxx/utils/ci/Dockerfile
index e4bda4f06742c1c..225de937cc869a0 100644
--- a/libcxx/utils/ci/Dockerfile
+++ b/libcxx/utils/ci/Dockerfile
@@ -152,17 +152,6 @@ RUN <<EOF
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh
sudo bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license
rm /tmp/install-cmake.sh
-
- # Install a newer CMake for modules
- # TODO Remove the duplicated installation when all runtimes can be build with CMake 3.28.
- wget https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.sh -O /tmp/install-cmake.sh
- sudo bash /tmp/install-cmake.sh --prefix=/opt --exclude-subdir --skip-license
- rm /tmp/install-cmake.sh
-
- wget https://github.com/Kitware/CMake/releases/download/v3.28.0-rc4/cmake-3.28.0-rc4-linux-x86_64.sh -O /tmp/install-cmake.sh
- sudo mkdir /opt/cmake-3.28
- sudo bash /tmp/install-cmake.sh --prefix=/opt/cmake-3.28 --exclude-subdir --skip-license
- rm /tmp/install-cmake.sh
EOF
# ===----------------------------------------------------------------------===##
diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index a48f8524ef63c44..a7c44dab7093911 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -48,7 +48,6 @@ environment_definitions:
CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
CC: clang-${LLVM_HEAD_VERSION}
CXX: clang++-${LLVM_HEAD_VERSION}
- CMAKE: /opt/bin/cmake
_absolute_path_clang: &absolute_path_clang
# Note modules require and absolute path for clang-scan-deps
@@ -262,7 +261,6 @@ steps:
env:
CC: clang16
CXX: clang++16
- ENABLE_STD_MODULES: 'Off'
agents:
queue: libcxx-builders
os: freebsd
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 221b497be6d9547..ddfe53d2d8bd635 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -47,11 +47,6 @@ CLANG_FORMAT The clang-format binary to use when generating the format
ENABLE_CLANG_TIDY Whether to compile and run clang-tidy checks. This variable
is optional.
-ENABLE_STD_MODULES Whether to enable or disable building the C++23 std
- modules. This variable is optional.
- TODO MODULES remove when all supported compilers support
- modules.
-
EOF
}
@@ -120,10 +115,6 @@ if [ -z "${ENABLE_CLANG_TIDY}" ]; then
ENABLE_CLANG_TIDY=Off
fi
-if [ -n "${ENABLE_STD_MODULES}" ]; then
- ENABLE_STD_MODULES="-DLIBCXX_ENABLE_STD_MODULES=${ENABLE_STD_MODULES}"
-fi
-
function generate-cmake-base() {
echo "--- Generating CMake"
${CMAKE} \
@@ -136,7 +127,6 @@ function generate-cmake-base() {
-DLIBCXXABI_ENABLE_WERROR=YES \
-DLIBUNWIND_ENABLE_WERROR=YES \
-DLIBCXX_ENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY} \
- ${ENABLE_STD_MODULES} \
-DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
"${@}"
}
diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index 63cfa1b67781981..9a71c494030d700 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -16,6 +16,10 @@ def _getSubstitution(substitution, config):
raise ValueError("Substitution {} is not in the config.".format(substitution))
+def _appendToSubstitution(substitutions, key, value):
+ return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]
+
+
def configure(parameters, features, config, lit_config):
note = lambda s: lit_config.note("({}) {}".format(config.name, s))
config.environment = dict(os.environ)
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index e5b561d7feeb57a..c4f537f411cc275 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -317,6 +317,18 @@ def _getAndroidDeviceApi(cfg):
AddSubstitution("%{clang-tidy}", lambda cfg: _getSuitableClangTidy(cfg))
],
),
+ # Whether module support for the platform is available.
+ Feature(
+ name="has-no-cxx-module-support",
+ # The libc of these platforms have functions with internal linkage.
+ # This is not allowed per C11 7.1.2 Standard headers/6
+ # Any declaration of a library function shall have external linkage.
+ when=lambda cfg: "__ANDROID__" in compilerMacros(cfg)
+ or "_WIN32" in compilerMacros(cfg)
+ or platform.system().lower().startswith("aix")
+ # Avoid building on platforms that don't support modules properly.
+ or not hasCompileFlag(cfg, "-Wno-reserved-module-identifier"),
+ ),
]
# Deduce and add the test features that that are implied by the #defines in
@@ -343,7 +355,6 @@ def _getAndroidDeviceApi(cfg):
"_LIBCPP_HAS_NO_WIDE_CHARACTERS": "no-wide-characters",
"_LIBCPP_HAS_NO_TIME_ZONE_DATABASE": "no-tzdb",
"_LIBCPP_HAS_NO_UNICODE": "libcpp-has-no-unicode",
- "_LIBCPP_HAS_NO_STD_MODULES": "libcpp-has-no-std-modules",
"_LIBCPP_PSTL_CPU_BACKEND_LIBDISPATCH": "libcpp-pstl-cpu-backend-libdispatch",
}
for macro, feature in macros.items():
diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py
index 5d84711bf5d2821..c605e8796ac5420 100644
--- a/libcxx/utils/libcxx/test/format.py
+++ b/libcxx/utils/libcxx/test/format.py
@@ -7,6 +7,7 @@
# ===----------------------------------------------------------------------===##
import lit
+import libcxx.test.config as config
import lit.formats
import os
import re
@@ -52,6 +53,14 @@ def _executeScriptInternal(test, litConfig, commands):
return (out, err, exitCode, timeoutInfo, parsedCommands)
+def _validateModuleDependencies(modules):
+ for m in modules:
+ if m not in ("std", "std.compat"):
+ raise RuntimeError(
+ f"Invalid module dependency '{m}', only 'std' and 'std.compat' are valid"
+ )
+
+
def parseScript(test, preamble):
"""
Extract the script from a test, with substitutions applied.
@@ -91,6 +100,8 @@ def parseScript(test, preamble):
# Parse the test file, including custom directives
additionalCompileFlags = []
fileDependencies = []
+ modules = [] # The enabled modules
+ moduleCompileFlags = [] # The compilation flags to use modules
parsers = [
lit.TestRunner.IntegratedTestKeywordParser(
"FILE_DEPENDENCIES:",
@@ -102,6 +113,11 @@ def parseScript(test, preamble):
lit.TestRunner.ParserKind.SPACE_LIST,
initial_value=additionalCompileFlags,
),
+ lit.TestRunner.IntegratedTestKeywordParser(
+ "MODULE_DEPENDENCIES:",
+ lit.TestRunner.ParserKind.SPACE_LIST,
+ initial_value=modules,
+ ),
]
# Add conditional parsers for ADDITIONAL_COMPILE_FLAGS. This should be replaced by first
@@ -132,12 +148,53 @@ def parseScript(test, preamble):
script += scriptInTest
# Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
- substitutions = [
- (s, x + " " + " ".join(additionalCompileFlags))
- if s == "%{compile_flags}"
- else (s, x)
- for (s, x) in substitutions
- ]
+ # Modules need to be built with the same compilation flags as the
+ # test. So add these flags before adding the modules.
+ substitutions = config._appendToSubstitution(
+ substitutions, "%{compile_flags}", " ".join(additionalCompileFlags)
+ )
+
+ if modules:
+ _validateModuleDependencies(modules)
+
+ # The moduleCompileFlags are added to the %{compile_flags}, but
+ # the modules need to be built without these flags. So expand the
+ # %{compile_flags} eagerly and hardcode them in the build script.
+ compileFlags = config._getSubstitution("%{compile_flags}", test.config)
+
+ # Building the modules needs to happen before the other script
+ # commands are executed. Therefore the commands are added to the
+ # front of the list.
+ if "std.compat" in modules:
+ script.insert(
+ 0,
+ "%dbg(MODULE std.compat) %{cxx} %{flags} "
+ f"{compileFlags} "
+ "-Wno-reserved-module-identifier -Wno-reserved-user-defined-literal "
+ "--precompile -o %T/std.compat.pcm -c %{module}/std.compat.cppm",
+ )
+ moduleCompileFlags.extend(
+ ["-fmodule-file=std.compat=%T/std.compat.pcm", "%T/std.compat.pcm"]
+ )
+
+ # Make sure the std module is built before std.compat. Libc++'s
+ # std.compat module depends on the std module. It is not
+ # known whether the compiler expects the modules in the order of
+ # their dependencies. However it's trivial to provide them in
+ # that order.
+ script.insert(
+ 0,
+ "%dbg(MODULE std) %{cxx} %{flags} "
+ f"{compileFlags} "
+ "-Wno-reserved-module-identifier -Wno-reserved-user-defined-literal "
+ "--precompile -o %T/std.pcm -c %{module}/std.cppm",
+ )
+ moduleCompileFlags.extend(["-fmodule-file=std=%T/std.pcm", "%T/std.pcm"])
+
+ # Add compile flags required for the modules.
+ substitutions = config._appendToSubstitution(
+ substitutions, "%{compile_flags}", " ".join(moduleCompileFlags)
+ )
# Perform substitutions in the script itself.
script = lit.TestRunner.applySubstitutions(
diff --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py
index bd19fac314dd9b5..3e9fcae4c5389ae 100644
--- a/libcxx/utils/libcxx/test/modules.py
+++ b/libcxx/utils/libcxx/test/modules.py
@@ -113,12 +113,12 @@ class module_test_generator:
clang_tidy_plugin: str
compiler: str
compiler_flags: str
+ module: str
def write_lit_configuration(self):
print(
f"""\
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: libcpp-has-no-std-modules
// UNSUPPORTED: clang-modules-build
// REQUIRES: has-clang-tidy
@@ -126,6 +126,8 @@ def write_lit_configuration(self):
// The GCC compiler flags are not always compatible with clang-tidy.
// UNSUPPORTED: gcc
+// MODULE_DEPENDENCIES: {self.module}
+
// RUN: echo -n > {self.tmp_prefix}.all_partitions
"""
)
More information about the libcxx-commits
mailing list