So, I want to give ocamldebug a shot.
Using latest Mac and OCaml 5.3.0:
nojaf@nojaf-mbp rescript % dune build
nojaf@nojaf-mbp rescript % ocamldebug _build/default/analysis/bin/main.bc
OCaml Debugger version 5.3.0
(ocd) break @Main 92
Loading program... Fatal error: cannot load shared library dllext_stubs
Reason: dlopen(dllext_stubs.so, 0x000A): tried: 'dllext_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllext_stubs.so' (no such file), '/usr/lib/dllext_stubs.so' (no such file, not in dyld cache), 'dllext_stubs.so' (no such file)
(ocd)
You can use the environment variable CAML_LD_LIBRARY_PATH to specify where to look up shared libraries containing native stubs (see OCaml - The runtime system (ocamlrun)). Dune places the stubs of native (public) libraries in _build/install/default/lib/stublibs.
nojaf@nojaf-mbp rescript % ls _build/install/default/lib/stublibs
ls: _build/install/default/lib/stublibs: No such file or directory
nojaf@nojaf-mbp rescript % dune exec -- ocamldebug /Users/nojaf/Projects/rescript/_build/default/analysis/bin/main.bc
OCaml Debugger version 5.3.0
(ocd) break @Main 92
Loading program... Fatal error: cannot load shared library dllext_stubs
Reason: dlopen(dllext_stubs.so, 0x000A): tried: 'dllext_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllext_stubs.so' (no such file), '/usr/lib/dllext_stubs.so' (no such file, not in dyld cache), 'dllext_stubs.so' (no such file)
(ocd)
CAML_LD_LIBRARY_PATH rings a bell, but I have no clue where to point it.
I don’t have a Reason toolchain to try it, but a quick look at the source indicates that the missing stubs are those of the library compiler/ext. You may want to look into _build/default/compiler/ext to see if you find your missing shared library.
The Reason toolchain isn’t required here. ReScript compiler is in OCaml, but doesn’t use Reason.
Could I just be missing a dependency? I think at some point it was inside _build/default/compiler/ext. Seems no longer to be the case.
Update:
ls /Users/nojaf/Projects/rescript/_build/default/compiler/ext/*.so
/Users/nojaf/Projects/rescript/_build/default/compiler/ext/dllext_stubs.so
Using CAML_LD_LIBRARY_PATH=/Users/nojaf/Projects/rescript/_build/default/compiler/ext:
Now leads to
Loading program... Fatal error: cannot load shared library dllbase_internalhash_types_stubs
Reason: dlopen(dllbase_internalhash_types_stubs.so, 0x000A): tried: 'dllbase_internalhash_types_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllbase_internalhash_types_stubs.so' (no such file), '/usr/lib/dllbase_internalhash_types_stubs.so' (no such file, not in dyld cache), 'dllbase_internalhash_types_stubs.so' (no such file)
(ocd) %
Okay, I figured it out. I need to append that _build/default/compiler/ext path to CAML_LD_LIBRARY_PATH