[libcxx-commits] [libcxx] [libc++] Properly detect whether C++20 modules are supported by the compiler (PR #94275)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 3 12:42:34 PDT 2024


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/94275

It is possible for a compiler to support the warning without being able to compile `export module foo;`, so use that in addition to the warning to check whether C++20 modules are supported.

>From dc4e4b37b80484f69719a8d416fddec1a1b01157 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 3 Jun 2024 15:40:12 -0400
Subject: [PATCH] [libc++] Properly detect whether C++20 modules are supported
 by the compiler

It is possible for a compiler to support the warning without being able
to compile `export module foo;`, so use that in addition to the warning
to check whether C++20 modules are supported.
---
 libcxx/utils/libcxx/test/features.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 093cd39ea64c6..6fe5595b0d405 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -317,7 +317,13 @@ def _mingwSupportsModules(cfg):
         or ("_WIN32" in compilerMacros(cfg) and not _mingwSupportsModules(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"),
+        or not hasCompileFlag(cfg, "-Wno-reserved-module-identifier")
+        or not sourceBuilds(
+            cfg,
+            """
+            export module test;
+          """,
+        )
     ),
     # The time zone validation tests compare the output of zdump against the
     # output generated by <chrono>'s time zone support.



More information about the libcxx-commits mailing list