Chuanqi Xu | c125965 | 2024-01-24 16:10:47 +0800 | [diff] [blame] | 1 | // REQUIRES: host-supports-jit, x86_64-linux |
Chuanqi Xu | dd3e6c8 | 2024-01-24 15:45:05 +0800 | [diff] [blame] | 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 \ |
Chuanqi Xu | d71831a | 2024-01-31 16:05:13 +0800 | [diff] [blame] | 9 | // RUN: -o %t/mod.pcm --target=x86_64-linux-gnu |
Jinsong Ji | b929be2 | 2024-01-31 11:51:15 -0500 | [diff] [blame] | 10 | // RUN: %clang -fPIC %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu |
Wei Wang | ae931b4 | 2024-02-01 00:29:59 -0800 | [diff] [blame] | 11 | // RUN: %clang -nostdlib -fPIC -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu |
Chuanqi Xu | dd3e6c8 | 2024-01-24 15:45:05 +0800 | [diff] [blame] | 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 \ |
Chuanqi Xu | d71831a | 2024-01-31 16:05:13 +0800 | [diff] [blame] | 15 | // RUN: -Xcc=--target=x86_64-linux-gnu | FileCheck %t/import.cpp |
Chuanqi Xu | dd3e6c8 | 2024-01-24 15:45:05 +0800 | [diff] [blame] | 16 | |
| 17 | //--- mod.cppm |
| 18 | export module M; |
| 19 | export const char* Hello() { |
| 20 | return "Hello Interpreter for Modules!"; |
| 21 | } |
| 22 | |
| 23 | //--- import.cpp |
| 24 | |
| 25 | %lib libmod.so |
| 26 | |
| 27 | import M; |
| 28 | |
| 29 | extern "C" int printf(const char *, ...); |
| 30 | printf("%s\n", Hello()); |
| 31 | |
| 32 | // CHECK: Hello Interpreter for Modules! |