
This commit adds the %lib <file> command to load a dynamic library to be used by the currently running interpreted code. For example `%lib libSDL2.so`. Differential Revision: https://reviews.llvm.org/D141824
20 lines
503 B
C++
20 lines
503 B
C++
// REQUIRES: host-supports-jit, system-linux
|
|
|
|
// RUN: %clang -xc++ -o %T/libdynamic-library-test.so -fPIC -shared -DLIBRARY %S/Inputs/dynamic-library-test.cpp
|
|
// RUN: cat %s | env LD_LIBRARY_PATH=%T:$LD_LIBRARY_PATH clang-repl | FileCheck %s
|
|
|
|
#include <cstdio>
|
|
|
|
extern int ultimate_answer;
|
|
int calculate_answer();
|
|
|
|
%lib libdynamic-library-test.so
|
|
|
|
printf("Return value: %d\n", calculate_answer());
|
|
// CHECK: Return value: 5
|
|
|
|
printf("Variable: %d\n", ultimate_answer);
|
|
// CHECK-NEXT: Variable: 42
|
|
|
|
%quit
|