xref: /llvm-project/clang/test/Interpreter/cxx20-modules.cppm (revision ae931b470319ade31fcc0797b6051eb8b96f9a8a)
1// REQUIRES: host-supports-jit, x86_64-linux
2// UNSUPPORTED: system-aix
3//
4// RUN: rm -rf %t
5// RUN: mkdir -p %t
6// RUN: split-file %s %t
7//
8// RUN: %clang -std=c++20 %t/mod.cppm --precompile \
9// RUN:     -o %t/mod.pcm --target=x86_64-linux-gnu
10// RUN: %clang -fPIC %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu
11// RUN: %clang -nostdlib -fPIC -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu
12//
13// RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
14// RUN:     clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \
15// RUN:     -Xcc=--target=x86_64-linux-gnu | FileCheck %t/import.cpp
16
17//--- mod.cppm
18export module M;
19export const char* Hello() {
20    return "Hello Interpreter for Modules!";
21}
22
23//--- import.cpp
24
25%lib libmod.so
26
27import M;
28
29extern "C" int printf(const char *, ...);
30printf("%s\n", Hello());
31
32// CHECK: Hello Interpreter for Modules!
33