[libcxx-commits] [libcxx] [libc++] Enable additional tests when Clang modules are enabled (PR #168967)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 3 09:12:03 PST 2026


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/168967

>From 4afe2b1b685ca89c80a34102a286d09ab61fd21e Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 20 Nov 2025 18:16:44 -0500
Subject: [PATCH 1/5] [libc++] Enable additional tests when Clang modules are
 enabled

Disabling tests when Clang modules are enabled is not great because
we are moving more and more tests towards using Clang modules by
default. Instead, disable Clang modules on a per-test basis.
---
 .../extensions/libcxx/depr/depr.c.headers/extern_c.pass.cpp | 2 +-
 .../libcxx/depr/depr.c.headers/include_as_c.sh.cpp          | 2 +-
 .../depr.c.headers/stdint_h.xopen_source.compile.pass.cpp   | 2 +-
 libcxx/test/extensions/posix/xopen_source.gen.py            | 2 +-
 .../customize_verbose_abort.compile-time.pass.cpp           | 2 +-
 .../assertions/modes/hardening_mode_incorrect_value.sh.cpp  | 5 +++--
 libcxx/test/libcxx-03/transitive_includes.gen.py            | 2 +-
 .../pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp     | 2 +-
 .../alg.modifying.operations/copy_move_nontrivial.pass.cpp  | 6 ++++--
 .../alg.modifying.operations/copy_move_trivial.pass.cpp     | 6 ++++--
 .../customize_verbose_abort.compile-time.pass.cpp           | 2 +-
 .../assertions/modes/hardening_mode_incorrect_value.sh.cpp  | 5 +++--
 .../semantics/assertion_semantic_incorrect_value.sh.cpp     | 5 +++--
 .../unexpected_disabled_cpp17.verify.cpp                    | 2 +-
 .../language.support/timespec_get.xopen.compile.pass.cpp    | 2 +-
 libcxx/test/libcxx/transitive_includes.gen.py               | 2 +-
 .../pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp     | 2 +-
 .../test/selftest/modules/std-and-std.compat-module.sh.cpp  | 4 +++-
 libcxx/test/selftest/modules/std-module.sh.cpp              | 4 +++-
 libcxx/test/selftest/modules/std.compat-module.sh.cpp       | 4 +++-
 libcxx/test/std/modules/std.compat.pass.cpp                 | 4 +++-
 libcxx/test/std/modules/std.pass.cpp                        | 4 +++-
 libcxx/utils/libcxx/test/modules.py                         | 4 +++-
 23 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/libcxx/test/extensions/libcxx/depr/depr.c.headers/extern_c.pass.cpp b/libcxx/test/extensions/libcxx/depr/depr.c.headers/extern_c.pass.cpp
index 33b55c4bb195a..b7bdd841ea3e0 100644
--- a/libcxx/test/extensions/libcxx/depr/depr.c.headers/extern_c.pass.cpp
+++ b/libcxx/test/extensions/libcxx/depr/depr.c.headers/extern_c.pass.cpp
@@ -8,7 +8,7 @@
 
 // When building with modules, including headers inside extern "C" is an anti-pattern
 // that we don't want to support and can't support with LSV enabled.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // Sometimes C++'s <foo.h> headers get included within extern "C" contexts. This
 // is ill-formed (no diagnostic required), per [using.headers]p3, but we permit
diff --git a/libcxx/test/extensions/libcxx/depr/depr.c.headers/include_as_c.sh.cpp b/libcxx/test/extensions/libcxx/depr/depr.c.headers/include_as_c.sh.cpp
index 635c7e3aa4f5f..dd9847f63253b 100644
--- a/libcxx/test/extensions/libcxx/depr/depr.c.headers/include_as_c.sh.cpp
+++ b/libcxx/test/extensions/libcxx/depr/depr.c.headers/include_as_c.sh.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // We're building as C, so this test doesn't work when building with modules.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // GCC complains about unrecognized arguments because we're compiling the
 // file as C, but we're passing C++ flags on the command-line.
diff --git a/libcxx/test/extensions/libcxx/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp b/libcxx/test/extensions/libcxx/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp
index 75a4ab908ce21..f665ec5a1b5db 100644
--- a/libcxx/test/extensions/libcxx/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp
+++ b/libcxx/test/extensions/libcxx/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // This test breaks when enabling LSV.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // Test that limits macros are available when <stdint.h> is included
 // with or without macro _XOPEN_SOURCE=700.
diff --git a/libcxx/test/extensions/posix/xopen_source.gen.py b/libcxx/test/extensions/posix/xopen_source.gen.py
index ec0d981d67b2b..bea11e2c04ceb 100644
--- a/libcxx/test/extensions/posix/xopen_source.gen.py
+++ b/libcxx/test/extensions/posix/xopen_source.gen.py
@@ -15,7 +15,7 @@
 # Some parts of the code like <fstream> use non-standard functions in their implementation,
 # and these functions are not provided when _XOPEN_SOURCE is set to older values. This
 # breaks when building with modules even when we don't use the offending headers directly.
-# UNSUPPORTED: clang-modules-build
+# ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 # The AIX localization support uses some functions as part of their headers that require a
 # recent value of _XOPEN_SOURCE.
diff --git a/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp
index 69154c3f7eaff..bb44bc68eb1ce 100644
--- a/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp
+++ b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // This compile-time customization requires cross-file macros, which doesn't work with modules.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // Make sure that we can customize the verbose termination function at compile-time by
 // defining _LIBCPP_VERBOSE_ABORT ourselves. Note that this does not have any
diff --git a/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp b/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp
index 751ff7247445f..4f0abd8ab9d07 100644
--- a/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp
+++ b/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp
@@ -9,10 +9,11 @@
 // This test verifies that setting the hardening mode to a value that's not part of the predefined constants triggers
 // a compile-time error.
 
-// Modules build produces a different error ("Could not build module 'std'").
-// UNSUPPORTED: clang-modules-build
 // REQUIRES: verify-support
 
+// TODO: Investigate
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // Note that GCC doesn't support `-Wno-macro-redefined`.
 // RUN: %{verify} -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=42
 // Make sure that common cases of misuse produce readable errors. We deliberately disallow setting the hardening mode as
diff --git a/libcxx/test/libcxx-03/transitive_includes.gen.py b/libcxx/test/libcxx-03/transitive_includes.gen.py
index 6f99240436632..3ab9986bdb94c 100644
--- a/libcxx/test/libcxx-03/transitive_includes.gen.py
+++ b/libcxx/test/libcxx-03/transitive_includes.gen.py
@@ -77,7 +77,7 @@
 
 // When built with modules, this test doesn't work because --trace-includes doesn't
 // report the stack of includes correctly.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // This test uses --trace-includes, which is not supported by GCC.
 // UNSUPPORTED: gcc
diff --git a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
index 1f5dae1232e37..65ae7de663162 100644
--- a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
@@ -8,7 +8,7 @@
 
 // The test suite needs to define the ABI macros on the command line when
 // modules are enabled.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // <utility>
 
diff --git a/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp b/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp
index 162a3539d2308..f0da45d9bd281 100644
--- a/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp
@@ -7,11 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// In the modules build, adding another overload of `memmove` doesn't work.
-// UNSUPPORTED: clang-modules-build
+
 // GCC complains about "ambiguating" `__builtin_memmove`.
 // UNSUPPORTED: gcc
 
+// In the modules build, adding another overload of `memmove` doesn't work.
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // <algorithm>
 
 #include <cassert>
diff --git a/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp b/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp
index ff10c7919200d..e009438acb005 100644
--- a/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp
@@ -7,11 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// In the modules build, adding another overload of `memmove` doesn't work.
-// UNSUPPORTED: clang-modules-build
+
 // GCC complains about "ambiguating" `__builtin_memmove`.
 // UNSUPPORTED: gcc
 
+// In the modules build, adding another overload of `memmove` doesn't work.
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // <algorithm>
 
 // These tests check that `std::copy` and `std::move` (including their variations like `copy_n`) forward to
diff --git a/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp b/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
index 69154c3f7eaff..bb44bc68eb1ce 100644
--- a/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
+++ b/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // This compile-time customization requires cross-file macros, which doesn't work with modules.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // Make sure that we can customize the verbose termination function at compile-time by
 // defining _LIBCPP_VERBOSE_ABORT ourselves. Note that this does not have any
diff --git a/libcxx/test/libcxx/assertions/modes/hardening_mode_incorrect_value.sh.cpp b/libcxx/test/libcxx/assertions/modes/hardening_mode_incorrect_value.sh.cpp
index 751ff7247445f..4f0abd8ab9d07 100644
--- a/libcxx/test/libcxx/assertions/modes/hardening_mode_incorrect_value.sh.cpp
+++ b/libcxx/test/libcxx/assertions/modes/hardening_mode_incorrect_value.sh.cpp
@@ -9,10 +9,11 @@
 // This test verifies that setting the hardening mode to a value that's not part of the predefined constants triggers
 // a compile-time error.
 
-// Modules build produces a different error ("Could not build module 'std'").
-// UNSUPPORTED: clang-modules-build
 // REQUIRES: verify-support
 
+// TODO: Investigate
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // Note that GCC doesn't support `-Wno-macro-redefined`.
 // RUN: %{verify} -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=42
 // Make sure that common cases of misuse produce readable errors. We deliberately disallow setting the hardening mode as
diff --git a/libcxx/test/libcxx/assertions/semantics/assertion_semantic_incorrect_value.sh.cpp b/libcxx/test/libcxx/assertions/semantics/assertion_semantic_incorrect_value.sh.cpp
index d7c1e26491ba9..67a0ed5aaa408 100644
--- a/libcxx/test/libcxx/assertions/semantics/assertion_semantic_incorrect_value.sh.cpp
+++ b/libcxx/test/libcxx/assertions/semantics/assertion_semantic_incorrect_value.sh.cpp
@@ -9,11 +9,12 @@
 // This test verifies that setting the assertion semantic to a value that's not part of the predefined constants
 // triggers a compile-time error.
 
-// Modules build produces a different error ("Could not build module 'std'").
-// UNSUPPORTED: clang-modules-build
 // UNSUPPORTED: c++03, libcpp-has-no-experimental-hardening-observe-semantic
 // REQUIRES: verify-support
 
+// TODO: Investigate
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // RUN: %{verify} -U_LIBCPP_ASSERTION_SEMANTIC -D_LIBCPP_ASSERTION_SEMANTIC=42
 // `hardening-dependent` cannot be set as the semantic (it's only an indicator to use hardening-related logic to pick
 // the final semantic).
diff --git a/libcxx/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.verify.cpp b/libcxx/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.verify.cpp
index b92f2baa02e47..10939ab91c69b 100644
--- a/libcxx/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.verify.cpp
+++ b/libcxx/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.verify.cpp
@@ -11,7 +11,7 @@
 // When built with modules, this test gives diagnostics like declaration of
 // 'unexpected' must be imported from module 'std.expected.unexpected' before
 // it is required. Therefore disable it in this configuration.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // test unexpected
 
diff --git a/libcxx/test/libcxx/language.support/timespec_get.xopen.compile.pass.cpp b/libcxx/test/libcxx/language.support/timespec_get.xopen.compile.pass.cpp
index 134978d099ecf..7eafb77c2de9c 100644
--- a/libcxx/test/libcxx/language.support/timespec_get.xopen.compile.pass.cpp
+++ b/libcxx/test/libcxx/language.support/timespec_get.xopen.compile.pass.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // This test breaks when enabling LSV.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // UNSUPPORTED: c++03, c++11, c++14
 
diff --git a/libcxx/test/libcxx/transitive_includes.gen.py b/libcxx/test/libcxx/transitive_includes.gen.py
index 2b643e1f2ad48..8995482778d43 100644
--- a/libcxx/test/libcxx/transitive_includes.gen.py
+++ b/libcxx/test/libcxx/transitive_includes.gen.py
@@ -75,7 +75,7 @@
 
 // When built with modules, this test doesn't work because --trace-includes doesn't
 // report the stack of includes correctly.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // This test uses --trace-includes, which is not supported by GCC.
 // UNSUPPORTED: gcc
diff --git a/libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp b/libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
index 1f5dae1232e37..65ae7de663162 100644
--- a/libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
+++ b/libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
@@ -8,7 +8,7 @@
 
 // The test suite needs to define the ABI macros on the command line when
 // modules are enabled.
-// UNSUPPORTED: clang-modules-build
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
 // <utility>
 
diff --git a/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp b/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp
index 455674d6b9949..f61e8493c61cf 100644
--- a/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp
+++ b/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// UNSUPPORTED: clang-modules-build
 // UNSUPPORTED: gcc
 
 // TODO: This test is currently written in a way that is specific to libc++, but it's really trying to test a property
@@ -20,6 +19,9 @@
 // The tests only look for the expected components and not the exact flags.
 // Otherwise changing the location of the module would break this test.
 
+// C++20 modules are incompatible with Clang modules
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // MODULE_DEPENDENCIES: std std.compat
 
 // RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std=.*/std.pcm .*/std.pcm"
diff --git a/libcxx/test/selftest/modules/std-module.sh.cpp b/libcxx/test/selftest/modules/std-module.sh.cpp
index e96c1e64b7275..ea9dbd5808937 100644
--- a/libcxx/test/selftest/modules/std-module.sh.cpp
+++ b/libcxx/test/selftest/modules/std-module.sh.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// UNSUPPORTED: clang-modules-build
 // UNSUPPORTED: gcc
 
 // TODO: This test is currently written in a way that is specific to libc++, but it's really trying to test a property
@@ -20,6 +19,9 @@
 // The tests only look for the expected components and not the exact flags.
 // Otherwise changing the location of the module would break this test.
 
+// C++20 modules are incompatible with Clang modules
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // MODULE_DEPENDENCIES: std
 
 // RUN: echo "%{compile_flags}" | grep -- "-fmodule-file=std=.*/std.pcm .*/std.pcm"
diff --git a/libcxx/test/selftest/modules/std.compat-module.sh.cpp b/libcxx/test/selftest/modules/std.compat-module.sh.cpp
index 4ec0ad8323d8d..8bce59b99279b 100644
--- a/libcxx/test/selftest/modules/std.compat-module.sh.cpp
+++ b/libcxx/test/selftest/modules/std.compat-module.sh.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// UNSUPPORTED: clang-modules-build
 // UNSUPPORTED: gcc
 
 // TODO: This test is currently written in a way that is specific to libc++, but it's really trying to test a property
@@ -16,6 +15,9 @@
 
 // XFAIL: has-no-cxx-module-support
 
+// C++20 modules are incompatible with Clang modules
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // 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.
diff --git a/libcxx/test/std/modules/std.compat.pass.cpp b/libcxx/test/std/modules/std.compat.pass.cpp
index e840f3c6b629c..0d1a4ac7d89c4 100644
--- a/libcxx/test/std/modules/std.compat.pass.cpp
+++ b/libcxx/test/std/modules/std.compat.pass.cpp
@@ -7,13 +7,15 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: clang-modules-build
 // UNSUPPORTED: gcc
 
 // XFAIL: has-no-cxx-module-support
 
 // A minimal test to validate import works.
 
+// C++20 modules are incompatible with Clang modules
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // MODULE_DEPENDENCIES: std.compat
 
 import std.compat;
diff --git a/libcxx/test/std/modules/std.pass.cpp b/libcxx/test/std/modules/std.pass.cpp
index ca05825b3a186..4587dcb1b8178 100644
--- a/libcxx/test/std/modules/std.pass.cpp
+++ b/libcxx/test/std/modules/std.pass.cpp
@@ -7,13 +7,15 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// UNSUPPORTED: clang-modules-build
 // UNSUPPORTED: gcc
 
 // XFAIL: has-no-cxx-module-support
 
 // A minimal test to validate import works.
 
+// C++20 modules are incompatible with Clang modules
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // MODULE_DEPENDENCIES: std
 
 import std;
diff --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py
index bd4fbe78c1cdc..f70d976705d60 100644
--- a/libcxx/utils/libcxx/test/modules.py
+++ b/libcxx/utils/libcxx/test/modules.py
@@ -118,13 +118,15 @@ def write_lit_configuration(self):
         print(
             f"""\
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: clang-modules-build
 
 // REQUIRES: has-clang-tidy
 
 // The GCC compiler flags are not always compatible with clang-tidy.
 // UNSUPPORTED: gcc
 
+// C++20 modules are incompatible with Clang modules
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 // MODULE_DEPENDENCIES: {self.module}
 
 // RUN: echo -n > {self.tmp_prefix}.all_partitions

>From 4c9bde202f20141f97e799b83f6ea793ff1318fa Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 27 Jan 2026 14:28:35 -0500
Subject: [PATCH 2/5] Try to take into account ADDITIONAL_COMPILE_FLAGS in
 modules tests

---
 libcxx/utils/libcxx/test/config.py | 6 +++---
 libcxx/utils/libcxx/test/dsl.py    | 4 ++--
 libcxx/utils/libcxx/test/format.py | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index 00fab6a73ba68..c1bba1167d9a3 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -9,8 +9,8 @@
 import os
 
 
-def _getSubstitution(substitution, config):
-    for (orig, replacement) in config.substitutions:
+def _getSubstitution(substitution, all_substitutions):
+    for (orig, replacement) in all_substitutions:
         if orig == substitution:
             return replacement
     raise ValueError("Substitution {} is not in the config.".format(substitution))
@@ -52,7 +52,7 @@ def configure(parameters, features, config, lit_config):
 
     # Print the basic substitutions
     for sub in ("%{cxx}", "%{flags}", "%{compile_flags}", "%{link_flags}", "%{benchmark_flags}", "%{exec}"):
-        note("Using {} substitution: '{}'".format(sub, _getSubstitution(sub, config)))
+        note("Using {} substitution: '{}'".format(sub, _getSubstitution(sub, config.substitutions)))
 
     # Print all available features
     note("All available features: {}".format(", ".join(sorted(config.available_features))))
diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index 88fc49160c56b..710b1b69d21da 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -365,8 +365,8 @@ def featureTestMacros(config, flags=""):
     }
 
 
-def _getSubstitution(substitution, config):
-  for (orig, replacement) in config.substitutions:
+def _getSubstitution(substitution, all_substitutions):
+  for (orig, replacement) in all_substitutions:
     if orig == substitution:
       return replacement
   raise ValueError('Substitution {} is not in the config.'.format(substitution))
diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py
index 76e9115295b99..a0c8b6e31cebe 100644
--- a/libcxx/utils/libcxx/test/format.py
+++ b/libcxx/utils/libcxx/test/format.py
@@ -167,7 +167,7 @@ def parseScript(test, preamble):
         # 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)
+        compileFlags = config._getSubstitution("%{compile_flags}", substitutions)
 
         # Building the modules needs to happen before the other script
         # commands are executed. Therefore the commands are added to the

>From d5e3acc1c6117861584f1cc80d57ac350877b850 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 28 Jan 2026 13:24:19 -0500
Subject: [PATCH 3/5] XFAIL carve-outs

---
 libcxx/utils/libcxx/test/modules.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py
index 53c91958c37e5..4076379c41276 100644
--- a/libcxx/utils/libcxx/test/modules.py
+++ b/libcxx/utils/libcxx/test/modules.py
@@ -119,6 +119,10 @@ def write_lit_configuration(self):
             f"""\
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
+// These tests check that we provide all declarations, so they currently don't work when
+// carve-outs are enabled.
+// XFAIL: no-filesystem, no-tzdb, no-localization, no-threads, no-wide-characters
+
 // REQUIRES: has-clang-tidy
 
 // The GCC compiler flags are not always compatible with clang-tidy.

>From e1b24d0ed26f44b25c9195ce9bf5907e0c64deb5 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 3 Feb 2026 11:43:10 -0500
Subject: [PATCH 4/5] Properly disable modules in xopen_source test

---
 libcxx/test/extensions/posix/xopen_source.gen.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libcxx/test/extensions/posix/xopen_source.gen.py b/libcxx/test/extensions/posix/xopen_source.gen.py
index bea11e2c04ceb..e98197c8ed21c 100644
--- a/libcxx/test/extensions/posix/xopen_source.gen.py
+++ b/libcxx/test/extensions/posix/xopen_source.gen.py
@@ -12,11 +12,6 @@
 #
 # https://llvm.org/PR117630
 
-# Some parts of the code like <fstream> use non-standard functions in their implementation,
-# and these functions are not provided when _XOPEN_SOURCE is set to older values. This
-# breaks when building with modules even when we don't use the offending headers directly.
-# ADDITIONAL_COMPILE_FLAGS: -fno-modules
-
 # The AIX localization support uses some functions as part of their headers that require a
 # recent value of _XOPEN_SOURCE.
 # UNSUPPORTED: LIBCXX-AIX-FIXME
@@ -50,6 +45,11 @@
 
 // ADDITIONAL_COMPILE_FLAGS: -D_XOPEN_SOURCE={version}
 
+// Some parts of the code like <fstream> use non-standard functions in their implementation,
+// and these functions are not provided when _XOPEN_SOURCE is set to older values. This
+// breaks when building with modules even when we don't use the offending headers directly.
+// ADDITIONAL_COMPILE_FLAGS: -fno-modules
+
 #include <{header}>
 """
         )

>From 538bbfb14c8324be3fd98c46388a388079221704 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 3 Feb 2026 12:11:45 -0500
Subject: [PATCH 5/5] XFAIL tests with Apple Clang 17

---
 .../selftest/modules/std-and-std.compat-module.sh.cpp    | 9 ++++++---
 libcxx/test/selftest/modules/std-module.sh.cpp           | 9 ++++++---
 libcxx/test/selftest/modules/std.compat-module.sh.cpp    | 3 +++
 libcxx/test/std/modules/std.compat.pass.cpp              | 3 +++
 libcxx/test/std/modules/std.pass.cpp                     | 3 +++
 5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp b/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp
index f61e8493c61cf..32e4c06f750c5 100644
--- a/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp
+++ b/libcxx/test/selftest/modules/std-and-std.compat-module.sh.cpp
@@ -15,13 +15,16 @@
 
 // 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.
+// Apple Clang 17 advertises C++ Modules support but fails to compile this test.
+// XFAIL: apple-clang-17
 
 // C++20 modules are incompatible with Clang modules
 // ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
+// 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"
diff --git a/libcxx/test/selftest/modules/std-module.sh.cpp b/libcxx/test/selftest/modules/std-module.sh.cpp
index ea9dbd5808937..8304d5f429190 100644
--- a/libcxx/test/selftest/modules/std-module.sh.cpp
+++ b/libcxx/test/selftest/modules/std-module.sh.cpp
@@ -15,13 +15,16 @@
 
 // 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.
+// Apple Clang 17 advertises C++ Modules support but fails to compile this test.
+// XFAIL: apple-clang-17
 
 // C++20 modules are incompatible with Clang modules
 // ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
+// 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"
diff --git a/libcxx/test/selftest/modules/std.compat-module.sh.cpp b/libcxx/test/selftest/modules/std.compat-module.sh.cpp
index 8bce59b99279b..cdfd1a187fbff 100644
--- a/libcxx/test/selftest/modules/std.compat-module.sh.cpp
+++ b/libcxx/test/selftest/modules/std.compat-module.sh.cpp
@@ -15,6 +15,9 @@
 
 // XFAIL: has-no-cxx-module-support
 
+// Apple Clang 17 advertises C++ Modules support but fails to compile this test.
+// XFAIL: apple-clang-17
+
 // C++20 modules are incompatible with Clang modules
 // ADDITIONAL_COMPILE_FLAGS: -fno-modules
 
diff --git a/libcxx/test/std/modules/std.compat.pass.cpp b/libcxx/test/std/modules/std.compat.pass.cpp
index 0d1a4ac7d89c4..a99f34b4ed19f 100644
--- a/libcxx/test/std/modules/std.compat.pass.cpp
+++ b/libcxx/test/std/modules/std.compat.pass.cpp
@@ -11,6 +11,9 @@
 
 // XFAIL: has-no-cxx-module-support
 
+// Apple Clang 17 advertises C++ Modules support but fails to compile this test.
+// XFAIL: apple-clang-17
+
 // A minimal test to validate import works.
 
 // C++20 modules are incompatible with Clang modules
diff --git a/libcxx/test/std/modules/std.pass.cpp b/libcxx/test/std/modules/std.pass.cpp
index 4587dcb1b8178..325a2fdebe1bc 100644
--- a/libcxx/test/std/modules/std.pass.cpp
+++ b/libcxx/test/std/modules/std.pass.cpp
@@ -11,6 +11,9 @@
 
 // XFAIL: has-no-cxx-module-support
 
+// Apple Clang 17 advertises C++ Modules support but fails to compile this test.
+// XFAIL: apple-clang-17
+
 // A minimal test to validate import works.
 
 // C++20 modules are incompatible with Clang modules



More information about the libcxx-commits mailing list