restores unit tracking in the plugin facility #1548
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After we switched to OCaml 4.08 and above, we trashed custom unit tracking from our plugin system and started to rely on the Dynlink facility, provided by OCaml, that offers precise unit tracking. However, Dynlink is not allowed inside OCaml Toplevel, which wasn't noticed, because it wasn't properly initialized (though apparently, it worked fine for our needs). But after 4.12 (see ocaml/ocaml#9790) it was properly initialized so we started to get "The dynlink.cma library cannot be used inside the OCaml toplevel" messages when trying to use
baptop
orbap.top
. A quick-fix (#1541) did only worse as it disabled any unit tracking and enabled double-loading of plugins and libraries (which is perfectly allowed in OCaml toplevel and is not a bug, as it was in regular OCaml runtime). Of course, double-loading could crash bap as many of bap libraries have their own state, which got reset after reloading.This PR restores the old findlib-based unit tracker. This tracker is not precise and may still miss loaded units. For example, if you load bap manually and then do
#require "bap.top"
it will reload bap (which should not be a problem, but who knows). With that said, we had used this tracker for many years, up until BAP 2.4.0, so I do have some trust in it. Also, I don't want to invest more time in this issue as we are in the process of switching to dune and the dune plugin system (which has its own unit tracking system that is precise). To be honest, dune plugins also do not work in toplevel right now, but this is a developing story (ocaml/dune#6081) and I hope that eventually, we will have it working.