[PATCH] D148992: [clang-repl] Fix dynamic library test to avoid cstdio and linker
Anubhab Ghosh via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 22 07:01:47 PDT 2023
argentite created this revision.
Herald added a project: All.
argentite added reviewers: bcain, zhuhan0, sgraenitz, v.g.vassilev.
argentite published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Some platforms do not have a working linker present. The goal is to
only test the loading of a shared library in clang-repl. A precompiled
library is used instead.
The cstdio header may also not be present. We only need printf.
Related discussion in D141824 <https://reviews.llvm.org/D141824>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148992
Files:
clang/test/Interpreter/Inputs/dynamic-library-test.cpp
clang/test/Interpreter/Inputs/libdynamic-library-test.so
clang/test/Interpreter/dynamic-library.cpp
Index: clang/test/Interpreter/dynamic-library.cpp
===================================================================
--- clang/test/Interpreter/dynamic-library.cpp
+++ clang/test/Interpreter/dynamic-library.cpp
@@ -1,10 +1,19 @@
// REQUIRES: host-supports-jit, system-linux
// UNSUPPORTED: target={{.*-(ps4|ps5)}}
-// 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
+// To generate libdynamic-library-test.so :
+// clang -xc++ -o libdynamic-library-test.so -fPIC -shared
+//
+// int ultimate_answer = 0;
+//
+// int calculate_answer() {
+// ultimate_answer = 42;
+// return 5;
+// }
-#include <cstdio>
+// RUN: cat %s | env LD_LIBRARY_PATH=%S/Inputs:$LD_LIBRARY_PATH clang-repl | FileCheck %s
+
+extern "C" int printf(const char* format, ...);
extern int ultimate_answer;
int calculate_answer();
Index: clang/test/Interpreter/Inputs/dynamic-library-test.cpp
===================================================================
--- clang/test/Interpreter/Inputs/dynamic-library-test.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-int ultimate_answer = 0;
-
-int calculate_answer() {
- ultimate_answer = 42;
- return 5;
-}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148992.516067.patch
Type: text/x-patch
Size: 1272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230422/63666745/attachment.bin>
More information about the cfe-commits
mailing list