blob: 4e56e2fc1528acf7e1cc19ba82631b6faf22cc59 [file] [log] [blame]
Chuanqi Xuc1259652024-01-24 16:10:47 +08001// REQUIRES: host-supports-jit, x86_64-linux
Chuanqi Xudd3e6c82024-01-24 15:45:05 +08002// 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 \
Chuanqi Xud71831a2024-01-31 16:05:13 +08009// RUN: -o %t/mod.pcm --target=x86_64-linux-gnu
Jinsong Jib929be22024-01-31 11:51:15 -050010// RUN: %clang -fPIC %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu
Wei Wangae931b42024-02-01 00:29:59 -080011// RUN: %clang -nostdlib -fPIC -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu
Chuanqi Xudd3e6c82024-01-24 15:45:05 +080012//
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 \
Chuanqi Xud71831a2024-01-31 16:05:13 +080015// RUN: -Xcc=--target=x86_64-linux-gnu | FileCheck %t/import.cpp
Chuanqi Xudd3e6c82024-01-24 15:45:05 +080016
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!