[PATCH] D141824: [clang-repl] Add a command to load dynamic libraries

Anubhab Ghosh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 28 05:42:08 PDT 2023


argentite added inline comments.


================
Comment at: clang/test/Interpreter/dynamic-library.cpp:1
+// RUN: head -n 7 %s | %clang -xc++ -o %T/libdynamic-library-test.so -fPIC -shared -
+int ultimate_answer = 0;
----------------
v.g.vassilev wrote:
> sgraenitz wrote:
> > The use of `head` and `tail` here is a creative solution, but I wonder how well it scales for similar cases in the future in case this becomes a role model. We have this situation a lot in LLDB: compile an input file and use the output in a RUN line. It typically uses separate input files for such purposes (note that "Inputs" folders must be excluded from test discovery somewhere in lit config), e.g.:
> > https://github.com/llvm/llvm-project/blob/release/16.x/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test
> > 
> > What do you think?
> I agree with that. I've seen that some clang tests surround the code in question with `#ifdef LIB` and then in the invocation they add `-DLIB`.
The `#ifdef` approach does not seem to work with clang-repl yet. It does not like unterminated `#ifdef`. So I am going with separate input file. "Inputs" folder seems to be excluded globally in `clang/test/lit.cfg.py`.


================
Comment at: clang/test/Interpreter/dynamic-library.cpp:9
+
+// REQUIRES: host-supports-jit, system-linux
+// RUN: tail -n 16 %s | env LD_LIBRARY_PATH=%T:$LD_LIBRARY_PATH clang-repl | FileCheck %s
----------------
sgraenitz wrote:
> This requirement applies to the entire file right? The arrangement here may imply the opposite.
Moved it to the top of the file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141824/new/

https://reviews.llvm.org/D141824



More information about the cfe-commits mailing list