[Question] Grabbing all sources that are being use from concrete piece of OCaml code or library

Let’s say that there is a tool that already has a summary of functions in OCaml standard library. Now I need to feed it an arbitrary OCaml library L and do symbolic execution (or something…) of a function declared there (let’s say that there is no external C calls except the ones from stdlib). Obviously, the tool should study all dependencies of this library L.

What is the most painless way to obtain relevant sources? I imagine that if all libraries are being compiled with single build system (I will accept dune, if it suits well) the build system can provide all the information needed: dependency graph of the sources in L; the libraries that L depends on, and recursively until we reach stdlib. Which of existing tools can do what I want? If there is no one, how hard will it be to tweak dune to get what I want?

P.S. I think that I might have found similar project: https://github.com/LexiFi/dead_code_analyzer. Maybe @alainfrisch has something to say about my question?