[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)
Will Hawkins via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Dec 22 21:51:13 PST 2023
================
@@ -131,13 +138,62 @@ def parseScript(test, preamble):
script += preamble
script += scriptInTest
+ has_std_module = False
+ has_std_compat_module = False
+ for module in modules:
+ if module == "std":
+ has_std_module = True
+ elif module == "std.compat":
+ has_std_compat_module = True
+ else:
+ script.insert(0, f"echo \"The module '{module}' is not valid, use 'std' or 'std.compat'\"")
+ script.insert(1, "false");
+ return script
+
+ if modules:
+ # This flag is needed for both modules.
+ moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+ # 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 has_std_compat_module:
+ script.insert(
+ 0,
+ "%dbg(MODULE std.compat) %{cxx} %{flags} %{compile_flags} "
+ "-Wno-reserved-module-identifier -Wno-reserved-user-defined-literal "
+ "--precompile -o %T/std.compat.pcm -c %{module}/std.compat.cppm",
+ )
+ moduleCompileFlags.append("%T/std.compat.pcm")
+
+ # Make sure the std module is added before std.compat.
+ # Libc++'s std.compat module will depend on its 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.
+ if has_std_module:
+ script.insert(
+ 0,
+ "%dbg(MODULE std) %{cxx} %{flags} %{compile_flags} "
+ "-Wno-reserved-module-identifier -Wno-reserved-user-defined-literal "
+ "--precompile -o %T/std.pcm -c %{module}/std.cppm",
+ )
+ moduleCompileFlags.append("%T/std.pcm")
+
# 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
]
+ # In order to use modules additional compilation flags are required.
----------------
hawkinsw wrote:
```suggestion
# In order to use modules, additional compilation flags are required.
```
https://github.com/llvm/llvm-project/pull/76246
More information about the llvm-branch-commits
mailing list