Antoine
Antoine

Reputation: 1812

How to know which library uses a given symbol?

Js_of_ocaml tells me my bytecode uses caml_blit_string_to_bigstring somewhere. Is there a way to find which library introduces this dependency?

Upvotes: 1

Views: 127

Answers (2)

Antoine
Antoine

Reputation: 1812

I managed to spot caml_blit_string_to_bigstring into cstruct.cma, using ocamlobjinfo.

Using opam list --depends-on=..., I found that Hex uses Cstruct, Ezjsonm uses Hex and Cow uses Ezjsonm.

Now I don't know for sure if it's the code of Ezjsonm that I'm using that triggers the crash.

EDIT I've pinned a custom version of Hex that doesn't rely on cstruct. The problem is gone now.

Upvotes: 2

Daniel Bünzli
Daniel Bünzli

Reputation: 5167

You could try something this:

cd $(opam config var lib)
ocamlobjinfo */*.cmo */*.cmx */*.cma */.cmxa | less 

And then search for your symbol, once you find it move up to find out the File line in which the symbol occurs.

This could also be in sub-sub+ folders but I'm a terrible shell script programmer so I'll let you figure out the right invocation.

Upvotes: 1

Related Questions