[clang] Support C++20 Modules in clang-repl (PR #79261)

Nathan Chancellor via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 20:01:49 PST 2024


================
@@ -0,0 +1,31 @@
+// UNSUPPORTED: system-aix
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/mod.cppm --precompile \
+// RUN:     -o %t/mod.pcm
+// RUN: %clang %t/mod.pcm -c -o %t/mod.o
+// RUN: %clang -shared %t/mod.o -o %t/libmod.so
+//
+// RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
+// RUN:     clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \
+// RUN:     | FileCheck %t/import.cpp
----------------
nathanchance wrote:

```diff
diff --git a/clang/test/Interpreter/cxx20-modules.cppm b/clang/test/Interpreter/cxx20-modules.cppm
index 2c6eba525519..cd2b04fdc547 100644
--- a/clang/test/Interpreter/cxx20-modules.cppm
+++ b/clang/test/Interpreter/cxx20-modules.cppm
@@ -6,13 +6,13 @@
 // RUN: split-file %s %t
 //
 // RUN: %clang -std=c++20 %t/mod.cppm --precompile \
-// RUN:     -o %t/mod.pcm
-// RUN: %clang %t/mod.pcm -c -o %t/mod.o
-// RUN: %clang -shared %t/mod.o -o %t/libmod.so
+// RUN:     -o %t/mod.pcm --target=x86_64-linux-gnu
+// RUN: %clang %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu
+// RUN: %clang -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu
 //
 // RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
 // RUN:     clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \
-// RUN:     | FileCheck %t/import.cpp
+// RUN:     -Xcc=--target=x86_64-linux-gnu | FileCheck %t/import.cpp
 
 //--- mod.cppm
 export module M;
```

appears to work for me.

https://github.com/llvm/llvm-project/pull/79261


More information about the cfe-commits mailing list